### Disk Scheduling

• Achieving better performance through scheduling

• Fact:

• There are many disk requests at any one moment in time:

• Service policy:

• Service policy: in which order do you process (= service) the pending requests ?

 The order in which you service the disk operations can affect the performance !!!

• Naive service (but fair): First Come First Serve

• Example policy: First Come, First Serve

• The request that has been received first is serviced first

Example:

The requests are serviced in the order they were made (= time of arrival)

• Advantage of First Come, First Serve:

 Fairness !!!

• Disadvantage of First Come, First Serve:

• Inefficient !!! (e.g. zig-zag read pattern)

Example:

 Request 1: accesses data stored on track 1 Request 2: accesses data stored on track 1001           Request 3: accesses data stored on track 2 Request 4: accesses data stored on track 1002 and so on...

The disk head will move 1000 + 999 + 1000 = 2999 tracks !!!!!

 Because seek time is very long for a disk, moving 2999 tracks is very time consuming

• Commonly used disk scheduling algorithm: the "elevator" algorithm

• Operation of an elevator:

• When someone on floor k presses the elevator request buttom, the request to stop on floor k is entered (made)

• While waiting for the elevator to arrive, other people can arrive

• When the elevator arrives on floor k:

 Every person will be served at the same time !!!

• Elevator scheduling for a disk:

• The disk head sweeps in-and-out (like an elevator)

• When the disk head is on a cylinder k:

 Disk will service all requests for that cylinder before moving to the next cylinder

Graphically:

Example:

 Request 1: accesses data stored on track 1 --- processed first Request 2: accesses data stored on track 1001 - request arrived while disk is accessing track 1 Request 3: accesses data stored on track 2 - request arrived while disk is accessing track 1 Request 4: accesses data stored on track 1002 - request arrived while disk is accessing track 1

Processing order:

1. Request 1: accesses data stored on track 1 --- processed first
2. Request 3: accesses data stored on track 2 !!!! (disk head passes by track 2 next and service request !!!)
3. Request 2: accesses data stored on track 1001
4. Request 4: accesses data stored on track 1002

 Number of tracks traversed = 1001 !!!