Disk disk scheduling Copyright Nahrstedt Angrave Abdelzaher Caccamo
Disk & disk scheduling Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo 1
Copyright ©: Nahrstedt, Angrave, Abdelzaher Detailed view of a disk The set of all the tracks in the same relative position on the platter is referred to as a cylinder 2
Copyright ©: Nahrstedt, Angrave, Abdelzaher Detailed view of a disk 3
Copyright ©: Nahrstedt, Angrave, Abdelzaher Detailed view of a disk n The sectors and tracks are mapped to a large 1 -dimensional array of logical blocks n n n The sector is the smallest data unit that can be transferred from/to disk and is equivalent to a data block For example, block 0 is the first sector of the first track on the outermost (or innermost) cylinder. In UNIX filesystem, size of a block is typically 512 or 1024 bytes. 4
Copyright ©: Nahrstedt, Angrave, Abdelzaher Disk scheduling Avg rotation time = ½ revolution time Transfer time = size(bytes)/transfer speed(bytes/sec) 5
Copyright ©: Nahrstedt, Angrave, Abdelzaher Disk Performance Factor: Seeking n Seeking: position the head to the desired cylinder n n Seeking speed depends on: n n n Roughly takes 2 -5 ms The power available for the pivot motor: halving the seek time requires quadrupling the power The arm’s stiffness: accelerations of 30 -40 g are required to achieve good seek times, and a too flexible arm can twist and bring the head into contact with the platter surface. A seek is composed of n n A speedup, a coast, a slowdown, a settle For very short seeks, the settle time dominates (1 -3 ms) 6
Copyright ©: Nahrstedt, Angrave, Abdelzaher Disk Performance: Other Factors n Rotational delay n n n Transfer bytes n n Wait for a sector to rotate underneath the heads Typically 8. 3 − 6. 0 ms (7, 200 – 10, 000 RPM) or ½ rotation takes 4. 15 -3 ms Average transfer bandwidth (15 -37 Mbytes/sec) Performance of transferring 1 Kbytes block n n Seek (assume is 5 ms) + half rotational delay (assume is 3 ms) + transfer (assume is 0. 04 ms) Total time is 8. 04 ms or 124 Kbytes/sec! 7
Copyright ©: Nahrstedt, Angrave, Abdelzaher Disk Performance n Quiz: what block size can get 90% of the disk transfer bandwidth? 8
Copyright ©: Nahrstedt, Angrave, Abdelzaher Disk Performance n Quiz: what block size can get 90% of the disk transfer bandwidth? Answer: the transfer time of 1 block should experience 10% overhead (where overhead = seek delay + half rotational delay); hence, if x is the unknown transfer time of 1 block, it follows that overhead / (x + overhead) =. 1 x=9*overhead According to the data given in this slide, x = 72 msec; hence, the block size should be 72/. 04=1800 Kbytes ~ 1. 8 Mbytes 9
Copyright ©: Nahrstedt, Angrave, Abdelzaher Disk Behaviors n There are more sectors on outer tracks than inner tracks n n n Read outer tracks: 37. 4 MB/sec Read inner tracks: 22 MB/sec Seek time and rotational latency dominates the cost of small reads n A lot of small disk transfers waste bandwidth 10
Copyright ©: Nahrstedt, Angrave, Abdelzaher Disk scheduling n Which disk request is serviced first? n n FCFS Shortest seek time first SCAN C-SCAN (Circular SCAN) 11
Copyright ©: Nahrstedt, Angrave, Abdelzaher FIFO (FCFS) order n Method n n Pros n n n First come first serve Fairness among requests In the order applications expect Cons n n Arrival may be on random spots on the disk (long seeks) 12 Wild swings can happen
Copyright ©: Nahrstedt, Angrave, Abdelzaher SSTF (Shortest Seek Time First) n Method n n Pros n n Pick the one closest on disk Try to minimize seek time Cons n Starvation 13
Copyright ©: Nahrstedt, Angrave, Abdelzaher SCAN algorithm n n Move head from side to side serving all requests on the way Requests that arrived too late while scanning in one direction will be served on reverse direction 14
Copyright ©: Nahrstedt, Angrave, Abdelzaher SCAN algorithm n Method n n Pros n n Take the closest request in the direction of travel Bounded time for each request Cons n Request at the other end will take a while 15
Copyright ©: Nahrstedt, Angrave, Abdelzaher C-SCAN (Circular SCAN) n n Move head from side to side serving all requests on ONE way only Requests that arrived too late for one scan will be served on the next 16
Copyright ©: Nahrstedt, Angrave, Abdelzaher C-SCAN (Circular SCAN) n Method n n n Pros n n Like SCAN But, wrap around Uniform service time Cons n Do nothing on the return 17
Copyright ©: Nahrstedt, Angrave, Abdelzaher Layout of a disk partition n Boot block n n n The first block in partition Executable: loads OS Followed by file system n n n Super block Free space management File index data (i-nodes) Root dir Files and directories 18
Copyright ©: Nahrstedt, Angrave, Abdelzaher A typical file system layout n Inode table: n n In the EXT 2 file system, the inode is the basic building block; Every file and directory in the file system is described by one and only one inode. The EXT 2 inodes are kept in the inode table. 19
Copyright ©: Nahrstedt, Angrave, Abdelzaher The EXT 2 Superblock n The Superblock contains a description of the basic size and shape of the file system. Among other information it holds the: n n n n Magic Number: to check that this is indeed an EXT 2 file system Revision Level: The major and minor revision levels Mount Count and Maximum Mount Count Block Size: for example 1024 bytes Free Blocks: number of free blocks in the file system, Free Inodes: number of free Inodes in the file system, First Inode: inode number of the first inode in the file system (in an EXT 2 would be the entry for the '/' directory. 20
Copyright ©: Nahrstedt, Angrave, Abdelzaher Free space management n Block allocation bitmap: n n Inode allocation bitmap: n n n This is used during block allocation and deallocation This is used during inode allocation and deallocation. It allows the system to keep track of allocated and unallocated inodes. Bitmaps for free blocks and inodes n n Each bit represents one block/inode Overhead is size of bitmap 21
Copyright ©: Nahrstedt, Angrave, Abdelzaher Mounting a file system n n Multiple file system trees can be mounted together Mount procedure n n n OS is given the name of the device and the location within the file structure at which to attach the file system (called ‘mount point’ ) OS verifies that the device contains a valid file system (ask device driver to read the device directory and verify that the directory has the expected format) OS notes in its directory structure that a file system is mounted at the specified mount point 22
Copyright ©: Nahrstedt, Angrave, Abdelzaher Examples of mounted file systems /dev/sda 2 Multiple file system trees on different machines can be mounted together by using network file system (NFS) Mounting point /dev/sda 3 /dev/sda 6 23
Copyright ©: Nahrstedt, Angrave, Abdelzaher Logical view: Mounted File System n n Allows # files on system to grow for ever File system must be mounted before it can be available to processes on the system: The OS is given the name of the device, and the location within the file structure at which to attach the files system (mount point) A file system is contained in a partition. A disk can have many partitions. 24
- Slides: 24