553 views
0 0 votes

Consider the following codes for critical section problem and set of statements 

image:p53.PNG

I) CODE 1 guarantees Mutual Exclusion
II) CODE 2 guarantees Mutual Exclusion
III) CODE 2 leads to Deadlock

Which of the above statements are TRUE

  1.   I and III only
  2.  I and II only
  3.   All I,II and III
  4.   II and III only

1 Answer

1 1 vote

Answer is 4) Statement II : Code 2 gurantees ME and spin lock is possible in it therefore leads to deadlock.


Reasoning :
Counter ex for statement 1)

At the very initial time both have false entries at respective index in shared array ,Now P0 check P1's index which is false and gets preempted and Now P1 hold computation and check P0's index and enters CS and gets Preempted .
After this point both are in CS which leads to Alter the condition of ME.


Condition of Spin lock for statement 3)

P0 asks for CS and make entry true at respective index in shared array and gets preempted
P1 asks for CS and make entry true at respective index in shared array and gets prempted now at this point of time no matter which process gets schedule it gets stuck in while loop and therefore spin lock will result to deadlock.

Position:
Show:

Related questions

1 1 vote
2 2 answers
81
81 views
Tushal_Kumar asked Sep 21
81 views
Q4. A fast-food restaurant has four kinds of employees: (1) order takers, who take customers’ orders; (2)cooks, who prepare the food; (3) packaging specialists, who stuff...
0 0 votes
1 1 answer
126
126 views
DΛΞMON asked Sep 9
126 views
\begin{aligned}&\text { Q. Which of following is/are true statements. }\\&\text { A) Suppose we have } 3 \text { process P0 P1 P2 and we want to run all concurrently then...
6 6 votes
2 2 answers
267
267 views
GO Classes asked Aug 31
267 views
Which of the following data structures can be used by a file system to manage free disk blocks?Bitmap Inode Free-block linked list File Allocation Table, FAT I and II onl...
4 4 votes
1 1 answer
184
184 views
GO Classes asked Aug 31
184 views
A segmentation-based memory-management system maintains a shared segment table.Processes $P_1$ and $P_2$ both share segment $S$.Which of the following statements is incor...