27,541 views
72 72 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 _______

16 Answers

Best answer
42 42 votes
Answer: $(7)$. Take any sequence of $20P$ and $12V$ operations, atleast one process will always remain blocked.
• edited by
17 17 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!

9 9 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

5 5 votes
The largest initial value of SS for which at least one P(S)P(S) operation will remain blocked is ..

"that means largest value of "S" in which one operation is in suspended list

so S=20-12-1=7 in which one operation is in suspended list
4 4 votes
After performing down operation if the process is getting suspended then it is called unsuccessful down operation .The down operation of the counting semaphore is successful if the initial value of semaphore s>=1.For 1 process to be in suspended list after subsequent p and v operations the value should be equal to -1 .So,
S-20+12=-1
So,S=7
Answer:
Position:
Show:

Related questions

37 37 votes
2 answers 2 answers
14.6k
14.6k views
Akash Kanase asked Feb 12, 2016
14,593 views
Consider the following processes, with the arrival time and the length of the CPU burst given in milliseconds. The scheduling algorithm used is preemptive shortest remain...
66 66 votes
10 answers 10 answers
28.7k
28.7k views
Akash Kanase asked Feb 12, 2016
28,662 views
Consider the following two-process synchronization solution.$$\begin{array}{|l|l|}\hline \text{PROCESS 0 } & \text{Process 1 }\\ \\ \text{Entry: loop while (turn == 1...
143 143 votes
15 answers 15 answers
41.6k
41.6k views
Akash Kanase asked Feb 12, 2016
41,622 views
Suppose the functions $F$ and $G$ can be computed in $5$ and $3$ nanoseconds by functional units $U_{F}$ and $U_{G}$, respectively. Given two instances of $U_{F}$ and two...
75 75 votes
8 answers 8 answers
28.4k
28.4k views
Akash Kanase asked Feb 12, 2016
28,409 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.