Monitors implemented with Semaphores
if next-count > 0 then V(next) else V(mutex);
x.wait:
x-count:=x-count+1;
if next-countɬ then V(next) else V (mutex);
P(x-sem);
x-count:=xcount-1
x.signal
if x-countɬ
then begin
next-count:=next_count+1;
V(x-sem);
P(next);
next-count:=next-count-1;
end;
General entry wrapper for all operations.