synchronization
GATE CSE & IT · Synchronization · 1990-2023
Study anchor
Galvin — Operating System Concepts
Processes, scheduling, memory, files, deadlocks
Practice action
Start latest PYQPYQs in this concept
All concepts →Consider the two functions incr and decr shown below. incr() { wait(s); X = X+1; signal(s); } decr() { wait(s); X = X-1; signal(s); } There are 5 threads each invoking incr once, a...
Consider the following threads, T 1 , T 2 and T 3 executing on a single processor, synchronized using three binary semaphore variables, S 1 , S 2 and S 3 , operated upon using stan...
Consider a non-negative counting semaphore $$S.$$ The operation $$P(S)$$ decrements $$S,$$ and $$V(S)$$ increments $$S.$$ During an execution, $$20$$ $$P(S)$$ operations and $$12$$...
Consider the procedure below for the Producer-Consumer problem which uses semaphores: semaphore n = 0; semaphore s = 1; void producer() { while(true) { produce(); semWait(s); addTo...
Three concurrent processes X, Y, and Z execute three different code segments that access and update certain shared variables. Process X executes the P operation (i.e., wait) on sem...
Fetch_And_Add (X, i) is an atomic Read-Modify-Write instruction that reads the value of memory location X, increments it by the value i, and returns the old value of X. It is used...
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-and-set(X)...
The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows: P(s): s = s-1; if s < 0 then wait; V(s) : s = s-1; ifs <= 0 then wakeup a pr...
Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes: /* P1 */ while(true){ want s1=true; whi...
Barrier is a synchronization construct where a set of processes synchronizes globally i.e. each process in the set arrives at the barrier and waits for all others to arrive and the...
In serial data transmission, every byte of data is padded with a $$‘0’$$ in the beginning and one or two $$‘1’s$$ at the end of byte because
Consider Peterson’s algorithm for mutual exclusion between two concurrent processes i and j. The program executed by process is shown below. Repeat flag[i]=true; turn=j; while (P)...
Let m[0] ..m[4] be mutexes (binary semaphores) and P[0] ...P[4] be processes. Suppose each process P[i] executes the following: wait (m[i]); wait (m(m[(i+1) mod 4]))0; ....... rele...
A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore
When the result of a computation depends on the speed of the processes involved there is said to be
Each process P i ,i=1.....9 is coded as follows Repeat P(mutex){ critical section } V(mutex) Forever The code for P 10 is identical except that it uses V(mutex) in place of P(mutex...
A solution to the Dining Philosophers Problem which avoids deadlock is
A critical section is a program segment
Start and stop bits do not contain 'information' but these are used in serial communication for
At a particular time of computation the value of a counting semaphore is 7. Then 20 P operations and 15 V operations were completed on this semaphore. The resulting value of the se...
State whether the following statement TRUE or FALSE. The use of monitors ensures that no dead -locks will be caused.
State whether the following statement TRUE or FALSE. Any implementation of a critical section requires the use of an indivisible machine instruction such as test-and-set.
Semaphore operations are atomic because they are implemented within the OS