1,293 views
5 votes
5 votes

My question is little different.

Each Process Pi, i = 1....9 is coded as follows

repeat
    P(mutex)
    {Critical section}
    V(mutex)
forever

The code for P10 is identical except it uses V(mutex) in place of P(mutex). What is the largest number of processes that can be inside the critical section at any moment?

If instead of mutex a semaphore would have been used, then was it possible that p1, p2 , p3 or any other process instead of process p10 could have opted out while all are in the critical section.?
My doubt started from the following note which I read from a source:
"Mutex can be released only by thread that had acquired it, while you can signal semaphore from any other thread (or process), so semaphores are more suitable for some synchronization problems like producer-consumer."

1 Answer

1 votes
1 votes

Answer is D 
If
initial value is 1//execute P1 or P10 first  
If
initial value is 0, P_10 can execute and make the value 1. 
since
the both code (ie p1 to p9 and p10)can be executed any number of times and code for p10 is 
 

repeat
{
    v(mutex)
    C.S.
    V(mutex)
}
forever 

now let me say P1 is in c.s  
then p10 comes executes the CS(
up on mutex) 
now P2 comes (down on mutex) 
now P10 moves out of CS (again binary semaphore will be 1 ) 
now P3 comes (down on mutex) 
now P10 come (
up on mutex) 
now P4 comes (down on mutex)  
so if we take p10 in out of CS recursively all 10 process can be in CS at same time 
using Binary semaphore only

Related questions

1.3k
views
1 answers
3 votes
Abhisek Tiwari 4 asked Oct 20, 2018
1,251 views
What is S1,S2?and how to to decide their scope for variable access? Procedure A; x,y:intger; Procedure B; x,z:real S1 end B; Procedure C; i:integer; S2 end C; end A;The ... , z and y in S1 and x of A, i and y in S2(D) None of the above
1.1k
views
0 answers
0 votes
amitqy asked Nov 21, 2018
1,070 views
1.7k
views
1 answers
2 votes
Akash Kumar Roy asked Mar 30, 2018
1,682 views
Can a process be preempted while it is in a critical section?If yes, then how does the critical section or synchronisation mechanism concept provide solution ... sir has used context switch. How preemption is different from context switch?
450
views
0 answers
0 votes
jatinmittal199510 asked Jan 15, 2017
450 views
Does Mutex provide Bounded Waiting solution ? (since it can lead to deadlock state, and I studied somewhere that if there is deadlock then we cannot assure Bounded Waiting and somewhere I read Mutex provides Bounded Waiting solution).