15,634 views
51 votes
51 votes
Consider a non-negative counting semaphore $S$. The operation $P(S)$ decrements $S$, and $V(S)$ increments $S$. During an execution, $20$ $P(S)$ operations and $12$ $V(S)$ operations are issued in some order. The largest initial value of $S$ for which at least one $P(S)$ operation will remain blocked is _______

10 Answers

Best answer
34 votes
34 votes
Answer: $(7)$. Take any sequence of $20P$ and $12V$ operations, atleast one process will always remain blocked.
edited by
9 votes
9 votes

If we get negative value then it must be in blocked state,

Nowwe have minimum -ve nummber is -1.

So, our equation will be S-20+12=-1 

So, S>7 for procees to be run successfully without blocked state!

6 votes
6 votes

Let us take a smaller example where P(S) = 5 and V(S) = 2, Now we need 2 more so that atleast one process will be blocked.So we can formulaize it as

Largest initial value of S so that atleast one get blocked = P(S) - V(S) = 1 + x and value of x is our answer.

here P(S) = 20 , V(S) = 12 

thus 20 - 12 = 1 + x

x=7 is answer

Answer:

Related questions

50 votes
50 votes
4 answers
3
Akash Kanase asked Feb 12, 2016
17,629 views
The width of the physical address on a machine is $40$ bits. The width of the tag field in a $512$ KB $8$-way set associative cache is ________ bits.
56 votes
56 votes
1 answer
4
Akash Kanase asked Feb 12, 2016
11,008 views
Consider the following database table named water_schemes:$$\overset{\text{Water_schemes}}{\begin{array}{|c|c|c|}\hline\textbf{scheme_no}& \textbf{district_name}& \te...