CS FundamentalsVery hardGATE CS (PYQ pattern)

In Lamport's bakery algorithm five processes P0 to P4 hold tickets (number, id): P0 has 4, P1 has 3, P2 has 4, P3 is not competing (0) and P4 has 3. In what order do the competing processes enter the critical section?

  1. A. P1, P4, P2, P0
  2. B. P0, P2, P1, P4
  3. C. P1, P4, P0, P2
  4. D. P4, P1, P0, P2

Correct answer: C. P1, P4, P0, P2

Processes are ordered by (ticket, process id), so equal tickets are broken by the smaller id: (3,1), (3,4), (4,0), (4,2). A process with ticket 0 is not waiting.

More Operating Systems questions

Exams that ask this topic