359 views
5 5 votes

Two processes, $A$ and $B$, share a counting semaphore $\verb|S|$ initialized to $2$. Each process executes the following code segment exactly once:

wait(S);
/* Critical Section */
signal(S);


Which of the following statements is/are TRUE?

  1. The maximum number of processes that can be in the critical section simultaneously is $2$.
     
  2. If the initial value of $\verb|S|$ was $0$, a deadlock would occur if both processes attempted to enter.
     
  3. A binary semaphore would yield the same synchronization behavior as this counting semaphore.
     
  4. The $\verb|wait|$ operation on a counting semaphore always decrements the value, even if it is already $0$.

1 Answer

2 2 votes

A) TRUE: A counting semaphore initialized to $n$ allows $n$ processes into the CS. Here, $n=2$.

B) TRUE: If $\verb|S = 0|$, the first process to call $\verb|wait(S)|$ will block. If both call it, both block, leading to a deadlock.

C) FALSE: A binary semaphore only allows $1$ process $(0$ or $1)$. A counting semaphore with $S=2$ allows $2$ processes.

D) FALSE: If $S=0$, the $\verb|wait|$ operation typically blocks the process and puts it in a queue; it does not necessarily decrement the integer below zero in all implementations , though in some definitions it becomes negative to indicate the number of blocked processes. However, in the standard "Test and Set" logic, it stops at $0$.

Answer:
Position:
Show:

Related questions

7 7 votes
1 1 answer
535
535 views
GO Classes asked Feb 28
535 views
Consider a system employing demand paging. The system's performance is being analyzed under heavy load, and it is observed that the CPU utilization is very low while the ...
4 4 votes
1 1 answer
423
423 views
GO Classes asked Feb 28
423 views
A computer system uses $46$-bit virtual addresses and $32$-bit physical addresses with a page size of $8\mathrm{~KB}$. If the system employs a $\mathbf{3}$-level hierarch...
3 3 votes
2 2 answers
358
358 views
GO Classes asked Feb 28
358 views
A system has $4$ processes $(P_1$ to $P_4)$ and $10$ instances of a single resource type $R$. Each process requires a maximum of $m$ instances to complete. What is the MA...
6 6 votes
2 2 answers
485
485 views
GO Classes asked Feb 28
485 views
Consider a uniprocessor system with three processes $\mathrm{P1, P2,}$ and $\mathrm{P3}$ arriving at time $\mathrm{t}=0$. Their burst times are $10,20 ,$ and $30$ units, ...