Answer:
Check the explanation
Step-by-step explanation:
Given data:
INFORMATION THAT WE HAVE:
Number of Process:15
Binary Semaphore X=1
wait(X): It decrease X value by 1
wait operation can only be done when X>0
Signal(X): It increase X value by 1
Signal operation can be done when X<1
11 process use:(P1-P11)
wait(X)
CS
signal(X)
4 processes use:(P12-P15)
signal(X)
CS
signal(X)
We can conclude that:
As it is binary semaphore,it value can only be 1 or 0.
Process can enter into CS by making X=0 and after completion of CS task makes X=1.
In case of 11 processes,at a time only 1 process can enter into CS.
Let's say process P9 enter into CS by changing X=0.
A,first instruction of P12 is signal(X) then it can also enter into CS by changing X=1.As signal operation can be performed when X=0 but wait operation cannot be performed.
So,now in CS there is two process: P9 and P12
First instruction of P13 is also signal(X).If it is going to try make X++ it can not do because it is binary semaphore and already X=1
P9 cannot also do signal operation.So it's kind of deadlock.
a)
In critical section,at the same time at most 2 processes can be present.
And now we consider that this is Counting semaphore
So,We can conclude that:
Counting Semaphore X=1
wait(X): It decrease X value by 1
wait operation can only be done when X>0
Signal(X): It increase X value by 1
Signal operation can be done at any value of X
Let's say process P1 enter into CS by changing X=0.
A,first instruction of P12 is signal(X) then it can also enter into CS by changing X=1.As signal operation can be performed when X>=0 but wait operation cannot be performed.
P13 can also enter by changing X=2 [ First operation is signal(X) ]
P14 can also enter by changing X=3 [ First operation is signal(X) ]
P15 can also enter by changing X=4 [ First operation is signal(X) ]
In the question , every process can execute critical section only once is mentioned
P2 can enter by changing X=3 [First operation is wait(X) ]
P3 can enter by changing X=2 [First operation is wait(X) ]
P4 can enter by changing X=1 [First operation is wait(X) ]
P5 can enter by changing X=0 [First operation is wait(X) ]
So,now available process in CS :(P1,P2,P3,P4,P5,P12,P13,P14,P15)
B)
In serious section, at the same time when nine processes can be present at most, that is if every process can execute CS only once.
* in case there is no situation whereby every process can execute CS only once then at a time at most all the processes can be present.