IAE Academy

GATE 2020 CS Q.35: solution and answer

GATE 2020 · CSQ.35 · 2 marks · MCQ

Consider the following five disk access requests of the form (request id, cylinder number) that are present in the disk scheduler queue at a given time.

(P, 155), (Q, 85), (R, 110), (S, 30), (T, 115)

Assume the head is positioned at cylinder 100. The scheduler follows Shortest Seek Time First scheduling to service the requests.

Which one of the following statements is FALSE?

  1. (A)

    T is serviced before P.

  2. (B)

    Q is serviced after S, but before T.

  3. (C)

    The head reverses its direction of movement between servicing of Q and P.

  4. (D)

    R is serviced before P.

See the question in the paper

Answer and solution

ANSWER

The false statement is (B): under SSTF the order is R, T, Q, S, P, so Q is served before S and after T.

Official answer: BSource: Official answer key, GATE 2020 CS (IIT Delhi)

  1. Shortest Seek Time First always serves the pending request whose cylinder is nearest the current head position. The head starts at cylinder 100.

  2. From 100 the distances are , , , , . The nearest is (110), so serve . The head is now at 110.

  3. From 110 the distances are , , , . Serve (115). The head is now at 115.

  4. From 115 the distances are , , . Serve (85). The head is now at 85.

  5. From 85 the distances are , . Serve (30). The head is now at 30. The last request is (155).

  6. Check the options against this order. (A) is 2nd and is 5th, so is served before : true. (B) is 3rd and is 4th, so is served before , not after it (and it is also after , not before it): false. (C) After (85) the head moves down to 30 for , then up to 155 for , so it reverses direction between and : true. (D) is 1st and is 5th: true.

  7. The only false statement is (B).

KEY IDEA

With SSTF, recompute the distance from the current head position to every pending request after each service and always take the smallest. Write down the full service order, then test each option against it.

WATCH OUT FOR

Computing every distance from the starting cylinder 100 once and sorting by it. That gives R, then Q or T, then P, then S, which is wrong because the head moves after each service. Another slip is missing that Q (85) and T (115) are both 15 away at the start, so the tie only matters if you do not move first. Here R is strictly nearest, and the head then reaches T before Q.

From the GATE 2020 CS paper. Every question of this paper · Download the full paper · All 6 File systems & disks questions, with notes

More File systems & disks questions