- A section of code, or a collection of operations, in which only one process may be executing at a given time and which we want to make ``sort of'' atomic. Atomic means either an operation happens in its entirely (everything happens at once) or NOT at all; i.e., it cannot be interrupted in the middle. Atomic operations are used to ensure that cooperating processes execute correctly. Mutual exclusion mechanisms are used to solve the critical region problem
- machine instructions are atomic, high level instructions are not (count++; this is actually 3 machine level instructions, an interrupt can occur in the middle of instructions)
- Fundamental requirements; Concurrent processes should meet the following requirements in order to cooperate correctly and efficiently using shared data:
- Mutual exclusion-no two processes will simultaneously be inside the same critical region (CR).
- No assumptions-may be made about speeds or the number of CPUs. Must handle all possible interleavings.
- Fault tolerance-processes running outside their CR should not block with others accessing the CR.
- Progress-no process should have to wait forever to enter its CR. A process wishing to enter its CR will eventually do so in finite time.
Also, a process in one CR should not block others entering a different CR. Efficiency-a process will remain inside its CR for a short time only, without blocking.
- Conceptually, there are three ways to satisfy the implementation requirements:
- Software approach: put responsibility on the processes
themselves
- Systems approach: provide support within operation system or
programming language
- Hardware approach: special-purpose machine instructions
Figure 6:
Mutual exclusion using critical regions
|
2004-03-21