Skip to main content

Critical section; mutual exclusion

Short answer

A critical section is the code segment where a process accesses shared variables, files or tables. Mutual exclusion guarantees that only one process at a time executes its critical section for a given resource; others wait. A solution must also ensure progress and bounded waiting.

Define critical section and mutual exclusion with respect to multiple-process system.

Critical section

In a system of multiple cooperating processes, the critical section (critical region) is the segment of code in which a process accesses shared resources such as shared variables, files or tables. If two processes execute their critical sections on the same shared data at once, the result can be inconsistent (race condition). The structure of each process is:

do {
    entry section        // request permission
        CRITICAL SECTION // access shared data
    exit section         // release permission
    remainder section
} while (TRUE);

Mutual exclusion

Mutual exclusion is the property that only one process at a time may be inside its critical section for a given shared resource; all others who want to enter must wait until it leaves. Hence the shared data are updated consistently and race conditions are avoided.

A correct solution must also satisfy progress (a process outside the critical section must not stop others from entering) and bounded waiting (no process waits forever), and must not assume anything about relative speeds or the number of CPUs. Mutual exclusion is achieved with locks, Peterson's algorithm, TSL, semaphores and monitors.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Operating System chapter 3 questions →