4 votes 4 votes Consider the following synchronization construct used by two the processes turn1 = true; turn2 = true; Process 1 ... while(true) { turn1 = true; while(turn2); /* Critical Section */ turn1 = false; } ... Process 2 ... while(true) { turn2 = true; while(turn1); /* Critical Section */ turn2 = false; } ... Which one of the following statements is/are TRUE? The proposed solution prevents deadlock but fails to guarantee mutual exclusion. The proposed solution guarantees mutual exclusion but fails to prevent deadlock. The proposed solution guarantees mutual exclusion and prevents deadlock. The proposed solution fails to prevent deadlock and fails to guarantee mutual exclusion. Operating System go2025-os-1 process-synchronization + – gatecse asked Nov 15, 2020 gatecse 318 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 1 votes 1 votes The given code guarantees mutual exclusion but since both turn1 and turn2 are initialized to TRUE both process $1$ and process $2$ will enter the infinite while loop without any progress. So, there is deadlock. Correct answer: B. gatecse answered Nov 15, 2020 • selected Oct 30, 2021 by Arjun gatecse comment Share Follow See all 7 Comments See all 7 7 Comments reply Show 4 previous comments Arjun commented Jan 5, 2021 reply Follow Share If P1 then not P2 = NOT P1 OR NOT P2. Now, (NOT P1 AND NOT P2) implies (NOT P1 OR NOT P2). Or in other words if no process in entering CS, mutual exclusion is satisfied. 12 votes 12 votes shadymademe commented Dec 21, 2022 reply Follow Share Mutual exclusion, non preemption, hold and wait, and circular wait are necessary conditions for deadlock. So, $~\neg \textrm{ME} \cup \neg \textrm{NP} \cup \neg \textrm{HW} \cup \neg \textrm{CW} \rightarrow \neg \textrm{DL} \Leftrightarrow \textrm{DL} \rightarrow \textrm{ME} \cap \textrm{NP} \cap \textrm{HW} \cap \textrm{CW}$. If I can prove deadlock is there in the system, I don't need to check for ME (and other necessary condtions) separately. Is my understanding correct @Arjun @Deepak Poonia sir? 1 votes 1 votes gatecse commented Dec 21, 2022 reply Follow Share yes 1 votes 1 votes Please log in or register to add a comment.