# Recent questions tagged semaphores 1 vote
2 answers
1
Consider the following pseudocode, where $\textsf{S}$ is a semaphore initialized to $5$ in line $\#2$ and $\textsf{counter}$ is a shared variable initialized to $0$ in line $\#1$. Assume that the increment operation in line $\#7$ is $\textit{not}$ ... $0$ after all the threads successfully complete the execution of $\textsf{parop}$ There is a deadlock involving all the threads
1 vote
2 answers
2
There are three processes $P_{1}, P_{2}$ and $P_{3}$ ... $P2$ exits critical section $P1$ exits critical section The final value of semaphore will be : $0$ $1$ $-1$ $-2$
8 votes
4 answers
3
Each of a set of $n$ processes executes the following code using two semaphores $a$ and $b$ initialized to $1$ and $0$, respectively. Assume that $\text{count}$ is a shared variable initialized to $0$ ... ensures that all processes execute CODE SECTION P mutually exclusively. It ensures that at most $n-1$ processes are in CODE SECTION P at any time.
4 votes
3 answers
4
The hardware implementation which provides mutual exclusion is Semaphores Test and set instructions Both options None of the options
0 votes
0 answers
5
A student majoring in anthropology and minoring in computer science has embarked on a research project to see if African baboons can be taught about deadlocks. He locates a deep canyon and fastens a rope across it, so the baboons can cross hand-overhand ... semaphores that avoids deadlock. Do not worry about a series of eastward-moving baboons holding up the westward-moving baboons indefinitely.
0 votes
0 answers
6
The objective of this exercise is to implement a multithreaded solution to find if a given number is a perfect number. $N$ is a perfect number if the sum of all its factors, excluding itself, is $N;$ examples are $6$ and $28$. The input is an integer, $N$ ... report accordingly. $($Note: You can make the computation faster by restricting the numbers searched from $1$ to the square root of $N.)$
0 votes
0 answers
7
Write a producer-consumer problem that uses threads and shares a common buffer. However, do not use semaphores or any other synchronization primitives to guard the shared data structures. Just let each thread access them when it wants to. Use sleep and wakeup to handle the ... number once in a while. Do not print more than one number every minute because the I/O could affect the race conditions.
0 votes
0 answers
8
Suppose that a university wants to show off how politically correct it is by applying the U.S. Supreme Court's Separate but equal is inherently unequal'' doctrine to gender as well as race, ending its long-standing practice ... write the following procedures: woman_wants_to_enter, man_wants_to_enter, woman_leaves, man_leaves. You may use whatever counters and synchronization techniques you like.
0 votes
0 answers
9
Solve the dining philosophers problem using monitors instead of semaphores.
0 votes
0 answers
10
Assume that you have an operating system that provides semaphores. Implement a message system. Write the procedures for sending and receiving messages.
0 votes
1 answer
11
Synchronization within monitors uses condition variables and two special operations, wait and signal. A more general form of synchronization would be to have a single primitive, waituntil, that had an arbitrary Boolean predicate as parameter. Thus, one could say, for example, ... general than that of Hoare or Brinch Hansen, but it is not used. Why not? (Hint: Think about the implementation.)
0 votes
0 answers
12
Can two threads in the same process synchronize using a kernel semaphore if the threads are implemented by the kernel? What if they are implemented in user space? Assume that no threads in any other processes have access to the semaphore. Discuss your answers.
0 votes
1 answer
13
How could an operating system that can disable interrupts implement semaphores?
1 vote
1 answer
14
1 vote
2 answers
15
Why in reader section we are locking(I highlighted the locking) read_count-- and if section? If we don't use locking what problems might arise? I know that we should use locking whenever we access shared variable but in this particular case I don't see any problem if we don't use locking(highlighted). Please explain what I am missing
0 votes
0 answers
16
Galvin, 9th edition on page 146 states that Shared memory can be faster than message passing, since message-passing systems are typically implemented using system calls and thus require the more time-consuming task of kernel intervention. In shared-memory systems, system ... I agree that shared memory is bound to be faster, but aren't the mutex and semaphore calls require Kernel intervention?
1 vote
1 answer
17
a)Mutual exclusion, progress, bounded wait all are satisfied b)Mutual exclusion, progress satisfied but bounded wait not satisfied c)Mutual exclusion satisfied progress, bounded wait not satisfied
1 vote
4 answers
18
1 vote
1 answer
19
Will there be Mutual Exclusion & Deadlock ?
4 votes
1 answer
20
Let S be a binary semaphore variable, S=0 What will be the value of S when following operations are performed:- 2P, 4V, 5P, 2P, 8V, 3P, 2V ?
0 votes
0 answers
21
Consider the following synchronization construct used by the processes P1, P2, and P3. The S1, S2 and S3 are counting semaphore variables: S1 = 3, S2 = 2, S3 = 1; P(S1); P(S2); P(S3); Critical Section V(S3); V(S2); V(S1); Does it satisfy mutual exclusion, progress and bounded waiting?
1 vote
1 answer
22
a) s1-wait(p) , s2-wait(q) , s3-wait(q) , s4-wait(p) b) s1-wait(p) , s2-wait(q) , s3-wait(p) , s4-wait(q) c) s1-wait(q) , s2-wait(p) , s3-wait(p) , s4-wait(q) d) none of above
0 votes
1 answer
23
In a system, counting semaphore was initialized to $10$, then $6P$(wait) operations and $4V$ (signal) operations were completed on this semaphore. So _____ is the final value of the semaphore. $7$ $8$ $13$ $12$
1 vote
1 answer
24
Consider a non-negative counting semaphore S. During an execution, 16P (wait) operations, and 4V (signal) operations are issued in some order. The largest initial value of S for which at least three up operations will remain blocked is ___________ Can someone explain me the solution
0 votes
0 answers
25
I think that statement iii is false , deadlock can arise in both semaphore as well as monitor (mutex)
0 votes
1 answer
26
The first known correct software solution to the critical-section problem for two processes was developed by Dekker. The two processes, P0 and P1, share the following variables: boolean flag; /* initially false */ int turn; The structure of process Pi (i == 0 or 1) is shown in Figure 5. ... [i] = true; } } /* critical section */ turn = j; flag[i] = false; /* remainder section */ } while (true);
0 votes
1 answer
27