reopened by
729 views
2 votes
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
reopened by

2 Answers

0 votes
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 votes
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.

Related questions

0 votes
0 votes
1 answer
1
N3314nch41 asked Sep 10, 2023
361 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 votes
0 votes
0 answers
2
Nirmal Gaur asked Dec 19, 2018
554 views
Does Progress implies freedom from Deadlock?
0 votes
0 votes
1 answer
4
rishi71662data4 asked Nov 16, 2017
612 views
In a given synchronization construct, if there is no deadlock and no strict alternation between two process then is it always true that a process will starve ?