in Operating System edited by
572 views
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

 

in Operating System edited by
by
572 views

2 Comments

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
2
u explained everything except answer??
0
0

2 Answers

2 votes
2 votes
This is peterson algo / dickerson solution.

There is mutual exclusion, progress and BC and no deadlock

1 comment

@rish1602  i know peterson algo, but unable to understand this code, can you please help.

0
0
1 vote
1 vote
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.

Related questions