Question 1
A multithreaded program P executes with x number of threads and used y number of locks for ensuring mutual exclusion while operating on shared memory locations. All locks in the program are non-reentrant, i.e., if a thread holds a lock l, then it cannot re-acquire lock l without releasing it. If a thread is unable to acquire a lock, it blocks until the lock becomes available. The minimum value of x and the minimum value of y together for which execution of P can result in a deadlock are:
GATE CSE 2017, Set 1 - [2Marks] (MCQ)
x = 1, y = 2
x = 2, y = 1
x = 2, y = 2
x = 1, y = 1
Question 2
With respect to deadlocks in an operating system, which of the following statements is/are false?
GATE CSE 2026 , SET1 - (MSQ)
An assignment edge in a resource allocation graph is marked from a process to a resource.
A safe state guarantees that all processes can finish without the formation of a deadlock.
Deadlock formation can be prevented by ensuring that the hold-and-wait condition is not allowed.
Banker's algorithm is used to prevent deadlock.
Question 3
A system has 5 processes and k instances of a resource R.
Assume each process requires a maximum of 2 instances of R. A process can request or release only one instance at a time. Further, a process can request the second instance of R only after acquiring the first instance.
The minimum possible value of k required to ensure a deadlock-free environment is ____.
GATE CSE 2026,SET1 - (NAT)
6
Question 4
π = {π1, π2, π3, π4} consists of all active processes in an operating system. π = {π 1, π 2, π 3, π 4} consists of single instances of distinct types of resources in the system.
The resource allocation graph has the following assignment and claim edges.
Assignment edges: π 1 β π1, π 2 β π2, π 3 β π3, π 4 β π4 (the assignment edge π 1 β π1 means resource π 1 is assigned to process π1 , and so on for others)
Claim edges: π1 β π 2, π2 β π 3, π3 β π 1, π2 β π 4, π4 β π 2 (the claim edge π1 β π 2 means process π1 is waiting for resource π 2 , and so on for others)
Which of the following statement(s) is/are CORRECT?
GATE 2025 CS2 - 2Marks (MSQ)
Aborting π1 makes the system deadlock free.
Aborting π3 makes the system deadlock free
Aborting π2 makes the system deadlock free
Aborting π1 and π4 makes the system deadlock free.
Question 5
Which of the following statements is/are TRUE with respect to deadlocks?
GATE CSE 2022 - [1Marks] (MSQ)
The circular wait is a necessary condition for the formation of deadlock
In a system where each resource has more than one instance, a cycle in its wait-for graph indicates the presence of a deadlock.
If the current allocation of resources to processes leads the system to an unsafe state, then deadlock will necessarily occur.
In the resource-allocation graph of a system, if every edge is an assignment edge, then the system is not in a deadlock state.
Question 6
Consider the two functions incr and decr shown below.
incr(){ decr(){
wait(s); wait(s);
X = X+1; X = X-1;
signal(s); signal(s);
} }There are 5 threads each invoking incr once, and 3 threads each invoking decor 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, and V2 be the values of X at the end of the execution of all the threads with implementations I-1, and y
I-2, respectively.
Which one of the following choices corresponds to the minimum possible values of V1, V2, respectively? GATE CSE 2023, Set 1 - 2Marks (MCQ)
15,7
7,7
12,7
12,8
Question 7
Which one or more of the following options guarantees that a computer system will transition from user mode to kernel mode?
GATE CSE 2023, Set 1 - 1Marks (MSQ)
Function call
malloc call
Page Fault
System call
Question 8
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 if
end function
Which of the following choice(s) about the above scheme is/are correct?
GATE CSE 2021,SET2 - [2Marks] (MSQ)
The scheme violates the mutual exclusion property.
The scheme ensures that deadlocks will not occur.
The scheme may lead to starvation.
The scheme may lead to live-lock.
Question 9
Consider the following pseudocode, where S is 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?
GATE CSE 2021,SET1 - [2Marks] (MSQ)
The value of counter is 0 after all the threads successfully complete the execution of parop.
The value of counter is 1 after all the threads successfully complete execution of parop.
The value of counter is 5 after all the threads successfully complete the execution of parop.
There is a deadlock involving all the threads.
Question 10
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.
CODE SECTION P
wait (a); count = count+1;
if (count==n) signal (b);
signal (a); wait (b); signal (b);
CODE SECTION Q
What does the code achieve?
It ensures that all processes execute CODE SECTION P mutually exclusively.
It ensures that at most two processes are in CODE SECTION Q at any time.
It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P.
It ensures that at most n-1 processes are in CODE SECTION P at any time.
There are 31 questions to complete.