Introduction to File Systems | Operating System - Computer Science Engineering (CSE) PDF Download

File Systems in Operating System

A file is a collection of related information that is recorded on secondary storage. Or file is a collection of logically related entities. From user’s perspective a file is the smallest allotment of logical secondary storage.

Introduction to File Systems | Operating System - Computer Science Engineering (CSE)

Introduction to File Systems | Operating System - Computer Science Engineering (CSE)

File Directories


Collection of files is a file directory. The directory contains information about the files, including attributes, location and ownership. Much of this information, especially that is concerned with storage, is managed by the operating system. The directory is itself a file, accessible by various file management routines.

Information contained in a device directory are:

  • Name
  • Type
  • Address
  • Current length
  • Maximum length
  • Date last accessed
  • Date last updated
  • Owner id
  • Protection information

Operation performed on directory are:

  • Search for a file
  • Create a file
  • Delete a file
  • List a directory
  • Rename a file
  • Traverse the file system

Advantages of maintaining directories are:

  • Efficiency: A file can be located more quickly.
  • Naming: It becomes convenient for users as two users can have same name for different files or may have different name for same file.
  • Grouping: Logical grouping of files can be done by properties e.g. all java programs, all games etc.

1. Single Level Directory

In this a single directory is maintained for all the users.

  • Naming problem: Users cannot have same name for two files.
  • Grouping problem: Users cannot group files according to their need.

Single Level DirectorySingle Level Directory

2. Two Level Directory

In this separate directories for each user is maintained.

  • Path name: Due to two levels there is a path name for every file to locate that file.
  • Now, we can have same file name for different user.
  • Searching is efficient in this method.

Two Level DirectoryTwo Level Directory

3. Tree-Structured Directory


Directory is maintained in the form of a tree. Searching is efficient and also there is grouping capability. We have absolute or relative path name for a file.

Introduction to File Systems | Operating System - Computer Science Engineering (CSE)

File  Allocation Methods

Continuous Allocation

  • A single continuous set of blocks is allocated to a file at the time of file creation. Thus, this is a pre-allocation strategy, using variable size portions. The file allocation table needs just a single entry for each file, showing the starting block and the length of the file. 
  • This method is best from the point of view of the individual sequential file. Multiple blocks can be read in at a time to improve I/O performance for sequential processing. It is also easy to retrieve a single block. 
  • For example, if a file starts at block b, and the ith block of the file is wanted, its location on secondary storage is simply b+i-1.

Disadvantages

  • External fragmentation will occur, making it difficult to find contiguous blocks of space of sufficient length. Compaction algorithm will be necessary to free up additional space on disk.
  • Also, with pre-allocation, it is necessary to declare the size of the file at the time of creation.

Linked Allocation (Non-contiguous allocation)

  • Allocation is on an individual block basis. Each block contains a pointer to the next block in the chain. Again the file table needs just a single entry for each file, showing the starting block and the length of the file. 
  • Although pre-allocation is possible, it is more common simply to allocate blocks as needed. Any free block can be added to the chain. The blocks need not be continuous. Increase in file size is always possible if free disk block is available. 
  • There is no external fragmentation because only one block at a time is needed but there can be internal fragmentation but it exists only in the last disk block of file.

Disadvantages

  • Internal fragmentation exists in last disk block of file.
  • There is an overhead of maintaining the pointer in every disk block.
  • If the pointer of any disk block is lost, the file will be truncated.
  • It supports only the sequencial access of files.

Indexed Allocation

  • It addresses many of the problems of contiguous and chained allocation. In this case, the file allocation table contains a separate one-level index for each file: The index has one entry for each block allocated to the file. Allocation may be on the basis of fixed-size blocks or variable-sized blocks. 
  • Allocation by blocks eliminates external fragmentation, whereas allocation by variable-size blocks improves locality. This allocation technique supports both sequential and direct access to the file and thus is the most popular form of file allocation.

Introduction to File Systems | Operating System - Computer Science Engineering (CSE)

Disk Free Space Management
  • Just as the space that is allocated to files must be managed ,so the space that is not currently allocated to any file must be managed. To perform any of the file allocation techniques, it is necessary to know what blocks on the disk are available. 
  • Thus we need a disk allocation table in addition to a file allocation table. The following are the approaches used for free space management.
  • Bit Tables: This method uses a vector containing one bit for each block on the disk. Each entry for a 0 corresponds to a free block and each 1 corresponds to a block in use.
    For example: 00011010111100110001
    In this vector every bit correspond to a particular block and 0 implies that, that particular block is free and 1 implies that the block is already occupied. A bit table has the advantage that it is relatively easy to find one or a contiguous group of free blocks. Thus, a bit table works well with any of the file allocation methods. Another advantage is that it is as small as possible.
  • Free Block List: In this method, each block is assigned a number sequentially and the list of the numbers of all free blocks is maintained in a reserved block of the disk.
    Introduction to File Systems | Operating System - Computer Science Engineering (CSE)
The document Introduction to File Systems | Operating System - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Operating System.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
10 videos|99 docs|33 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Introduction to File Systems - Operating System - Computer Science Engineering (CSE)

1. What is a file allocation method?
Ans. A file allocation method is a technique used by the operating system to allocate and manage space for files on a storage device. It determines how the files are stored, accessed, and organized on the storage medium.
2. What is linked allocation in file systems?
Ans. Linked allocation is a non-contiguous file allocation method where each file is represented by a linked list of disk blocks. Each block contains a pointer to the next block in the file. This allows files to be stored in a scattered manner across the storage medium, with the blocks connected by pointers.
3. What are the advantages of linked allocation?
Ans. Linked allocation offers several advantages, including: - Efficient space utilization: Linked allocation allows files to be stored in a non-contiguous manner, which reduces internal fragmentation and makes better use of available disk space. - Dynamic file size: Linked allocation allows files to grow or shrink dynamically without the need for contiguous space. New blocks can be easily added or removed by updating the pointers in the linked list. - Easy file deletion: Linked allocation simplifies file deletion as only the pointers need to be updated, making it a faster operation compared to other allocation methods.
4. What are the limitations of linked allocation?
Ans. Linked allocation also has some limitations, including: - Slow access speed: Accessing a specific block in a file stored using linked allocation can be slower compared to contiguous allocation methods. This is because the operating system needs to traverse the linked list to reach the desired block. - Limited concurrent access: Linked allocation may not be suitable for scenarios where multiple processes need to access the same file simultaneously. As the file blocks are scattered, concurrent access may lead to conflicts and inefficiencies. - Disk fragmentation: Over time, linked allocation can lead to disk fragmentation, where free blocks become scattered across the storage medium. This can affect overall system performance and require periodic disk defragmentation.
5. What is indexed allocation in file systems?
Ans. Indexed allocation is a file allocation method where a separate index block is used to store pointers to the actual data blocks of a file. The index block contains an array of pointers, each pointing to a data block. This enables direct access to any block of the file without the need for traversing linked lists.
10 videos|99 docs|33 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Extra Questions

,

Introduction to File Systems | Operating System - Computer Science Engineering (CSE)

,

Sample Paper

,

past year papers

,

Free

,

study material

,

Important questions

,

Introduction to File Systems | Operating System - Computer Science Engineering (CSE)

,

practice quizzes

,

Semester Notes

,

Summary

,

ppt

,

mock tests for examination

,

Viva Questions

,

Objective type Questions

,

Exam

,

shortcuts and tricks

,

Introduction to File Systems | Operating System - Computer Science Engineering (CSE)

,

Previous Year Questions with Solutions

,

video lectures

,

MCQs

,

pdf

;