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 />

InterProcess Communication IPC<br />

– Mutual Exclusion with Busy Waiting<br />

» Technique 3: Strict Alternation<br />

» Continuously test a variable to see if your turn<br />

has come!<br />

/* Process A */<br />

while (TRUE) {<br />

while (turn != 0);/* wait */<br />

critical_section();<br />

turn = 1;<br />

noncritical_section();<br />

}<br />

/* process B */<br />

while (TRUE) {<br />

while (turn != 1);/* wait */<br />

critical_section();<br />

turn = 0;<br />

noncritical_section();<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!