• reopened by
1,661 views
2 2 votes
If there are n processes executing concurrently using binary semaphore S , (n-1) processes have the code

do{                                   

wait(S);

<c.s>

signal(s);

<r.s>}while(1);

the code for the n-th process i.e Pn is given by

do{                                   

signal(S);

<c.s>

wait(S);

<r.s>}while(1);

a) What is the max no. of processes that can be there in the critical section simultaneosly ?
A. 2

B . 3

C. n-1

D. n

2 Answers

0 0 votes
total three process can enter in critical section .consider p1 enter in CS and get preempted after nth process came and signal it now both of them in critical section now s=1 again p2 will came enter in CS in which P1 is already there so total  number of process $P_{1}$+$P_{2}$+$P_{N}$=3 so answer will be 3.
0 0 votes
P1 executes its code and due to wait() monitor it got suspended and then Pn execute its code and signal() P1 and enter in critical section and now P1 also enter in critical section hence 2 processes are there in critical section at any point of time.
Position:
Show:

Related questions

0 0 votes
1 1 answer
579
579 views
0 0 votes
1 1 answer
849
849 views
N3314nch41 asked Sep 10, 2023
849 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??
0 0 votes
0 0 answers
1.1k
1.1k views
Nirmal Gaur asked Dec 19, 2018
1,097 views
Does Progress implies freedom from Deadlock?
2 2 votes
2 answers 2 answers
1.3k
1.3k views
Kalpataru Bose asked Nov 27, 2017
1,277 views
If there are n processes executing concurrently using binary semaphore S , (n-1) processes have the code do{ wait(S); <c.s signal(s); <r.s }while(1);the code for the n-th...