Recent questions tagged semaphore

2 2 votes
1 1 answer
161
161 views
Consider an integer semaphore $\texttt{S}$.Method $\textbf{1}$wait(S): disable interrupts while S <= 0: do nothing S = S - 1 enable interrupts signal(S): disable interrup...
3 3 votes
1 1 answer
181
181 views
A bounded buffer has capacity $6$ and is initially empty.The semaphore values are initially:$\texttt{empty} = 6$$\texttt{full} = 0$$\texttt{mutex} = 1$During execution:$9...
5 5 votes
2 2 answers
160
160 views
A bounded buffer has capacity $5$ and is initially empty.During an execution:$8$ producer insertions complete. $5$ consumer removals complete.Assume no insertion or remov...
3 3 votes
1 1 answer
128
128 views
A producer-consumer system uses a buffer containing $N$ slots.The semaphores are:$\texttt{empty}$, representing empty slots $\texttt{full}$, representing filled slots $\t...
3 3 votes
2 2 answers
145
145 views
Which of the following statements are correct?Semaphore $\texttt{wait()}$ and $\texttt{signal()}$ operations must be atomic. A counting semaphore can represent the number...
4 4 votes
3 3 answers
180
180 views
A semaphore $S$ is initialized to $1$.The following operations occur in order:$\texttt{wait(S)}$$\texttt{wait(S)}$$\texttt{signal(S)}$$\texttt{wait(S)}$$\texttt{signal(S)...
4 4 votes
2 2 answers
146
146 views
Two concurrent processes execute:Process A$A_1$$A_2$$A_3$$A_4$Process B$B_1$$B_2$$B_3$$B_4$A semaphore $S$ is initialized to $0$.The requirement is that $A_2$ must comple...
21 21 votes
5 5 answers
2.9k
2.9k views
Consider three processes $\text{P1, P2}$, and $\text{P3}$ running identical code, as shown in the pseudocode below. $\text{A}$ and $\text{B}$ are two binary semaphores in...
0 0 votes
0 0 answers
286
286 views
The enter_CS() and leave_CS() functions to implement critical section of a process are realized using test-and-set instruction as follows:void enter_CS(x) { while (test-a...
0 0 votes
0 0 answers
486
486 views
Identify the correct statement(s) from the followings with respect to Spinlock SemaphoresThe name refers to busy waiting semaphores.They are not useful when the locks are...
0 0 votes
1 1 answer
473
473 views
What is the value of n after 10 concurrent threads terminate, where initially value of counting semaphore s = 2 and n=0?Thread Tk:int x;wait(s);x = n;n = x + 1;signal(s);...
0 0 votes
1 1 answer
368
368 views
Consider the following three threads and four semaphores.$s 1, s 2, s 3, s 4$ are counting semaphores and $x$ is a shared variable initialized as $1.$The goal is to initi...
2 2 votes
1 1 answer
275
275 views
Consider the following three threads and four semaphores.$s 1, s 2, s 3, s 4$ are counting semaphores and $x$ is a shared variable initialized as $1.$The goal is to initi...
1 1 vote
0 0 answers
728
728 views
Rather than the solution, my question is how do we approach these kind of questions? Do we always consider the case where two processes execute at the same speed(like 1 l...
0 0 votes
2 2 answers
321
321 views
can someone please explain the exact difference between binary semaphores and mutex?not able to find any simple explanation.
2 2 votes
0 0 answers
575
575 views
Consider a counting semaphore s1 initialized to two. The binary semaphore s2 is initialized to one. There are three processes executing the following code segment concurr...
0 0 votes
1 1 answer
407
407 views
Let $P_{1}, P_{2}, \ldots, P_{20}$ be a set of 20 cooperating processes, all of which have access to a shared integer X. For $i \in\{1,2, \ldots, 20\}$, the process $P_{i...
0 0 votes
1 answers 1 answer
1.0k
1.0k views
Can a counting semaphore acquire a negative value?S = 2;15 P operations done, should the semaphore be 0 or -13