/**/ File Management Operating System % - Dextutor

File Management

File management is another important function of an operating system. File management is necessary so that the operating system can map files onto physical devices. Here, in this article, we will learn about files and how file management is done in the system.

What is a file

A file is a named collection of related information. Every file has a location on secondary storage or a non-volatile device like a magnetic disk, tapes, etc. The data cannot be written to secondary storage unless they are within a file. Commonly, files represent programs (both source and object forms) and data in the form of a sequence of bits, bytes or records. Each file in the system possesses desirable properties such as:

  • Long term existence: System stores files on a non-volatile memory like a disk.
  • Sharable between processes: Because files have names and can have associated access permissions that permit controlled sharing.
  • Structure: files can be organized into a hierarchical or more complex structure to reflect the relationships among files.

File System

The file system is a mechanism that provides a means to store data and files in an organized manner along with the functions/operations that can be performed on files. The system identifies every file by its name and a unique identification number called inode number. The inode number refers to the physical file, the data stored in a particular location. Above all, it also maintains other sets of attributes associated with the file. There are different types of file systems a system may support. Some of which are mentioned below type of file system that an operating system supports are:

  • FAT
  • exFAT
  • NTFS
  • Apple file system
  • ext2, ext3,ext4
  • HFS

File Attributes

A file’s attributes may vary from one operating system to another but typically consist of these:

  • Name
  • Identifier
  • Type
  • Location
  • Size
  • Protection
  • Time, date and user information

File Operations

A user or the system can perform different operations on the files. It depends on the permission assigned to the file. Different operations that can be performed on the file are:

  • Create a file
  • Writing a file
  • Reading a file
  • Deleting or truncating a file
  • Reposition the file cursor

File Types

A common technique for implementing file types is to include the type as part of the file name. The system uses the extension to indicate the type of the file and the type of operations that can be done on that file. Various file types are executable, object, source code, batch, text, archive, etc.

File Structure

A File Structure of a file is a predefined format in which the operating system understands. It has an exclusively defined structure, which is based on its type. The files must follow a required structure that is understood by the operating system.

On the other hand, if the operating system supports multiple file structures, the size of the kernel will increase. For instance, an operating system defines five different file structures, the kernel needs to have the code to support these file structures.

Different operating systems support different file structures according to the type of file. For instance,

  • The text file is a sequence of characters in the form of lines.
  • A source file is a sequence of procedures and functions.
  • An object file is a sequence of bytes organized into blocks that are understandable by the machine.

Access Methods

Files store information. When required, this information must be accessed and read into computer memory. Some systems use only one type of access method, others might use many of them. Generally, a file in the system can be accessed using two ways:

  • Sequential Access: This is the simplest access method. The information in the file is accessed in order, one record after the other. Most of the editors and compilers use this method to access the file. It works on a tape model.
  • Direct Access/ Random Access: This method is also called as relative access. The direct-access method allows random access to any file block. For direct access, the file is viewed as a numbered sequence of blocks or records. It works on the disk model.

Directory

There are a number of files that reside in the system. The directory records information -such as name, location, size, and type-for all files on a volume. A directory is viewed as a symbol table which can be organized in many ways. To understand how files are stored in the directory, we need to know what is the logical structure of the directory system. When considering the directory structure, we need to keep in mind what different operations that can be performed on a directory like:

  • Search for a file
  • Create a file
  • Delete a file
  • List a directory
  • Rename a directory
Directories and Files on a disk
Figure-1 Directories and Files on a disk

Directory structure methods

Single-Level Directory:

The single-level directory is the simplest directory structure. All the files are stored in the same directory which is easy to understand. However, there are some limitations to this directory structure.

  • When the number of files increased or when there is an increase in the number of users then this directory structure is not feasible.
  • Since all the files are in the same directory, they must have unique names.
  • It is difficult for a user to remember all the file names.
Single-Level Directory
Figure-2 Single-Level Directory
Two-Level Directory

In this type of structure, each user has its own user file directory (UFD). Each UFD lists only files of a single user. When a user logs in to the system, the system will search the master file directory (MFD). When a user refers to a particular file, the system searches his own UFD. Therefore, different users may have files with the same name. Although this type of structure has resolved many limitations of the single-level directory, it still has many disadvantages

  • Isolation of one user from another.
  • To name a file uniquely, a user must know the pathname of the file desired.
Figure-3 Two-Level Directory
Tree-Structured Directories

Extension of the two-level directory to an arbitrary height. Here, users can create their own subdirectories and organize their files accordingly. To access any file user can make use of absolute or relative paths

Tree-Structured Directory
Figure-4 Tree-Structured Directory
Acyclic-Graph Directory

In the acyclic graph directory, user can share the files and subdirectories. Suppose two users want to work on a single project. They will save the data related to the project in a directory that is shared between the two. A tree structure prohibits the sharing of files or directories. An acyclic graph that is, a graph with no cycles-allows directories to share subdirectories and files.

Figure-5 Acyclic Graph Directory

Directory Implementation

The selection of directory-allocation and directory-management algorithms significantly affects the efficiency, performance, and reliability of the file system.

Linear List

It is the simplest method of implementing directory. It makes use of a linear list of filenames with pointers to the data blocks. This method is simple to design but time-consuming in case of implementation.

Hash Table

It is a combination of a linear list and hash data structure. The hash table takes a value computed from the file name and returns a pointer to the file name in the linear list. The search time is comparatively less. Insertion and deletion are also easy.

PPT

The above discussion is summarized in the form of a PPT with animations below.
Note: Click within the slide area for animations. Clicking on the “next” slide button will not display any animation

Previous                                             Next
Page Replacement Algorithms           File Allocation Methods

1 thought on “File Management”

Leave a Comment