





















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






















































Proposed in 1969 by Dijkstra for process synchronization“Cooperating Sequential Processes”
while S <= 0 do nothing; // busy wait S = S - 1;
block
wakeup - P and V atomic Semaphore without busy-wait
Variables/data local to a monitor cannot be directly accessed fromoutside.
mon_name (ep1, ep2, …, epn) { entry_point ep entry_point ep
yes, but only one active
others? - waiting on an event
Data Procedure i Procedure j Process a Process b ConditionVariable.wait ConditionVariable.signal Only one process at a given time Queue for each conditional variable
void CS_exit() { Lock(m) { Lock(m) { while (![condition]) [change shared data Wait(c, m) to reflect out_of_CS] [change shared data [broadcast/signal as needed] to reflect in_CS]
[broadcast/signal as needed]
Readers/Writer example structure:
Reader’s Priority: Monitors ... procedure StartWrite; begin if busy
readcount
then OKtowrite.wait; busy
true; end StartWrite; procedure EndWrite; begin busy
false; if OKtoread.queue then OKtoread.signal; else OKtowrite.signal; end EndWrite; begin
initialization readercount
busy
false; end; end readers-writers.
Reader: StartRead(); ReadFile(); EndRead(); Writer: StartWrite(); WriteFile(); EndWrite();