Header Ads

File allocation and access methods

File allocation

File allocation is done to effectively to utilize the file space and for accessing files fast. There are mainly three types of file allocation methods that are explained below:



1. Contiguous allocation

In contiguous memory allocation, the file is stored in any contiguous blocks on the disk. The file location consists of: disk address, address of first block and its length. It supports both types  of file access methods that is sequential access and direct access methods. The main disadvantage of contiguous file allocation method is external fragmentation. One is not sure about the memory needed before creating a new file due to which it is often difficult to find free space for a new file .

2. Indexed allocation

In indexed file allocation system each file has its own index block. It provides a basic solution to the problems that are faced by the other two file allocation methods. All pointer are brought together at one location that is called index block(that occupies space). It does not suffers from external fragmentation as each and every bit of memory can be utilized.

3. Linked allocation

In linked allocation every file is a linked list of disk blocks. The directory contains a pointer to the first block of the file. each block contains the pointer to the next block and the last block contains NIL (0) pointer. The pointer is defined as a NIL pointer in case of an empty file. It does not deals with external fragmentation. However, the main disadvantage of linked allocation is that it does not support direct access method.

File access methods

There are many ways by which the information in the file can be accessed. Some system provides one access method while the other provides many. In a system where multiple file access methods are supported it becomes difficult to choose the right method for an application. There are mainly three types of file access methods as discussed below:


1. Sequential access

It is the most common method used for accessing of files. As the name suggests, information in the files are accessed one by one.It is based on a tape model of a file.

2. Direct access

It is a model of disk model of a file. In direct access method, there is no restrictions on the order of reading and writing .Not all operating systems support both direct and sequential methods. Some system only allows sequential file access others allow only direct access.

3. Other access methods

Other access methods involves construction of an index for a file. The index contains pointer to the various blocks. To find an entry in the file, the index is searched first and the pointer is then used to access the file directly to find the destination entry. This method becomes complex in large file when the index becomes too large to be kept in memory. There is a solution to this problem that is to create an index for the index file. The primary index file would contain pointers to the secondary index files which would point to the actual data items.

No comments:

CSE Solved. Powered by Blogger.