24
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo 1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Embed Size (px)

Citation preview

Page 1: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo 1

Disk & disk scheduling

Page 2: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

2

The set of all the tracks in the same relative position on the platter is referred to as a cylinder

Detailed view of a disk

Page 3: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

3

Detailed view of a disk

Page 4: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

4

Detailed view of a disk The sectors and tracks are mapped to a

large 1-dimensional array of logical blocks 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.

Page 5: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

5

Disk scheduling

Avg rotation time =½ revolution time

Transfer time =size(bytes)/transfer speed(bytes/sec)

Page 6: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

6

Disk Performance Factor: Seeking

Seeking: position the head to the desired cylinder Roughly takes 2-5ms

Seeking speed depends on: The power available for the pivot motor: halving the

seek time requires quadrupling the power The arm’s stiffness: accelerations of 30-40g 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 A speedup, a coast, a slowdown, a settle For very short seeks, the settle time dominates (1-3ms)

Page 7: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

7

Disk Performance: OtherFactors

Rotational delay Wait for a sector to rotate underneath the heads Typically 8.3 − 6.0 ms (7,200 – 10,000RPM) or ½

rotation takes 4.15-3ms

Transfer bytes Average transfer bandwidth (15-37 Mbytes/sec)

Performance of transferring 1 Kbytes block Seek (assume is 5 ms) + half rotational delay

(assume is 3ms) + transfer (assume is 0.04 ms) Total time is 8.04ms or 124 Kbytes/sec!

Page 8: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

8

Disk Performance

Quiz: what block size can get 90% of the disk transfer bandwidth?

Page 9: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

9

Disk Performance 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=1800Kbytes ~ 1.8 Mbytes

Page 10: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

10

Disk Behaviors

There are more sectors on outer tracks than inner tracks Read outer tracks: 37.4MB/sec Read inner tracks: 22MB/sec

Seek time and rotational latency dominates the cost of small reads A lot of small disk transfers

waste bandwidth

Page 11: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

11

Disk scheduling

Which disk request is serviced first? FCFS Shortest seek time first SCAN C-SCAN (Circular SCAN)

Page 12: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

12

FIFO (FCFS) order

Method First come first serve

Pros Fairness among requests In the order applications expect

Cons Arrival may be on random spots on the disk

(long seeks) Wild swings can happen

Page 13: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

13

SSTF (Shortest Seek Time First)

Method Pick the one closest on disk

Pros Try to minimize seek time

Cons Starvation

Page 14: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

14

SCAN algorithm

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

Page 15: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

15

SCAN algorithm

Method Take the closest request in the direction of

travel Pros

Bounded time for each request Cons

Request at the other end will take a while

Page 16: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

16

C-SCAN (Circular SCAN)

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

Page 17: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

17

C-SCAN (Circular SCAN)

Method Like SCAN But, wrap around

Pros Uniform service time

Cons Do nothing on the return

Page 18: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

18

Layout of a disk partition

Boot block The first block in partition Executable: loads OS

Followed by file system Super block Free space management File index data (i-nodes) Root dir Files and directories

Page 19: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

19

A typical file system layout

Inode table: In the EXT2 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 EXT2 inodes are kept in the inode table.

Page 20: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

20

The EXT2 Superblock The Superblock contains a description of the basic size

and shape of the file system. Among other information it holds the:

Magic Number: to check that this is indeed an EXT2 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 EXT2 would be the entry for the '/' directory.

Page 21: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

21

Free space management Block allocation bitmap:

This is used during block allocation and deallocation

Inode allocation bitmap: 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 Each bit represents one block/inode Overhead is size of bitmap

Page 22: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

22

Mounting a file system Multiple file system trees can be mounted

together Mount procedure

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

Page 23: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

23

Examples of mounted file systems

Mounting point

/dev/sda3 /dev/sda6

/dev/sda2 Multiple file system trees on different machines can be mounted together by using network file system (NFS)

Page 24: Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Disk & disk scheduling

Copyright ©: Nahrstedt, Angrave, Abdelzaher

24

Logical view: Mounted File System

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.