Different Types of Access Methods:
There are several ways to access information in a file. Some systems provide only one access method for files. Some systems provide different access methods. Selection of the right access method for a particular application is a major design problem.
1. Sequential Access:
Information in the file is processed in order, one record after the other. This
is by far the most common mode of access of files. For example, computer editors
usually access files in this fashion.
A read operation reads the next portion of the file and automatically advances
the file pointer. Similarly, a write operation appends to. the end of the file
and advances to the end of the newly written material i.e. the new end of file.
Such a file can be reset to the beginning. On some systems, a program may be
able to skip forward or backward n records for some integer n. This scheme is
known as sequential access. Sequential access is based on a tape model of a
2 Direct Access:
Direct access is based on a disk model of a file. For direct access, the file is
viewed as a numbered sequence of block or records. A direct-access file allows
arbitrary blocks to be read or written. After block 18 has been read, block 57
could be next and then block 3. There are no restrictions on the order of
reading and writing for a direct access file. Direct access files are of great
use for intermediate access to large amounts of information.
The file operations must be modified to include the block number as a parameter.
It works like "read n", where n is the block number rather than "read next".
Similarly, it writes with "write n" rather that "write next".
An alternative "approach retains "read next" and "write next". It adds an
operation "position file to n" where n is the block number. Then we would issue
the command "position to n" and then "read next".
All operating systems support both sequential and direct access for files. Some
systems allow only sequential file access. Others allow only direct access. Some
systems require that a file should be defined as sequential or direct when it is
created. Such a file can be accessed only in a manner defined at the time of its
3. Other Access Methods:
Other access methods can be built on top of a direct-access method. These
additional methods generally involve the construction of an index for a file.
The index contains pointers 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 desired entry.
With a large file, the index itself may become too large to be kept in memory.
One solution is to create an index for the index file. The primary index file
would contain pointers to secondary index files that would point to the actual
For example, IBM's indexed sequential access method (ISAM) uses a small master
index that points to disk blocks of a secondary index. The secondary index
blocks point to the actual file blocks. The file is kept sorted on a defined
key. We first make a binary search of the master index to find a particular
item. It provides the block number of the secondary index. This block is read
in. Binary search is used again to find the block containing the desired record.
Finally, this block is searched sequentially. In this way, any record can be
located from its key by at most direct access reads.