Query on Concurrency,Synchronization


#1

At a Particular time,the value of a counting semaphore is 10.It will become 7 after
a)3 V operations
b)3 P operations
c)5 V operations and 2 P operations
d)13 P operations and 10 V operations


#2

I think it is both B and D since for V it will be increased by 1 and for P it will be decreased by 1.


#3

What i think is there B option is only correct , and they show that in official answer key too …

now why option B , that is because of P, It is used when some process enter into the critical section

so when counting semaphore is 10, after enter into it’s CS , the counting semaphore value become 7 after 3 P operations.

But , it can not be START with V, as V is only used when some process exit into the critical section

so a process have to enter into it’s critical section first , not to exit first .

Now, you can think if the process is middle of it’s critical section then it exit first means perform V , then again enter into it’s CS means perform P . But this is not the general scenario .

Hence only B is the correct option


#4

According to Me … Answer should be B ( 3 P operations) ,As process will be -1 with every wait condition, after semaphore. So it will be 7 after 3 P operations.

In wait condition it is S = S-1 in P operation
In Signal condition S S+1 in V operations .

Thanks,if you like Answer

visit my facebook page for GATE CS/IT 2019,for courses and Lessons