30.10.2014 Views

Operating Systems - David Vernon

Operating Systems - David Vernon

Operating Systems - David Vernon

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Processes<br />

void consumer(void)<br />

{<br />

int item;<br />

}<br />

while (TRUE) { /* repeat forever */<br />

if (count == 0) sleep(); /* if buffer is empth, go to sleep */<br />

remove_item(&item); /* take item out of buffer */<br />

count = count - 1; /* deccrement count of items in buffer */<br />

if (count == N-1) wakeup(producer); /* was buffer full */<br />

consume_item(&item);<br />

}<br />

Copyright © 2007 <strong>David</strong> <strong>Vernon</strong> (www.vernon.eu)

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

Saved successfully!

Ooh no, something went wrong!