Process Synchronization


Q21.

Semaphores are used to solve the problem ofI. Race ConditionII. Process SynchronizationIII. Mutual ExclusionIV. None of the above
GateOverflow

Q22.

Consider the procedure below for the Producer-Consumer problem which uses semaphores: Which one of the following is TRUE?
GateOverflow

Q23.

The following two functions P1 and P2 that share a variable B with an initial value of 2 execute concurrently. The number of distinct values that B can possibly take after the execution is______________.
GateOverflow

Q24.

A critical section is a program segment
GateOverflow

Q25.

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; if (s <= 0) then wakeup a process waiting on s; Assume that P_{b} and V_{b} the wait and signal operations on binary semaphores are provided. Two binary semaphores x_{b} and y_{b} are used to implement the semaphore operations P(s) and V(s) as follows: P(s) : Pb(xb); s = s - 1; if (s < 0) { Vb(xb) ; Pb(Yb) ; } else Vb(xb); V(s) : Pb(xb) ; s = s + 1; if (s <= 0) Vb(Yb) ; Vb(xb) ; The initial values of xb and yb are respectively
GateOverflow

Q26.

The following is a code with two threads, producer and consumer, that can run in parallel. Further, S and Q are binary semaphores quipped with the standard P and V operations. semaphore S = 1, Q = 0; integer x; producer: consumer: while (true) do while (true) do P(S); P(Q); x = produce (); consume (x); V(Q); V(S); done done Which of the following is TRUE about the program above?
GateOverflow

Q27.

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) ; } void leave_CS(x) { x=0; } In the above solution, x is a memory location associated with the CS and is nitialized to 0. Now consider the following statements: I. The above solution to CS problem is deadlock-free II. The solution is starvation free. III. The processes enter CS in FIFO order. IV More than one process can enter CS at the same time. Which of the above statements is TRUE?
GateOverflow

Q28.

A shared variable x, initialized to zero, is operated on by four concurrent processes W, X, Y, Z as follows. Each of the processes W and X reads x from memory, increments by one, stores it to memory, and then terminates. Each of the processes Y and Z reads x from memory, decrements by two, stores it to memory, and then terminates. Each process before reading x invokes the P operation (i.e., wait) on a counting semaphore S and invokes the V operation (i.e., signal) on the semaphore S after storing x to memory. Semaphore S is initialized to two. What is the maximum possible value of x after all processes complete execution?
GateOverflow

Q29.

A certain computation generates two arrays a and b such that a[i]=f(i)for o\leq i \lt n and b[i] = g (a[i] )for o\leq i \lt n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below. Which one of the following represents the CORRECT implementations of ExitX and EntryY?
GateOverflow

Q30.

Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values of shared boolean variables S1 and S2 are randomly assigned. Which one of the following statements describes the properties achieved?
GateOverflow