Definition
Critical Section
A critical section (or critical segment) is a portion of a program that accesses a shared resource, such as a global variable, a data structure, or a hardware device. To ensure data consistency, the execution of critical sections must be protected by mutual exclusion.
A process’s execution trace can be divided into non-critical segments (where no shared data is touched) and critical sections (where the process accesses the critical region).
Safety Requirements
Any solution to the critical section problem must satisfy three requirements:
- Mutual Exclusion: Only one process can execute in its critical section at any given time.
- Progress: If no process is in its critical section and some wish to enter, the selection process must be made in finite time.
- Bounded Waiting: There must be a limit on the number of times other processes are allowed to enter their critical sections after a process has made a request to enter.