Critical-Section Problem

Process Structure

A Solution to the Critical-Race Problem

A solution to the critical-race problem must satisfy three requirements:

  1. Mutual exclusion — if a process is executing in its critical section, then no other processes can be executing in their critical sections.
  2. 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