Doubt (Count semph, implemented by bin semph.)

20 views
Skip to first unread message

Rashmi Konnur

unread,
Apr 24, 2025, 9:50:19 AMApr 24
to Operating Systems for MTech/JRF (CS) students at ISI Kolkata
In the slide pg.22, why is wait(S) nested inside another wait_b-signal_b pair? Shouldn't the wait_b(S2) be sufficient for maintaining a queue of procs? Is the Wait_b(S3) used for bounded waiting?

Mandar Mitra

unread,
Apr 24, 2025, 12:00:52 PMApr 24
to Rashmi Konnur, Operating Systems for MTech/JRF (CS) students at ISI Kolkata
I did not have time to discuss binary semaphores in class, so this is, strictly speaking, not in the syllabus.

But the answer is yes, S3 is required to ensure bounded waiting.

Without S3, the following could happen. Suppose C is initialised to 1, and P0 is in the critical section. When P1 is inside wait(S), there could be a context switch between signal_b(S1) and wait_b(S2). During this time, P2 and P0 could get alternating access to the critical section an arbitary number of times before P1 gets access, violating bounded waiting.
Reply all
Reply to author
Forward
0 new messages