Question

Suppose a disk has 201 cylinders, numbered from 0 to 200. At some time the disk arm is at cylinder 100, and there is a queue of disk access requests for cylinders 30, 85, 90, 100, 105, 110, 135 and 145. If Shortest-Seek Time First (SSTF) is being used for scheduling the disk access, the request for cylinder 90 is serviced after servicing ____________ number of requests.

Official answer and solution
Official answer
3
From
Official GATE 2014 answer key

Solution

Trace the Shortest-Seek Time First (SSTF) disk scheduling algorithm starting from cylinder 100.

Initial head position: cylinder 100.
Pending request queue: {30,85,90,100,105,110,135,145}\{30, 85, 90, 100, 105, 110, 135, 145\}.

  1. At cylinder 100, distance to request 100 is ∣100−100∣=0|100 - 100| = 0.

    • Service cylinder 100 (1st request serviced).
    • Remaining queue: {30,85,90,105,110,135,145}\{30, 85, 90, 105, 110, 135, 145\}.
    • Current head position: 100.
  2. Distances from 100:

    • ∣100−105∣=5|100 - 105| = 5
    • ∣100−90∣=10|100 - 90| = 10
    • Minimum seek distance is 5 (to cylinder 105).
    • Service cylinder 105 (2nd request serviced).
    • Remaining queue: {30,85,90,110,135,145}\{30, 85, 90, 110, 135, 145\}.
    • Current head position: 105.
  3. Distances from 105:

    • ∣105−110∣=5|105 - 110| = 5
    • ∣105−90∣=15|105 - 90| = 15
    • Minimum seek distance is 5 (to cylinder 110).
    • Service cylinder 110 (3rd request serviced).
    • Remaining queue: {30,85,90,135,145}\{30, 85, 90, 135, 145\}.
    • Current head position: 110.
  4. Distances from 110:

    • ∣110−90∣=20|110 - 90| = 20
    • ∣110−135∣=25|110 - 135| = 25
    • Minimum seek distance is 20 (to cylinder 90).
    • Cylinder 90 is the 4th request serviced.

Therefore, cylinder 90 is serviced after servicing 3 requests (100, 105, and 110).

Final answer

3

Common trap

Counting cylinder 90 itself as one of the requests serviced before cylinder 90.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 1
Question
29 of 65, printed as CS Q.19
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.