720 views
0 votes
0 votes

Original question - Click here

My question is how deadlock is possible in that question. I've read the discussion and folks are saying that  this below line is not an atomic execution, fair enough!!  And more than one process can have same t[i] value and can stuck at while loop mentioned later in original question, but i don't understand how to processes can get same t[i] value?

pmax (t[0],....,t[n-1])+1; c[i]=0;

 

And this line can broken down as 

  1. LOAD R0, MAX
  2. INCREMENT R0
  3. STORE T[i], R0

 

Now say P0 comes and execute line 1 and got value R0 = 0 and then at line 2) R0 = 1 and now say P0 preempted.

 

Now P1 comes and execute line 1 and 2 and got R1 or R0 = 0 and got preempted, but if you preempt this P1 also, then what process will further execute and if you don't preempt P1 then P1 will have t[1] = 1.

So, how two processes has same t[i] value at any time?

Please log in or register to answer this question.

Related questions

3 votes
3 votes
0 answers
2
iarnav asked Sep 28, 2018
720 views
Any implementation of a critical section requires the use of an indivisible machine- instruction ,such as test-and-set?Is the above statement True or False?
0 votes
0 votes
0 answers
3
Mr L asked Dec 2, 2018
575 views
https://youtu.be/b0XINQEQPWEin this video,Kiran Kumar Sir at 36:30 says the two formulas are not valid.But in 2016 gate question,option C https://gateoverflow.in/39618say...