A disk has 200 tracks (numbered 0 through 199). At a given time, it was…

2004

A disk has 200 tracks (numbered 0 through 199). At a given time, it was servicing the request of reading data from track 120, and at the previous request, service was for track 90. The pending requests (in order of their arrival) are for track numbers. 30 70 115 130 110 80 20 25. How many times will the head change its direction for the disk scheduling policies SSTF(Shortest Seek Time First) and FCFS (First Come Fist Serve)

  1. A.

    2 and 3

  2. B.

    3 and 3

  3. C.

    3 and 4

  4. D.

    4 and 4

Attempted by 77 students.

Show answer & explanation

Correct answer: C

Solution:

Initial state: head is at track 120; the previous request was at track 90, so the initial head direction is toward increasing track numbers (up). Pending requests in arrival order: 30, 70, 115, 130, 110, 80, 20, 25.

SSTF (Shortest Seek Time First):

  • From 120 choose nearest 115 (distance 5): move 120 → 115 (direction: down). Direction change count = 1 (initial was up → now down).

  • 115 → 110 (nearest, down): no direction change (count stays 1).

  • 110 → 130 (nearest, up): direction changes to up (count = 2).

  • 130 → 80 (nearest, down): direction changes to down (count = 3).

  • 80 → 70 (down): no change (count = 3).

  • 70 → 30 (down): no change (count = 3).

  • 30 → 25 (down): no change (count = 3).

  • 25 → 20 (down): no change (final count = 3).

Total direction changes for SSTF: 3.

FCFS (First Come First Serve):

  • Service in arrival order starting from 120: 30, 70, 115, 130, 110, 80, 20, 25.

  • 120 → 30 (down): initial was up → down (count = 1).

  • 30 → 70 (up): change to up (count = 2).

  • 70 → 115 (up): no change (count = 2).

  • 115 → 130 (up): no change (count = 2).

  • 130 → 110 (down): change to down (count = 3).

  • 110 → 80 (down): no change (count = 3).

  • 80 → 20 (down): no change (count = 3).

  • 20 → 25 (up): change to up (final count = 4).

Total direction changes for FCFS: 4.

Answer: 3 and 4 (SSTF = 3 direction changes; FCFS = 4 direction changes).

Explore the full course: Gate Guidance By Sanchit Sir