GATE|| IPC, Concurrency and Synchronization , Deadlock || Pyq (2005 to2026)

Last Updated :
Discuss
Comments

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.

Take a part in the ongoing discussion