Presentation is loading. Please wait.

Presentation is loading. Please wait.

File-System Structure

Similar presentations


Presentation on theme: "File-System Structure"— Presentation transcript:

1 File-System Structure
File structure Logical storage unit Collection of related information File system resides on secondary storage (disks). Each file system on a separate disk partition. File control block – storage structure consisting of information about a file. OSes use different allocation methods An allocation method refers to how disk blocks are allocated for files: Contiguous allocation Linked allocation Indexed allocation Operating System Concepts

2 Contiguous Allocation
Each file occupies a set of contiguous blocks on the disk. Simple – only starting location (block #) and length (number of blocks) are required. Random access. Wasteful of space (dynamic storage-allocation problem). Files cannot grow. Non of the common OSes uses this method. Operating System Concepts

3 Contiguous Allocation of Disk Space
Operating System Concepts

4 Operating System Concepts
Linked Allocation Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. Each block contains data and a pointer to the next block. Simple - needs only starting address Free-space management system - no waste of space. No random access. File-allocation table (FAT) - disk-space allocation used by MS-DOS and OS/2 employs this method. Operating System Concepts

5 Operating System Concepts
Linked Allocation Operating System Concepts

6 File-Allocation Table
Operating System Concepts

7 Operating System Concepts
Indexed Allocation Brings all pointers together into the index block. Needs an index table. Random access. Dynamic access without external fragmentation, but has overhead of index block. Operating System Concepts

8 Indexed Allocation (Cont.)
Operating System Concepts

9 Operating System Concepts
Two-level index outer-index index table file Operating System Concepts

10 Operating System Concepts
UNIX File System (UFS) Operating System Concepts

11 Free-Space Management
Bit vector (n blocks) Bit map requires extra space, but usually a small one. Example: block size = 212 bytes disk size = 230 bytes (1 gigabyte) n = 230/212 = 218 bits (or 32K bytes) Easy to get contiguous files. 1 2 n-1 0  block[i] free 1  block[i] occupied bit[i] =  Operating System Concepts

12 Linked list (free list)
Each freed block contains a pointer to the next free block. No need for space of the bit vector, but needs a space for the pointers. (FAT anyway has a space for a pointer in each block) Cannot get contiguous space easily. Error in one pointer can be crucial. Operating System Concepts

13 Operating System Concepts
Linked list (Cont.) Operating System Concepts

14 Operating System Concepts
Buffer Cache Separate section of main memory for frequently used blocks. Memory-mapped I/O uses Buffer Cache. Operating System Concepts

15 Operating System Concepts
Recovery If computer is shut down abruptly, buffer cache may not be flashed into the disk  The disk may have some inconsistencies. Consistency checking – compares data in directory structure with data blocks on disk, and tries to fix inconsistencies. E.g. try to find blocks which are not free, but do not belonged to any file. scandisk on Windows and fsck on UNIX can try to automatically fix such inconsistencies. Operating System Concepts

16 Operating System Concepts
Journaling Journaling File System (or Log structured File Systems) records each update to the file system as a transaction. All transactions are written to a log. The log is on the disk. A transaction is considered committed once it is written to the log. However, the file system may not be updated yet. The transactions in the log are asynchronously written to the file system. When the file system is modified, the transaction is removed from the log. If the file system crashes, all remaining transactions in the log must still be performed. Operating System Concepts


Download ppt "File-System Structure"

Similar presentations


Ads by Google