Please note that in both variants of mutual exclusion: Figs. 12.6 and 12.7 we
have to assume un-interrupting execution of tests of global variable and setting of
own variables.
This is supported by hardware instruction usually called “test and set” introduced in early 50s hardware architectures.
Mutual exclusion is implemented here because entering of the critical section is
taking place if and only if:
• either other process does not want to enter, or
• other process wants to enter, but it is not its turn.
A property called progress is achieved: both processes cannot wait forever at a
while loop.
The process gets access to the critical section immediately if other processes do
not want to enter, or other processes (matching turn) will eventually finish.
Starvation free property is also fulfilled as one process after entering the waiting
phase will wait at most one critical section.
C2=0?
Turn =1?
Turn =2?
C1:=1
C1:=0
Critical section 1:,
turn := 2, c1:=1
Noncritical 1
Y
N
Y
Y
C1=0?
Turn =2?
Turn =1?
C2:=1
C2:=0
Critical section 2:,
turn := 1, c2:=1
Noncritical 2
Y
Y
Y
Fig. 12.6 Synchronization by Dekker for two processes
12.3 Communication of Sequential Processes: Principles of Synchronization
185
Précédent

- 197/315

Suivant