File system and storage allocation types.

A file system in an operating system is the component responsible for managing how data is stored, organized, accessed, and protected on a storage device like a disk.

What a File System Deals With


Types of storage allocation

In contiguous allocation, a file is stored in continuous (adjacent) blocks on disk. The disk is already divided into fixed-size blocks, and when a file is created, the operating system allocates a sequence of consecutive blocks to store that file. So instead of scattering data, everything is placed next to each other. The OS only needs to store two things for each file: the starting block (base) and the length (number of blocks).

For example, suppose a file F needs 4 blocks. The OS may allocate blocks 10, 11, 12, 13. So the file is stored as: 
Start = 10 , Length = 4 . If the CPU wants to access the 3rd block of the file, it can directly calculate: 
Physical block = Start + Offset = 10 + 2 = 12. 
This makes access very fast, especially for sequential and even random access.  

Comments