File Management Module in Operating System:

The majority of computer applications use storage facilities provided by magnetic disk and other storage devices to store non-volatile data. A-File is the term used for a logical representation of this non-volatile data.


The File Management Module is the operating system component that manages all the files on secondary storage.

The File Management Module provides a filing system for the following three functions:

1. It provides a means of organizing and accessing files (data) in a convenient way.


2. Perform automatic management of secondary memory space. The exact whereabouts of files in secondary storage should be of no concern to the user.


3. Protect the files against system failure or access by unauthorized users.

1. Accessing and Organizing:

The basic problem of accessing a file for the OS is to hide the major complexities involved in storing the file data on secondary storage. Suppose a source program consists of lines of text terminated by new-line characters. The programmer using this file need not be concerned about how the file is held on disk and how it is packed into physical storage units on the disk surface. He must be able to access the file through a symbolic name.


The symbolic name of a file is the logical view by the user of the physical data on secondary storage. The operating system will keep track of the physical data by keeping a structure (called a file node) containing file information.


The file node will be kept in memory during the operating system run-time for fast access although it must be stored itself on secondary storage once the system goes down.


Nowadays operating systems group file nodes in collections called directories. A directory is a logical grouping of files:


Note:


1. Besides the group of files that it contains the directory structure can hold generic information on who can access the particular files.
2. Like the file nodes/the directory structure is itself stored on secondary storage once the system goes down.
3. The symbolic name of the file will consist of the directory name plus the file name for example "dir1\data.txt".


As the number of applications grew in modern systems, the above directory mechanism evolved into a-multi-level arrangement. It is found in UNIX, Windows and DOS. There is a top-level directory called the root. It can contain references to other files or to other low-level directories forming a tree system:

2. Secondary Memory Space Management:

Organization of file data on secondary storage (example a hard disk) can be different from the logical organization of files by the operating system. Secondary storage is typically organized into fixed-sized blocks, which are a multiple of 512 bytes.


Three major techniques by which file data is organized in these blocks are as follows:


1. Contiguous Blocks Allocation:


In this technique the file data is stored in blocks adjacent to each other (that is the have consecutive numbers). The file node will point to the first block and will contain the length of the file. The whole of each block will be used to hold user data:


Advantages of Contiguous Blocks Allocation:


The advantages of contiguous blocks allocation are as follows:



  • Simple to implement.
  • Damage to a single block results in only localized loss of data. 
  • Any block may be accessed at random making contiguous files ideal for applications such as databases.



Disadvantages of Contiguous Blocks Allocation:


The disadvantages of contiguous blocks allocation are as follows:



  • This technique suffers from fragmentation. As files are created and deleted, the free space becomes broken up into small pieces. No piece may be large enough by itself to hold anything but the smallest file.
  • It is difficult to add and delete blocks in the middle of a file because it has to move all following blocks.



2. Block Linkage:


In this technique a few bytes in each block are used as pointers to the next block. The last block will contain a null pointer (typically zero). The file node will point to the first block:


Advantages of Block Linkage:


The advantage of block linkage is as follows:



  • Fragmentation is eliminated since now any block can be reserved for the file.



Disadvantages of Block Linkage:


The disadvantages of block linkage are as follows:



  • Overhead needed to store the pointer of the next block. Some space is taken from each block to be reserved for the pointer.
  • A large number of disk accesses are needed to find the end of the file. (Sometimes a pointer to the last block is stored in the file node).
  • Access to the file is necessarily sequential since all blocks can be accessed only passing down the chain.
  • Damage to one block can result in great data loss as reference to the following blocks is lost.


3. Index Blocks:

In this technique the linkage pointers for each file are stored in a separate index block on disk. If the file is large then several index blocks may be needed, each one chained to the other. The file node will point to the first index block in the chain:


Advantages of Index Blocks:


The advantages of index blocks are as follows:



  • Fragmentation is eliminated since now any block can be reserved for the file. 
  • File can be accessed sequentially since any block can be accessed at random by simply specifying the name of the file and the offset in the index block.



Disadvantages of Index Blocks:


The disadvantages of index blocks are as follows:



  • Overhead needed to store the pointers of the blocks in the index block. Some space will always be lost from each index block.
  • Addition or deletion of middle blocks will result in rearrangements of pointers in index blocks. This can be a lengthy operation.
  • Damage to index blocks result in great data loss. This is often avoided by storing multiple copies of the index blocks in different areas of the disk. This is a substantial overhead but it provides a good solution.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Blog Archive

Powered by Blogger.

- Copyright © 2013 Taqi Shah Blogspot -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -