Process Synchronization


Question 1
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, and 3 threads each invoking decr once, on the same shared variable X. The initial value of X is 10.
Suppose there are two implementations of the semaphore s, as follows:

I-1: s is a binary semaphore initialized to 1.
I-2: s is a counting semaphore initialized to 2.

Let V1, V2 be the values of X at the end of execution of all the threads with implementations I-1, I-2, respectively.
Which one of the following choices corresponds to the minimum possible values of V1, V2, respectively?
A
15, 7
B
7, 7
C
12, 7
D
12, 8
GATE CSE 2023   Operating System
Question 2
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 3
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 4
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 5
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 5 Explanation: 
NOTE: Question is excluded from the evaluation due to ambiguity.
Click here for detail solution by gateoverflow




There are 5 questions to complete.

6 thoughts on “Process Synchronization”

  1. Sir, please update the question 45. The question has to be never contains a substring of the form, it was written as always leads to the substring.

    Reply

Leave a Comment