17.04.2014 Views

semaphores, classic problems

semaphores, classic problems

semaphores, classic problems

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The producer/consumer problem<br />

Producer<br />

Buffer<br />

Consumer<br />

Semaphore s = new Semaphore();<br />

cobegin<br />

/* Producer */<br />

while(true) {<br />

produce;<br />

V(s);<br />

} |<br />

/* Consumer */<br />

while(true) {<br />

P(s);<br />

consume;<br />

}<br />

coend<br />

Computing Systems<br />

http://www.cs.caltech.edu/cs134/cs134a October 10, 2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!