0% found this document useful (0 votes)
41 views5 pages

Access Methods

The document discusses different methods for accessing files in a computer system including sequential access, direct access, and index sequential access. It also covers different file structures and directory structures such as single-level, two-level, tree-structured, and acyclic graph directories.

Uploaded by

zaidaan khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views5 pages

Access Methods

The document discusses different methods for accessing files in a computer system including sequential access, direct access, and index sequential access. It also covers different file structures and directory structures such as single-level, two-level, tree-structured, and acyclic graph directories.

Uploaded by

zaidaan khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Access Methods

When a file is used, information is read and accessed into computer memory and there are
several ways to access this information of the file. Some systems provide only one access
method for files. Other systems, such as those of IBM, support many access methods, and
choosing the right one for a particular application is a major design problem. There are three
ways to access a file into a computer system:

Sequential-Access,

Direct Access,

Index sequential Method.

Sequential Access – 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,
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 I/O location. Similarly, for the writewrite
next append to the end of the file and advance to the newly written material.

Key points:

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

Direct 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.

Index sequential method – It is the other method of accessing a file which is built on the top of
the direct 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 by the help of pointer we access the file directly.

Key points: It is built on top of Sequential access.

It control the pointer by using index.


A file is a named collection of related information that is recorded on secondary storage such as
magnetic disks, magnetic tapes and optical disks. In general,

a file is a sequence of bits, bytes, lines or records whose meaning is defined by the files creator
and user.

File Structure A File Structure should be according to a required format that the operating system
can understand. A file has a certain defined structure according to its type.

A text file is a sequence of characters organized into lines.

A source file is a sequence of procedures and functions.

An object file is a sequence of bytes organized into blocks that are understandable by the
machine.

When operating system defines different file structures, it also contains the code to support
these file structure. Unix, MS-DOS support minimum number of file structure.

File Type File type refers to the ability of the operating system to distinguish different types of
file such as text files source files and binary files etc.

Many operating systems support many types of files. Operating system like MS-DOS and UNIX
have the following types of files –

Ordinary files These are the files that contain user information. These may have text, databases
or executable program.

The user can apply various operations on such files like add, modify, delete or even remove the
entire file.

Directory files These files contain list of file names and other information related to these files.

Special files These files are also known as device files.

These files represent physical device like disks, terminals, printers, networks, tape drive etc.

These files are of two types − Character special files − data is handled character by character as
in case of terminals or printers. Block special files − data is handled in blocks as in the case of
disks and tapes.
File System Structure

File System provide efficient access to the disk by allowing data to be stored, located and
retrieved in a convenient way.

A file System must be able to store the file, locate the file and retrieve the file. Most of the
Operating Systems use layering approach for every task including file systems.

Every layer of the file system is responsible for some activities.

The image shown below, elaborates how the file system is divided in different layers, and also
the functionality of each layer.

When an application program asks for a file, the first request is directed to the logical file system.
The logical file system contains the Meta data of the file and directory structure. If the
application program doesn't have the required permissions of the file then this layer will throw an
error. Logical file systems also verify the path to the file.

Generally, files are divided into various logical blocks. Files are to be stored in the hard disk and
to be retrieved from the hard disk.

Hard disk is divided into various tracks and sectors. Therefore, in order to store and retrieve the
files, the logical blocks need to be mapped to physical blocks.

This mapping is done by File organization module. It is also responsible for free space
management.

Once File organization module decided which physical block the application program needs, it
passes this information to basic file system.

The basic file system is responsible for issuing the commands to I/O control in order to fetch
those blocks.

I/O controls contain the codes by using which it can access hard disk. These codes are known
as device drivers. I/O controls are also responsible for handling interrupts.
A directory is a container that is used to contain folders and file.

It organizes files and folders into a hierarchical manner.

Single-level directory –

Single level directory is simplest directory structure.In it all files are contained in same directory
which make it easy to support and understand.

A single level directory has a significant limitation, however, when the number of files increases
or when the system has more than one user. Since all the files are in the same directory, they
must have the unique name . if two users call their dataset test, then the unique name rule
violated.

Advantages:

Since it is a single directory, so its implementation is very easy. If files are smaller in size,
searching will faster. The operations like file creation, searching, deletion, updating are very easy
in such a directory structure.

Disadvantages:

There may chance of name collision because two files cannot have the same name. Searching
will become time taking if directory will large. In this cannot group the same type of files
together.

Two-level directory –

As we have seen, a single level directory often leads to confusion of files names among different
users. the solution to this problem is to create a separate directory for each user.

In the two-level directory structure, each user has their own user files directory (UFD). The UFDs
has similar structures, but each list only the files of a single user. system’s master file directory
(MFD) is searches whenever a new user id=s logged in. The MFD is indexed by username or
account number, and each entry points to the UFD for that user.

Advantages:
We can give full path like /User-name/directory-name/.

Different users can have same directory as well as file name.

Searching of files become easier due to path name and user-grouping.

advantages:

A user is not allowed to share files with other users.

Still it not very scalable, two files of the same type cannot be grouped together in the same user.

Tree-structured directory –

Once we have seen a two-level directory as a tree of height 2, the natural generalization is to
extend the directory structure to a tree of arbitrary height.

This generalization allows the user to create there own subdirectories and to organize on their
files accordingly.

A tree structure is the most common directory structure. The tree has a root directory, and every
file in the system have a unique path.

Advantages:

Very generalize, since full path name can be given. Very scalable, the probability of name
collision is less. Searching becomes very easy, we can use both absolute path as well as relative.

Disadvantages:

Every file does not fit into the hierarchical model, files may be saved into multiple directories. We
can not share files. It is inefficient, because accessing a file may go under multiple directories.

Acyclic graph directory –

An acyclic graph is a graph with no cycle and allows to share subdirectories and files.

The same file or subdirectories may be in two different directories.

It is a natural generalization of the tree-structured directory. It is used in the situation like when
two programmers are working on a joint project and they need to access files. The associated
files are stored in a subdirectory, separating them from other projects and files of other
programmers, since they are working on a joint project so they want the subdirectories to be into
their own directories. The common subdirectories should be shared. So here we use Acyclic
directories. It is the point to note that shared file is not the same as copy file . If any programmer
makes some changes in the subdirectory it will reflect in both subdirectories.

You might also like