Presentation is loading. Please wait.

Presentation is loading. Please wait.

Free Space Management.

Similar presentations


Presentation on theme: "Free Space Management."— Presentation transcript:

1 Free Space Management

2 Bit Vector Simple and efficient to find the first free block, or consecutive free blocks By bit-manipulation Requires extra space block size = 212 bytes disk size = 230 bytes n = 230/212 = 218 bits (or 32K bytes) Efficient only when the entire vector is kept in main memory Write back to the disk occasionally for recovery needs 1 2 n-1 0  block[i] free 1  block[i] occupied bit[i] =  Question: What’s the block # of the fist free block?

3 Linked List Link together all free blocks
Keep a pointer to the first free block in a special location on the disk and caching it in memory Cannot get contiguous space easily No waste of space Not efficient: have to traverse the disk for free spaces Usually, OS needs one free block at a time FAT incorporate the linked list mechanism

4 Grouping And Counting Grouping: store the address of n free blocks in the first free block. The first n-1 are actually free. The final block contains the addresses of another n free blocks… Counting: Each entry has a disk address and a count Several contiguous blocks may be allocated or freed simultaneously

5 Example Of Free-Space Management
Bit Vector Grouping Block 2  3, 4, 5 Block 5  8, 9, Block 10  11, 12, Block 13  17, 28, Block 25  26, 27 Counting

6 Efficiency and Performance

7 Efficiency and Performance
Efficiency dependent on Disk allocation and directory algorithms Types of data kept in file’s directory entry Performance On-board cache – local memory in disk controller to store entire tracks at a time Disk cache – separate section of main memory for frequently used blocks (LRU is a reasonable algorithm for block replacement) Free-behind and read-ahead – techniques to optimize sequential access (optimize the disk cache’s block replacement algorithm) Improve PC performance by dedicating section of memory as virtual disk, or RAM disk.

8 Various Disk-Caching Locations

9 Page Cache Non-unified buffer cache Unified Buffer Cache
A page cache caches pages rather than disk blocks using virtual memory techniques Memory-mapped I/O uses a page cache Routine I/O through the file system uses the buffer (disk) cache Unified Buffer Cache A unified buffer cache uses the same buffer cache to cache both memory-mapped pages and ordinary file system I/O

10 I/O Without/With A Unified Buffer Cache

11 Recovery Consistency checker – compares data in directory structure with data blocks on disk, and tries to fix inconsistencies Use system programs to back up data from disk to another storage device (floppy disk, magnetic tape) Recover lost file or disk by restoring data from backup

12 Log Structured File Systems
Log structured (or journaling) file systems record each update to the file system as a transaction All transactions are written to a log. A transaction is considered committed once it is written to the log However, the file system may not yet be updated 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


Download ppt "Free Space Management."

Similar presentations


Ads by Google