10.3. Hardware support for mutual exclusion

Many computers have instructions which perform read, conditional modify and write of a memory location within a single bus cycle; that is, they provide an atomic, conditional update of a memory location. With such an instruction we can implement mutual exclusion on a multiprocessor. One example is a test-and-set (TAS) instruction which is typically of the form:

TAS BOOLEANif the boolean indicates that the region is free

then set it to indicate busy and skip the next instruction

else execute the next instruction

If the boolean was free it is now set to busy and the process enters its critical region. If the boolean was busy, the next instruction in sequence is executed (see Figures 10.5 and 10.6). The ...

Get Operating Systems: Concurrent and Distributed Software Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.