Docsity

Disk Interaction-Advance Operating System-Lecture Slides, Slides of Advanced Operating Systems

Partial preview of the text

Download Disk Interaction-Advance Operating System-Lecture Slides and more Slides Advanced Operating Systems in PDF only on Docsity!

Lecture No.

Some useful facts

 Disk reads/writes in terms of sectors, not bytes  read/write single sector or adjacent groups  How to write a single byte? “Read-modify-write”  read in sector containing the byte  modify that byte  write entire sector back to disk  key: if cached, don’t need to read in  Sector = unit of atomicity.  sector write done completely, even if crash in middle  (disk saves up enough momentum to complete)  larger atomic units have to be synthesized by OS

Disk Scheduling

 Because seeks are so expensive (milliseconds!), the

OS tries to schedule disk requests that are queued

waiting for the disk

 FCFS (do nothing)

 Reasonable when load is low
 Long waiting times for long request queues

 SSTF (shortest seek time first)

 Minimize arm movement (seek time), maximize request rate
 Favors middle blocks

 SCAN (elevator)

 Service requests in one direction until done, then reverse

 C-SCAN

 Like SCAN, but only go in one direction (typewriter)

BSD 4.4 Fast File system (FFS)

 Used a minimum of 4096 size disk block

 Records the block size in superblock

 Multiple file systems with different block sizes can co-

reside

 Improves performance in several ways

 Superblock is replicated to provide fault tolerance

Representing Small Files

 Internal fragmentation in the file system blocks can

waste significant space for small files.

 FFS solution: optimize small files for space

efficiency.

 Subdivide blocks into 2/ 4/ 8 fragments (or just frags).

Clustering in FFS

 Clustering improves bandwidth utilization for large

files read and written sequentially.

 FFS can allocate contiguous runs of blocks “most of

the time” on disks with sufficient free space.

 Files can be lost if directory destroyed or crash happens before link can be set  New twist: FFS can find lost inodes  Facts:  FFS pre-allocates inodes in known locations on disk  Free inodes are initialized to all 0s.  So?  Fact 1 lets FFS find all inodes (whether or not there are any pointers to them)  Fact 2 tells FFS that any inode with non-zero contents is (probably) still in use.  fsck places unreferenced inodes with non-zero contents in the lost+found directory

FFS: inode recovery