in Operating System
221 views
0 votes
0 votes

Is the below given Peterson’s solution free from deadlock ?

I am getting a doubt that if we preempt the P0 after executing line 1 and if P1 arrives next it will get blocked . Once P0 resumes it will get blocked. So both are in deadlock , Is that correct?

in Operating System
221 views

3 Comments

While P1 is in while loop, and P0 resumes and executes line no. 2 that is turn=1;

P1 while loop condition shows false and it gets into CS and P0 gets stuck.

So, no deadlock.
0
0
Deadlock happens when both processes/codes are running and both are waiting for a resource/variable occupied by other. Getting blocked is NOT deadlock. Do not get confused.
0
0
Thank you , I got it.
0
0

Please log in or register to answer this question.