edited by
2,430 views
1 votes
1 votes

Consider Three binary Semaphore Q = R = 1 , S = 0; 


Process P1:-
P(Q);
P(R);
/* CRITICAL SECTION */
V(Q);
V(R);

Process P2:-
P(R);
P(Q);
/* CRITICAL SECTION */
V(Q);
V(R);

Process P3:-
P(S);
/* CRITICAL SECTION */

Q1 Give the status (ie. satisfied or not satisfied) of following :-

1. Mutual Exclusion.

2. Bounded Waiting

3. Progress

4. Deadlock

5. Starvation.

Q2 Consider the Scenario in which process p1 and p2 only with above code and process p3 is not present, now here Process P1 is in critical section for INFINITE AMOUNT OF TIME then process P2 is also trying to enter into critical section,

1. then Bounded Wait is satisfied or not.

2. then Starvation is satisfied or not.

edited by

2 Answers

4 votes
4 votes

1.

Here progress, mutual exclusion , deadlock and starvation satisfied

For ME only one process at a time in critical section

For Progress if P1 don't want to enter into critical section it can't stop P2

For deadlock P1 make Q=0 and preempted then P2 make R=0 then P1 can't perform P(R) same P2 can't perform P(Q) hence Deadlock.

For Starvation P3 never enter into critical section

But bound and waiting not satisfied because any one process can enter into critical section many time

If P3 removed then 

1.bound and waiting not satisfied

2. No starvation

 

 

 

0 votes
0 votes
Q1:

If P1 executes first then it will set semaphore Q=0,R=0 and enter CS and got preempted.

Next P2 executes and sees R=0 and gets blocked.

Next P3...since semaphore S=0 its gets blocked.

Again P1 comes to execution leaves CS and makes Q=1 and R=1.

And P2 executes and enters CS.

P3 never enters CS.

We can execute in any order :).

1).MUTUAL EXCLUSION is satisfied.(since only 1 process enters CS at a time).

2).BOUNDED WAITING is not satisfies.(since p3 does not enter CS and it starves forever ).

3).PROGRESS is guranteed.

4).No deadlock.

5).Yes,there is starvation for p3.

Hope my answer helps :)

Related questions

0 votes
0 votes
1 answer
2
1 votes
1 votes
2 answers
3
0 votes
0 votes
1 answer
4
N3314nch41 asked Sep 10, 2023
341 views
How to approach synchronization (specifically semaphore) question, there size are really intimidating and i’m unable to decode the code written? What to do??