1
GATE CSE 2024 Set 2
MCQ (More than One Correct Answer)
+2
-0

Consider a multi-threaded program with two threads T1 and T2. The threads share two semaphores: s1 (initialized to 1) and s2 (initialized to 0). The threads also share a global variable x (initialized to 0). The threads execute the code shown below.

// code of T1

wait(s1);

x = x + 1;

print(x);

wait(s2);

signal(s1);

// code of T2

wait(s1);

x = x + 1;

print(x);

signal(s2);

signal(s1);

Which of the following outcomes is/are possible when threads T1 and T2 execute concurrently?

A

T1 runs first and prints 1, T2 runs next and prints 2

B

T2 runs first and prints 1, T1 runs next and prints 2

C

T1 runs first and prints 1, T2 does not print anything (deadlock)

D

T2 runs first and prints 1, T1 does not print anything (deadlock)

2
GATE CSE 2021 Set 1
MCQ (More than One Correct Answer)
+2
-0

Consider the following pseudocode, where S is a semaphore intialized to 5 in line#2 an counter is a shared variable intialized 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?

A

There is a deadlock involving all the threads.

B
The value of counter is 5 after all the threads successfully complete the execution of parop.
C
The value of counter is 1 after all the threads successfully complete the execution of parop.
D
The value of counter is 0 after all the threads successfully complete the execution of parop.
3
GATE CSE 2019
MCQ (Single Correct Answer)
+2
-0.67
Consider the following snapshot of a system running $n$ concurrent processes. Process $i$ is holding $X_i$ instances of a resource $\mathrm{R}, 1 \leq i \leq n$. Assume that all instances of R are currently in use. Further, for all $i$, process $i$ can place a request for at most $Y_i$ additional instances of R while holding the $X_i$ instances it already has. Of the $n$ processes, there are exactly two processes $p$ and $q$ such that $Y_p=Y_q=0$. Which one of the following conditions guarantees that no other process apart from $p$ and $q$ can complete execution?
A
$X_p + X_q < \min \{Y_k \mid 1 \leq k \leq n, k \neq p, k \neq q\}$
B
$X_p + X_q < \max \{Y_k \mid 1 \leq k \leq n, k \neq p, k \neq q\}$
C
$\min (X_p, X_q) \geq \min \{Y_k \mid 1 \leq k \leq n, k \neq p, k \neq q\}$
D
$\min (X_p, X_q) = \max \{Y_k \mid 1 \leq k \leq n, k \neq p, k \neq q\}$
4
GATE CSE 2018
MCQ (Single Correct Answer)
+2
-0.6
In a system, there are three types of resources: $$E, F$$ and $$G.$$ Four processes $${P_0},$$ $${P_1},$$ $${P_2}$$ and $${P_3}$$ execute concurrently. At the outset, the processes have declared their maximum resource requirements using a matrix named Max as given below. For example, Max$$\left[ {{P_{2,}}F} \right]$$ is the maximum number of instances of $$F$$ that $${{P_{2,}}}$$ would require. The number of instances of the resources allocated to the various processes at any given state is given by a matrix named Allocation.

Consider a state of the system with the Allocation matrix as shown below, and in which $$3$$ instances of $$E$$ and $$3$$ instances of $$F$$ are the only resources available.

Allocation
E F G
P0 1 0 1
P1 1 1 2
P2 1 0 3
P3 2 0 0

Max
E F G
P0 4 3 1
P1 2 1 4
P2 1 3 3
P3 5 4 1

From the perspective of deadlock avoidance, which one of the following is true?

A
The system is in $$safe$$ state.
B
The system is not in $$safe$$ state, but would be $$safe$$ if one more instance of $$E$$ were available
C
The system is not in $$safe$$ state, but would be $$safe$$ if one more instance of $$F$$ were available
D
The system is not in $$safe$$ state, but would be $$safe$$ if one more instance of $$G$$ were available
GATE CSE Subjects
Software Engineering
Web Technologies
EXAM MAP
Medical
NEETAIIMS
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Civil Services
UPSC Civil Service
Defence
NDA
Staff Selection Commission
SSC CGL Tier I
CBSE
Class 12