Given that five threads concurrently executing parop()
case 1 : when all those five threads execute line 5 and preempt, then All threads blocked at line 6.
Therefore Deadlock occur.
case 2 : If line 5 to Line 10, executive without preemption by threads one after another. then Counter value is 5.
Case 3 : Initially counter = 0, let T1, execute line 5,6 and note that line 7 is non-atomic instruction. So before saving 1, T1 preempt.
And remaining Threads completes the execution. After that T1 resume and make counter = 1 and completes the execution.
Note that Case 3 produces minimum value of counter. So Counter can’t be 0 after the execution of threads.