File System and File Access Methods in Operating System

In this tutorial, we will learn about the file system and file access methods in operating system. By Prerana Jain Last updated : May 06, 2023

What is a File?

A file is basically a sequence of bytes organized into blocks that are understandable by any machines. In other words, the collection of related information that is stored in a secondary storage device is also called a file. The file is a collection of logically related entities. According to the users view a file is the smallest allots space of the logical secondary storage. The object that stores data, information, settings or commands used with a computer program on a computer is called file. In graphical user interface (GUI) such as Microsoft Windows, files display as icons that relate to the program that opens the file.

By using a software program we can create a file on the computer. For example to create an image file you would use an image editor and create a document you would use a word processor. Computer files are stored on a drive e.g (hard disk), disc (DVD) and diskette (e.g floppy) and may also be contained in a folder (directory) on that medium. Information is kept in files. Files reside on secondary storage. When this formation is to be used, it has to be accessed and brought into primary main memory. Information in files could be accessed in many ways. It is usually dependent on an application.

What are the Attributes of File?

A file is referred by its name, a name or string is a collection of character. There are many systems which differentiate the upper and lower case of the alphabet. When a file is saved by any name it becomes independents for the user and file name should be unique. The system does not allow the files of the same types of name. The attributes of the file may vary from the one operating system to another operating system.

The following are the attributes of a file:

  1. Name - The name of any file is the information which is in readable form for the users.
  2. Identifier - The identifier is a unique tag number which identifies the file within the file system. It is not possible for the human to read the identifier or tag number.
  3. Type - type is needed for the system that supports different types of file.
  4. Size - In this attribute, the current or the maximum size of the file is included( in bytes, words, blocks).
  5. Location - This attribute of the file is the pointer to the file and the location of the file where the file is stored on that device.
  6. Protection - this information determines the control and assigns the power of reading, writing and executing. It also defines that who can do the reading, writing.
  7. Time date and user identification - This type of data is useful for the protection, security and usage monitoring. It also defines the last creation, last modification and last use of the file.

What are the operations of the file?

A file has many properties so to defile the file property operating system provides a lot of information that can be performed on the file. There are many simple and easy operations of file like create, delete, update and some others like rename.

  1. Creating a file - for creating any file there are mainly two steps first the free space is available in the system and second is the new entry of file must be made in the directory.
  2. Writing a file - For writing a file the system call specifies the two things name of the file and the information that is written on the file. When the name of the file is given the system search that file in the directory, the write pointer point the location where the next write is to take place and write pointer is updated.
  3. Reading a file - For reading a file the system call also specifies the two things name of the file and the read pointer. The directory is searched for the given entry and system keep track on the read pointer. The read pointer is updated once the read is completed. The same pointer is used by both the read and write operation on the file.
  4. Deleting a file - For deleting a file first we search for the directory and then erase the directory. After that, we release the space so that it can be reused by another file.
  5. Repositioning of the file - First, the directory is searched for the file and the current position of the file is changed by the new position.

What are File Access Methods?

The file contains the information but when it required to used this information can be access by the access methods and reads into the computer memory. Some system provides only one access method and some provide more than on access method to access the file,

1. Sequential Access Method

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

The idea of Sequential access is based on the tape model which is a sequential access device. We consider Sequential access method is best because most of the records in a file are to be processed. For example, transaction files.

Example: Compilers usually access files in this fashion.

2. Direct or Random Access Methods

Sometimes it is not necessary to process every record in a file. It is not necessary to process all the records in the order in which they are present in the memory. In all such cases, direct access is used.

The disk is a direct access device which gives us the reliability to random access of any file block. In the file, there is a collection of physical blocks and the records of that blocks.

Eg. Databases are often of this type since they allow query processing that involves immediate access to large amounts of information. All reservation systems fall into this category.

Not all operating systems support direct access files. The sequential and direct access of the file is defined at the time of creation and accessed accordingly later. The direct access of a sequential file is not possible but Sequential access to a direct access file is possible.

3. Index Access Method

An indexed file is a computer file with an index that allows easy random access to any record given its file key. The key is an attribute that uniquely identifies a record. We can say that If more than one index is present the other ones are alternate indexes. The creation of the indexes is done with the file but maintained by the system.

4. Index sequential Access Method

The index sequential access method is a modification of the direct access method. Basically, it is kind of combination of both the sequential access as well as direct access. The main idea of this method is to first access the file directly and then it accesses sequentially. In this access method, it is necessary for maintaining an index. The index is nothing but a pointer to a block. The direct access of the index is made to access a record in a file. The information which is obtained from this access is used to access the file. Sometimes the indexes are very big. So to maintain all these hierarchies of indexes are built in which one direct access of an index leads to information of another index access.

The main advantage in this type of access is that both direct and sequential access of files is possible with the help of this method.




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.