Critical-Section Problem
Process Structure
-
Each process has a general structure of code as such:

-
Entry section requests permission for the process to enter its critical section
-
Critical section is where the process accesses/updates shared data (data that is shared with other processes
- When one process is executing in its critical section, no other process is allowed to execute in its critical section.
A Solution to the Critical-Race Problem
A solution to the critical-race problem must satisfy three requirements:
- Mutual exclusion — if a process is executing in its critical section, then no other processes can be executing in their critical sections.
- Progress —
Handling Critical Sections
Two general approaches: preemptive vs nonpreemptive kernels:
Peterson’s Solution
Hardware-Based Solutions
Memory Barriers
Hardware Instructions
Atomic Variables
Mutex Locks