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?The maximum number of processes that can be in the critical section simultaneously is $2$. If the initial value of $\verb|S|$ was $0$, a deadlock would occur if both processes attempted to enter. A binary semaphore would yield the same synchronization behavior as this counting semaphore. The $\verb|wait|$ operation on a counting semaphore always decrements the value, even if it is already $0$. Operating System goclasses operating-system goclasses-cs-dpp goclasses-cs-dpp-day-208 goclasses-os-practice-questions multiple-selects + – GO Classes 359 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
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$. GO Classes answered Feb 28 GO Classes comment Share Follow See all 2 Comments 2 2 Comments reply ayushojha0207 commented May 1 reply Follow flag How is blocking Same as being in deadlock ? 0 0 replyShare Aambo04 commented Jun 25 reply Follow flag @ayushojha0207 In the above program, blocking all processes when no one is in the critical section leads to deadlock(when S=0, option B). 0 0 replyShare Please log in or register to add a comment.