Home | Projects | Notes > Operating Systems > Mutual Exclusion - Hardware Support

Mutual Exclusion - Hardware Support

 

Interrupt Disabling

In a uniprocessor (multiprogramming) system, concurrent processes cannot have overlapped execution; they can only be interleaved. Furthermore, a process will continue to run until it invokes an OS service or until it is interrupted. Therefore, to guarantee mutual exclusion, it is sufficient to prevent a process from being interrupted.

 

Atomic Operations (Special Machine Instructions)

At the hardware level, access to a memory location excludes any other access to that same location. With this as a foundation, processor designers have proposed several machine instructions that carry out two actions atomically, such as reading/writing or reading/testing, of a single memory location within one instruction fetch cycle. During execution of the instruction, access to the memory location is blocked for any other instruction referencing that location.

Test & Set Instruction

Compare & Swap Instruction

 

References

Stallings, W. (2018). Operating Systems: Internals and Design Principles (9th ed.). Pearson Education, Inc.