# Process Synchronization

 Question 1
Consider the following threads, $T_1, T_2, \text{ and }T_3$ executing on a single processor, synchronized using three binary semaphore variables, $S_1, S_2, \text{ and }S_3$, operated upon using standard $wait()$ and $signal()$. The threads can be context switched in any order and at any time.

Which initialization of the semaphores would print the sequence BCABCABCA ...?
 A $S_1 = 1; S_2 = 1; S_3 = 1$ B $S_1 = 1; S_2 = 1; S_3 = 0$ C $S_1 = 1; S_2 = 0; S_3 = 0$ D $S_1 = 0; S_2 = 1; S_3 = 1$
GATE CSE 2022   Operating System
Question 1 Explanation:
 Question 2
Consider a computer system with multiple shared resource types, with one instance per resource type. Each instance can be owned by only one process at a time. Owning and freeing of resources are done by holding a global lock (L). The following scheme is used to own a resource instance:
 function OWNRESOURCE(Resource R)
Acquire lock L // a global lock
if R is available then
Acquire R
Release lock L
else
if R is owned by another process P then
Terminate P, after releasing all resources owned by P
Acquire R
Restart P
Release lock L
end if
end if
end function
Which of the following choice(s) about the above scheme is/are correct?
[MSQ]
 A The scheme ensures that deadlocks will not occur B The scheme may lead to live-lock C The scheme may lead to starvation D The scheme violates the mutual exclusion property
GATE CSE 2021 SET-2   Operating System
Question 2 Explanation:
 Question 3
Consider the following pseudocode, where Sis a semaphore initialized to 5 in line #2 and counter is a shared variable initialized to 0 in line #1. Assume that the increment operation in line #7 is not atomic.
1.  int counter =0;
2.  Semaphore S= init(5);
3.  void parop(void)
4.  {
5.         wait(S);
6.         wait(S);
7.         counter++;
8.         signal(S);
9.          signal(S);
10.  } 
If five threads execute the function $parop$ concurrently, which of the following program behavior(s) is/are possible?
[MSQ]
 A The value of countercounter is 5 after all the threads successfully complete the execution of parop. B The value of countercounter is 1 after all the threads successfully complete the execution of parop. C The value of countercounter is 0 after all the threads successfully complete the execution of parop. D There is a deadlock involving all the threads.
GATE CSE 2021 SET-1   Operating System
Question 3 Explanation:
 Question 4
Remote Procedure Calls are used for
 A communication between two processes remotely different from each other on the same system B communication between two processes on the same system C communication between two processes on the separate systems D none of the above
ISRO CSE 2020   Operating System
Question 4 Explanation:
NOTE: Question is excluded from the evaluation due to ambiguity.
 Question 5
The hardware implementation which provides mutual exclusion is
 A Semaphores B Test and set instructions C Both options D None of the options
ISRO CSE 2020   Operating System
Question 5 Explanation:
 Question 6
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 count is a shared variable initialized to 0 and not used in CODE SECTION P.

What does the code achieve?
 A It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P. B It ensures that two processes are in CODE SECTION Q at any time. C It ensures that all processes execute CODE SECTION P mutually exclusively. D It ensures that at most n-1 processes are in CODE SECTION P at any time.
GATE CSE 2020   Operating System
Question 6 Explanation:
 Question 7
Consider three concurrent processes P1, P2 and P3 as shown below, which access a shared variable D that has been initialized to 100.

The process are executed on a uniprocessor system running a time-shared operating system. If the minimum and maximum possible values of D after the three processes have completed execution are X and Y respectively, then the value of Y-X is __________.
 A 50 B 80 C 100 D 130
GATE CSE 2019   Operating System
Question 7 Explanation:
 Question 8
In multi-programmed systems, it is advantageous if some programs such as editors and compilers can be shared by several users.
Which of the following must be true of multi-programmed systems in order that a single copy of a program can be shared by several users?

I. The program is a macro
II. The program is recursive
III. The program is reentrant
 A I only B II only C III only D I, II and III
ISRO CSE 2018   Operating System
Question 8 Explanation:
 Question 9
Procedures P1 and P2 have a producer-consumer relationship, communicating by the use of a set of shared buffers.

P1 :
repeat
Obtain an empty buffer
Fill it
Return a full buffer
forever

P2:
repeat
Obtain a full buffer
Empty it
Return an empty buffer
forever

Increasing the number of buffers is likely to do which of the following?

I. Increase the rate at which requests are satisfied (throughput)
II. Decrease the likelihood of deadlock
III. Increase the ease of achieving a correct implementation
 A III only B II only C I only D II and III only
ISRO CSE 2018   Operating System
Question 9 Explanation:
 Question 10
Consider the following solution to the producer-consumer synchronization problem. The shared buffer size is N. Three semaphores empty, full and mutex are defined with respective initial values of 0, N and 1. Semaphore empty denotes the number of available slots in the buffer, for the consumer to read from. Semaphore full denotes the number of available slots in the buffer, for the producer to write to. The placeholder variables, denoted by P, Q, R, and S, in the code below can be assigned either empty or full. The valid semaphore operations are: wait() and signal().

Which one of the following assignments to P, Q, R and S will yield the correct solution?
 A P: full, Q: full, R: empty, S: empty B P: empty, Q: empty, R: full, S: full C P: full, Q: empty, R: empty, S: full D P: empty, Q: full, R: full, S: empty
GATE CSE 2018   Operating System
Question 10 Explanation:
There are 10 questions to complete.

### 4 thoughts on “Process Synchronization”

1. Sir, Please update the option i and ii of question number 52, both option are same written here.