Filter by year

Concurrency questions

Q40

GATE CS 2024 CS-1Concurrency and SynchronizationMCQ2 marks−2/3 if wrong
Consider the following two threads T1 and T2 that update two shared variables a and b. Assume that initially a = b = 1. Though context switching between threads can happen at any time, each statement of T1 or T2 is executed atomically without interruption.
T1:
a = a + 1;
b = b + 1;
T2:
b = 2 * b;
a = 2 * a;
Which one of the following options lists all the possible combinations of values of a and b after both T1 and T2 finish execution?
Show answer without attempting

Answer: A

Q23

GATE CS 2019 CSConcurrency and SynchronizationNAT1 mark
Consider three concurrent processes P1, P2 and P3 as shown below, which access a shared variable D that has been initialized to 100.
P1P2P3
⋮\vdots⋮\vdots⋮\vdots
D=D+20\text{D} = \text{D} + 20D=D−50\text{D} = \text{D} - 50D=D+10\text{D} = \text{D} + 10
⋮\vdots⋮\vdots⋮\vdots
The processes 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−XY - X is __________.
Show answer without attempting

Answer: 80

Q30

GATE CS 2015 CS-1Concurrency and SynchronizationNAT1 mark
The following two functions P1 and P2 that share a variable B with an initial value of 2 execute concurrently.
P1() {
    C = B - 1;
    B = 2 * C;
}

P2() {
    D = 2 * B;
    B = D - 1;
}
The number of distinct values that B can possibly take after the execution is ________.
Show answer without attempting

Answer: 3

0/30 correct0 marks

Related topics in Concurrency and Synchronization