File Access Methods in OS
There are various types of file access methods in the operating system:
- Sequential Access Method
- Direct Access Method
- Index Sequential Access Method
- Sequential Access Method: – Sequential Access Method is one of the simplest file access methods. Most of the OS (operating system) uses a sequential access method to access the file. In this method, word by word, the operating system read the file, and we have a pointer that points the file’s base address. If we need to read the file’s first word, then there is a pointer that offers the word which we want to read and increment the value of the word by 1, and till the end of the file, this process will continue.
The Modern world system offers the facility of index access and direct access to file. But the sequential access method is one of the most used methods because more files like text files, audio files, and the video files require to be sequentially accessed.
- Sequential Access Method is reasonable for tape.
- In the sequential access method, if we use read command, then the pointer is moved ahead by 1.
- If the write command is used, then the memory will be allocated, and at the end of the file, a pointer will be moved.
2. Direct Access Method: – Direct Access Method is also called the Relative access method. In the Database System, we mostly use the Direct Access Method. In most of the situations, there is a need for information in the filtered form from the database. And in that case, the speed of sequential access may be low and not efficient.
Let us assume that each storage block stores 4 records, and we already know that the block which we require is stored in the 10th block. In this situation, the sequential access method is not suitable. Since if we use this, then to access the record which is needed, this method will traverse all the blocks.
So, in this situation, the Direct access method gives a more satisfying result, else the OS (operating system) needs to perform a few complex jobs like defining the block number, which is required. It is mostly implemented in the application of the database.
3. Index Access Method: – Index Access Method is another essential method of file, accessing. In this method, for a file an index is created, and the index is just like an index which is at the back of the book. The index includes the pointer to the different blocks. If we want to find a record in the file, then first, we search in the index, and after that, with the help of the pointer, we can directly access the file.
In the Index Access method, we can search fast in the large database, and also easy. But in this, the method need some additional space to store the value of the index in the memory.
- On top of the sequential access method, the index access method is built.
- The Index access method can control the pointer with the help of the index.