CS FundamentalsEasyGATE CS (PYQ pattern)

A ticket lock has next_ticket = 10 and now_serving = 10 (free). Events in order: T1 acquires, T2 acquires, T3 acquires, T1 releases, T4 acquires, T2 releases, T5 acquires, T3 releases. (acquire = take ticket next_ticket++, then spin until now_serving equals it; release = now_serving++.) Afterwards, what are next_ticket and now_serving, and who holds the lock?

  1. A. next_ticket 15, now_serving 13, held by T5
  2. B. next_ticket 14, now_serving 13, held by T4
  3. C. next_ticket 15, now_serving 13, held by T4
  4. D. next_ticket 15, now_serving 12, held by T3

Correct answer: C. next_ticket 15, now_serving 13, held by T4

Tickets: T1 10, T2 11, T3 12, T4 13, T5 14, so next_ticket = 15. Three releases move now_serving from 10 to 13, which is T4's ticket. T5 (14) keeps spinning; FIFO order follows ticket order, not arrival at the spin loop.

More Operating Systems questions

Exams that ask this topic