File Access Methods
The information that is stored in the files can be accessed in several ways. Some of them are:-
1. Sequential access method- In this method, a process can read all records in a well synchronized manner, starting at the beginning but cannot skip in between and even cannot read these files out of order. The main operations on files that can be carried out are read and write. A read operation reads the next portion of the file and automatically advances a file pointer which tracks the location of I/O. Similarly, a write appends to the end of the file and advances to the end of the newly written data. Sequential files are convenient when the storage medium is magnetic tape.
2. Direct or random access method- A direct access file is made up of collection of records , each of which is identified by a number called record number. In direct access file, one can access any record at any time for reading and writing. There is no order of reading or writing records. For example, one can read record 5 and then record 34. The user specifies relative block numbers of file to the operating system. The relative block numbers are started from 0 to the total number of blocks in file. The direct access provides fastest way to access a record by specifying the record number.
3. Index Sequential Access method- This method is the modified version of direct access method. The index contains pointer to the various blocks. To find an entry in the file, we find search the index and find the pointer of the record to access file entry directly.