130 likes | 305 Views
Disk Layout 10/04/14. Sourav Sarkar 11CS30037. Boot Control Block . Disk. RAM. Contains info needed by the system to boot OS Contains disk address of the block where the OS is stored. Partition Control Block.
E N D
Disk Layout10/04/14 Sourav Sarkar 11CS30037
Boot Control Block Disk RAM • Contains info needed by the system to boot OS • Contains disk address of the block where the OS is stored
Partition Control Block • If the system has multiple OS then the disk must be partitioned into multiple blocks .For each block there is a separate directory structure • Information • No of blocks occupied / free • Size of each block
Partition Control Block(Cont.) Partition Table BootBlock SuperBlock FreeSpaceManagement Inodes Root Files- Directory
Directory Structure • Filenames • Attributes • For each file we have FCB(File Control Block)
In memory File System Structure • Directory Structure holds info about recently accessed directories • Load the entire directory info containing frequently accessed files • Load part of directory(like cache) Filename
System Wide open File Table • Stores the info of all the files that are currently being accessed. It stores FCB of all currently accessed files Per Process open file table File Descriptor Table(Linux) For each process we have an entry in the table with pointers to Appropriate entries in the system wide table(all files opened by the process)
File Handling & The Logical File System • Application program uses the logical file system • Logical Fie System : • Allocates a new FCB • Reads appropriate directory into memory • Updates directory with new filenames and FCB • Write it back to disk
Using the File (I/O) • Open()(Filename) • Directory searched • FCB -> copied into system wide file table • Entry made to per-person open file table(with a pointer to system wide open file table and file descriptor) • Note: For threads proxy tables created in the address space
System Table FCB(k) N(k) • N(k) is the number of process opening file k • When a process closes a particular file its entry is removed from its FDT and n(k) is reduced by 1 • When n(k) = 0 system will write back the file to the disk • Corresponding entry of the system table is removed
Allocating blocks to files • Contiguous allocation : Blocks allocated b,b+1,b+2 … • Performance : • Best in most cases • Simple as only the starting location and length of the file is needed. • Read performance is great • Minimal disk movement • Sequential and direct access
More on block allocation • Problems: • Finding space for file • External Fragmentation • Solution : Compaction • Must know file size a priori ! Not possible file size may gradually increase in most cases. If space exhausted need to move file to new location