1,154 views

Consider the following synchronization construct used by the processes P1, P2 and P3. The S1, S2 and S3 are counting semaphore variables:
S1 = 3, S2 = 2, S3 = 1;
P (S1);
P (S2);
P (S3);
Critical section
V (S3);
V (S2);
(S1);
Which of the below statement is true?

A It satisfies mutual exclusion and progress but not bounding waiting.

B It satisfies both progress and bounded waiting but not mutual exclusion.

C It satisfies mutual exclusion and bounded waiting but not progress.

D It satisfies all the mutual exclusion, progress and bounded waiting.

A?
is it D?
edited
A it is

EDIT:- sorry...m wrong...if a while true function would have been at beginning then we won't have a bounded waiting...here process locks does it work ,up the semaphore and terminates finally.D will be answer
moved
A it is
if the data structure has queue for blocked processes ===> it is bounded waiting
edited

@Shaik Masthan, But in this case one process will always be blocked so from my thinking progress and bounded waiting is not satisfied.

EDIT- I was thinking that there is only 1 up operation will be performed on s3 so only 2 process will get chance to enter critical section but there are 2 up operation.

i am not getting why you are saying it is progress and bounded waiting are not satisfied !

( even question is not same, it will help to solve this question )

ya ok while typing the explanation I got where i am going wrong. All 3 should be satisfied.

if the data structure has queue for blocked processes ===> it is bounded waiting

Shaik Masthan but it is not given in the question ...without queue how we can assure there is bounded waiting.

semaphores by default have a queue for blocked processes

@Shaik Masthan Sir, I think bounded waiting is not guaranteed because if we assume the following case:

S1=3 ; S2= 2 ; S3 = 1

================================

S1 : P1, P2 , P3    ( S1=0)

S2 : P1 , P2          (S2=0)

S3 : P1                  (S3=0)

V(S3) :                  (S3=1)

V(S2) :                 (S4=1)

V(S1):                  (S1=1)

================================

Now P1 is out and again comes for execution

================================

S1 : P2, P3, P1        (S1=0)

S2 : P2, P1              (S2=0) --- P1 can go directly in S2 and so P3 will not get chance

S3 : P2                     (S3=0)

Similarly P2 is out and again comes like P1

=================================

Here in this case P3 is waiting ……because we are not keeping track of who came first and if the first comer should be executed before late comer.

Please tell me what’s wrong because i feel this should be correct !

@Shaik Masthan Sir can you please explain how mutual exclusion is satisfied??  M getting 2 process together in critical section by preempting p1 in V(S3) and then brought P2

what's mistske here?

@MANSI_SOMANIV(s3) by p1 means, p1 is not out of critical section, rt?

Yes sir sorry forgot that, cz I was thinking like process still not exit as did preemption ,still in execution

But here it's out of critical section

Thanks sir

All are satisfied.

Progress is satisfied: As you see P1,P2,P3, Suppose P1 is not interested and P2 wants to get into CS then P1 won't stop to P2. So Progress is satisfied.

Bounded Waiting: Semaphores by default have a queue for blocked process but if not any scheduling algorithm mentioned(FCFS etc...) then also every process get the chance to get into CS.

1 comment

can you tell how ME is satisfied???

1
236 views