30.10.2014 Views

Operating Systems - David Vernon

Operating Systems - David Vernon

Operating Systems - David Vernon

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Processes<br />

InterProcess Communication IPC<br />

– Mutual Exclusion with Busy Waiting<br />

» Technique 5: TSL<br />

enter_region:<br />

tsl register, flag ! Copy flag to register and set flag to 1<br />

cmp register, #0 ! Was flag zero?<br />

jnz enter_region ! If it was non-zero, lock was set, so loop<br />

ret ! Now zero, so return to caller and allow entry<br />

! to critical region<br />

leave_region:<br />

mov flag, #0 ! Store a 0 in flag<br />

ret ! Return to caller<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!