search
Log In

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
asked Feb 18 in Operating System Arjun 690 views
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.
asked Feb 12, 2020 in Operating System Arjun 4.7k views
4 votes
3 answers
4
The hardware implementation which provides mutual exclusion is Semaphores Test and set instructions Both options None of the options
asked Jan 13, 2020 in Operating System Satbir 1.7k views
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.
asked Oct 30, 2019 in Operating System Lakshman Patel RJIT 163 views
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.)$
asked Oct 25, 2019 in Operating System Lakshman Patel RJIT 86 views
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.
asked Oct 25, 2019 in Operating System Lakshman Patel RJIT 184 views
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.
asked Oct 25, 2019 in Operating System Lakshman Patel RJIT 199 views
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.)
asked Oct 25, 2019 in Operating System Lakshman Patel RJIT 140 views
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.
asked Oct 25, 2019 in Operating System Lakshman Patel RJIT 47 views
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
asked May 26, 2019 in Operating System Bhaskar Singh 445 views
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?
asked May 5, 2019 in Operating System vinay chauhan 280 views
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
asked May 4, 2019 in Operating System Hirak 382 views
4 votes
1 answer
20
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?
asked Jan 6, 2019 in Operating System syncronizing 776 views
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
asked Dec 12, 2018 in Operating System Rahul_Rathod_ 641 views
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$
asked Dec 7, 2018 in Operating System Arjun 381 views
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
asked Nov 22, 2018 in Operating System Pavan Shetty 276 views
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[2]; /* 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);
asked Nov 17, 2018 in Operating System Chetan Warke 405 views
0 votes
1 answer
27
...