160 likes | 383 Views
Operating Systems. Contents: Free Space Management Introduction to Disk and I/O Management Prepared by: Y.Pranay Hasan 11CS30042. Free Space Management. How does OS maintains free blocks for allocating to data? Who manages free space? ( Ans : File Organization Module).
E N D
Operating Systems Contents: • Free Space Management • Introduction to Disk and I/O Management Prepared by: Y.Pranay Hasan 11CS30042
Free Space Management How does OS maintains free blocks for allocating to data? Who manages free space? (Ans : File Organization Module) Disk Blocks Bit vector Data i-node Directory
Free Space Management • Free I-nodes • Marked as free on disk • An array of 50 free i-nodes stored in the superblock • Free file blocks • Stored as a list of 50- free block arrays • First array stored in the superblock
Free Space Management • Bitmap: one bit for each block on the disk • Good to find a contiguous group of free blocks • Small enough to be kept in memory
Free Space Management • File System maintains free-space list to track available blocks • Bit vector or bit map (n blocks) • Each block is represented by 1 bit bit [i] = 1 block[i] is free = 0 implies block[i] is occupied • Bit Vector: 0 1 2 3 4 5 6 7 8 9 10
Bit Map word word • Block number calculation = (no. of bits per word) *(no. of value words) +offset of first 1 bit • The procedure is efficient and also simple in finding the first free blocks or n consecutive free blocks • In the above case Block No = 4 * 1 + 2 = 6 Bit map
Bit Map • Bit map requires extra space Ex: Block Size = 4KB Disk Size = 2 bytes = 1 TB No of blocks = 2 / 2 = 2 bits (256 MB) If clusters of 4 blocks = 64MB of memory Cluster: If all bits are free => available If at least one bit is not free =>not available • Keep the vector in main memory 40 40 12 28
Linked Free Space List on disk • Keep a pointer to the first free block • Link together all the free disk blocks • Cannot get contiguous space easily • Traverse the list, but it turns out to be expensive • Generally we need only first free block • Is there any other way? • yes, there is!!
Method 1: Grouping • Reserve few disk blocks for management • Modify linked list tto store address of next (n-1) free blocks in first free block, plus a pointer to next block that contains free-block pointers (n–1) free block addresses
Method 2 : Counting • Because space is frequently contiguously used in freed with contiguous allocation , extends and clustering • Keep address of first free block and count of following free blocks • Free space list then has entries containing addresses and counts count First address of Free block group
Example problem: Grouping 1KB block 16 bits block no. Each block holds 1KB = 2 / 16 = 512 blocks But last block is for pointer Hence 512 – 1 = 511 blocks. 12
Disk characteristics • Disk Latency = Seek Time + Rotation Time + Transfer Time + Controller Overhead • Seek Time? depends no. tracks move arm, seek speed of disk • Rotation Time? depends on speed disk rotates, how far sector is from head • Transfer Time? depends on data rate (bandwidth) of disk (bit density), size of request
Disk device performance • Average distance sector from head? • 1/2 time of a rotation • 7200 Revolutions Per Minute 120 Rev/sec • 1 revolution = 1/120 sec 8.33 milliseconds • 1/2 rotation (revolution) 4.16 ms • Average no. tracks move arm? • Sum all possible seek distances from all possible tracks / # possible • Assumes average seek distance is random • Disk industry standard benchmark
Example • Calculate time to read 1 sector (512B) for UltraStar 72 using advertised performance; sector is on outer track Ans: Disk latency = average seek time + average rotational delay + transfer time + controller overhead = 5.3 ms + 0.5 * 1/(10000 RPM) + 0.5 KB / (50 MB/s) + 0.15 ms = 5.3 ms + 0.5 /(10000 RPM/(60000ms/M)) + 0.5 KB / (50 KB/ms) + 0.15 ms = 5.3 + 3.0 + 0.10 + 0.15 ms = 8.55 ms