File System Access Methods-

File access methods refer to the manner in which the records of a file may be accessed. There are several ways to access files −

  1. Sequential access
  2. Direct/Random access
  3. Indexed sequential access

Sequential Access –

Sequential access is that in which the records are accessed in some sequence, i.e., the information in the file is processed in order, one record after the other. This access method is the most primitive one. Example: Compilers usually access files in this fashion.

It is the simplest access method. Information in the file is processed in order, one record after the other. This mode of access is by far the most common; for example, the editor and compiler usually access the file in this fashion.

Read and write make up the bulk of the operation on a file. A read operation -read next- read the next position of the file and automatically advance a file pointer, which keeps track of I/O location. Similarly, for the write next append to the end of the file and advance to the newly written material.

os File Access Methods

key point –

  1. Data is accessed one record right after another record in order.
  2. When we use the read command, it moves ahead pointer by one
  3. When we use the write command, it will allocate memory and move the pointer to the end of the file
  4. Such a method is reasonable for tape.

Direct/Random access-

Another method is direct access method also known as relative access method. A filed-length logical record that allows the program to read and write record rapidly. in no particular order. The direct access is based on the disk model of a file since disk allows random access to any file block. For direct access, the file is viewed as a numbered sequence of block or record. Thus, we may read block 14 then block 59 and then we can write block 17. There is no restriction on the order of reading and writing for a direct access file.

A block number provided by the user to the operating system is normally a relative block number, the first relative block of the file is 0 and then 1 and so on.

os File Access Methods

key point –

  1. Random access file organization provides, accessing the records directly.
  2. Each record has its own address on the file with by the help of which it can be directly accessed for reading or writing.
  3. The records need not be in any sequence within the file and they need not be in adjacent locations on the storage medium.

Index sequential method –

It is the other method of accessing a file that is built on top of the sequential access method. These methods construct an index for the file. The index, like an index in the back of a book, contains the pointer to the various blocks. To find a record in the file, we first search the index, and then with the help of a pointer, we access the file directly.

key point- 

  1. This mechanism is built upon the base of sequential access.
  2. An index is created for each file which contains pointers to various blocks.
  3. The index is searched sequentially and its pointer is used to access the file directly

Space Allocation

Files are allocated disk spaces by the operating system. Operating systems deploy the following three main ways to allocate disk space to files.

  1. Contiguous Allocation
  2. Linked Allocation
  3. Indexed Allocation

Contiguous Allocation

  1. Each file occupies a contiguous address space on the disk.
  2. The assigned disk address is in linear order.
  3. Easy to implement.
  4. External fragmentation is a major issue with this type of allocation technique.

Linked Allocation

  1. Each file carries a list of links to disk blocks.
  2. The directory contains a link/pointer to the first block of a file.
  3. No external fragmentation
  4. Effectively used in sequential access files.
  5. Inefficient in case of direct access file.

Indexed Allocation

  1. Provides solutions to problems of contiguous and linked allocation.
  2. An index block is created having all pointers to files.
  3. Each file has its own index block which stores the addresses of disk space occupied by the file.
  4. The directory contains the addresses of index blocks of files.

IMPORTANT LINKS

  1. Explain File Allocation Methods
  2. What is Directory Structure in 
  3. What is Cache Memory Organization What is Program Design Explain File Allocation Methods USFULL PRODUCT

Tygot Adjustable Aluminium Alloy Tripod Stand Holder for Mobile Phones & Camera, 360 mm -1050 mm, 1/4 inch Screw + Mobile Holde

 DONATE SOME MONEY TO THIS BLOG AND CREATERS

0