There are two threads which try to solve critical section problem using Test-And-Set instruction.
The above code prevents deadlock. The detailed explanation is provided in pictures below:
Absolutely right @srestha mam. T2 will busy wait i.e. it will be in a spinlock since blocking of processes, if they have to wait to enter C.S. ,is not mentioned in the code.
@SuvasishDutta
In your point , u mentioned p1MustWait will be False. But in code nowhere it is mentioned as false. Then how are u getting it false?
64.3k questions
77.9k answers
244k comments
80.0k users