2 votes 2 votes The solution for process synchronization is given below : Which of the following is correct about the above given solution? (A) Satisfies Mutual Exclusion (B) Satisfies Progress (C) Satisfies Bounded wait (D) Suffers from deadlock Operating System test-series operating-system process-synchronization multiple-selects + – LRU asked Oct 17, 2021 • edited Oct 17, 2021 by LRU LRU 568 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply Vishal_kumar98 commented Oct 22, 2021 reply Follow Share 1. Mutual exclusion: There are two cases to consider: a. A process is inside the C.S.: Without loss of generality, assume process j is inside the C.S. Before entering the C.S. the process sets its own flag to 1. If process i tries to enter the C.S. it will see that flag[j] is up and gets caught up in the while loop. It will continue in the while loop until the other process sets its own flag to 0, which happens only at the end of the C.S. b. Two processes are trying to enter simultaneously: In this situation, if both processes reach their respective while loop at the top, then the variable turn will ensure that only one of them passes through. The variable turn is alternating between the allowing either process and is only modified at the exit of a C.S. 2. Progress: There are two cases to consider: a. One process is trying to enter with no competition: In such a case, the flag of the other process is down, and the process goes past the while looking into the critical section directly. b. Two processes are trying to enter simultaneously. In this case, if the first process is trapped into the while loop, then the variable turn will make one of the two variables lower its flag and go into a loop waiting for the variable turn to change (the inner while loop). The other process whose turn is set by the variable turn will be able to get through. 3. Bounded Waiting: Assume there is a process blocked inside the inner while loop, while another process is in C.S. In such a case if the process inside the critical section tries to re-enter, it will be blocked because on the exit of the C.S. it has already set the variable turn to point to the other process. Therefore, the process that just got out of the C.S. will be forced to wait for its own turn. So, bounded waiting is taken care of. 2 votes 2 votes sachin486 commented Dec 23, 2021 reply Follow Share u explained everything except answer?? 0 votes 0 votes Please log in or register to add a comment.
2 votes 2 votes This is peterson algo / dickerson solution. There is mutual exclusion, progress and BC and no deadlock rish1602 answered Jan 8, 2022 rish1602 comment Share Follow See 1 comment See all 1 1 comment reply Atharva007 commented Mar 5, 2022 reply Follow Share @rish1602 i know peterson algo, but unable to understand this code, can you please help. 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes when both process are False both will enter in CS so no mutual exclusion. Progress is there, bounded wait is there and it doesnt suffer from deadlock. sachin486 answered Dec 23, 2021 sachin486 comment Share Follow See all 0 reply Please log in or register to add a comment.