Critical Sections
Critical Sections
We can avoid the problem of interference by making actions indivisible or atomic. The piece of code that must appear ( from the point of view of some other process) as an atomic action is called a Critical Section (CS). If processes P and Q both contain critical sections whose overlapped executions could interfere with one another, then we need to ensure these sections are executed under mutual exclusion.
forall e: (CSiP ® CSjQ) or (CSjQ ® CSiP)
for all pairs of processes P and Q and repetitions of their critical sections i and j.
We say that two operations are serialised when they may be executed in either order but without overlap.