Why the part highlighted the following picture is need? I've been trying to follow to logic flow of it as follow:
Imaging a Situation:
Two processes enter/call F, first A, second B:
Process A: mutex
(value: 1 -> 0) enter the body of F, then calls x.wait()
, so mutex
(value: 0 -> 1) but this process into waiting state because x_sem
(value: 0 -> -1) and now count
(value: 0 -> 1).
Process B: mutex
(value: 1 -> 0) also enter the body of F, then calls x.signal()
, so since count > 0
pass, next_count
(value: 0 -> 1). Now, only at this moment next_count > 0
will pass, but Process B still holding the mutex.
So why the part I highlighted is needed?
The book I'm reading is "Operating System Concepts, 9th ed., pages 229~230."