Deadlock · Operating System
23 questions · asked in 17 of 27 years (2000–2026)
MCQ 17 · MSQ 3 · NAT 31-mark 11 · 2-mark 12
2000Questions per year2026
Questions 6–10 of 23
Consider a system with 3 processes that share 4 instances of the same resource type. Each process can request a maximum of K instances. Resource instances can be requested and released only one at a time. The largest value of K that will always avoid deadlock is ____.
Answer: 2
No deadlock can happen if one instance is still free even when each process holds K 1 instances: .
Take K = 3. Then two processes could each hold 2 instances and wait for each other forever.
Answer: 2
Take K = 3. Then two processes could each hold 2 instances and wait for each other forever.
Answer: 2
In a system, there are three types of resources: E, F and G. Four processes execute concurrently. At the outset, the processes have declared their maximum resource requirements using a matrix named Max as given below. For example, Max[,F] is the maximum number of instances of F that 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.
From the perspective of deadlock avoidance, which one of the following is true?
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.
From the perspective of deadlock avoidance, which one of the following is true?
Answer: (A)
Need is found as Max Allocation. This gives P0 (3,3,0), P1 (1,0,2), P2 (0,3,0), P3 (3,4,1). Available is (3,3,0).
- P0 can complete first new available (4,3,1)
- Next P2 (5,3,4)
- Next P1 (6,4,6)
- Last P3 (8,4,6)
A safe sequence exists: P0, P2, P1, P3.
Answer: The system is in safe state
- P0 can complete first new available (4,3,1)
- Next P2 (5,3,4)
- Next P1 (6,4,6)
- Last P3 (8,4,6)
A safe sequence exists: P0, P2, P1, P3.
Answer: The system is in safe state
A multithreaded program P executes with x number of threads and uses 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:
Answer: (D)
The locks are non-reentrant. Suppose one thread already holds lock l and tries to get l again. It blocks and waits for itself, so it never moves on. This means one thread and one lock are enough for a deadlock.
Answer: x = 1, y = 1
Answer: x = 1, y = 1
A system shares 9 tape drives. The current allocation and maximum requirement of tape drives for three processes are shown below:
Which of the following best describes current state of the system ?
Which of the following best describes current state of the system ?
Answer: (B)
Drives already allocated: 3 + 1 + 3 = 7. So 2 drives are free. Drives still needed: P1 needs 4, P2 needs 5, P3 needs 2.
P3 needs 2, so it can finish first the free drives become 5 now P1 can finish the free drives become 8 then P2 can finish. So a safe sequence exists, and no process is stuck at present.
Answer: Safe, Not Deadlocked
P3 needs 2, so it can finish first the free drives become 5 now P1 can finish the free drives become 8 then P2 can finish. So a safe sequence exists, and no process is stuck at present.
Answer: Safe, Not Deadlocked
Consider the following policies for preventing deadlock in a system with mutually exclusive resources.
I. Processes should acquire all their resources at the beginning of execution. If any resource is not available, all resources acquired so far are released
II. The resources are numbered uniquely, and processes are allowed to request for resources only in increasing resource numbers
III. The resources are numbered uniquely, and processes are allowed to request for resources only in decreasing resource numbers
IV. The resources are numbered uniquely. A process is allowed to request only for a resource with resource number larger than its currently held resources
Which of the above policies can be used for preventing deadlock?
I. Processes should acquire all their resources at the beginning of execution. If any resource is not available, all resources acquired so far are released
II. The resources are numbered uniquely, and processes are allowed to request for resources only in increasing resource numbers
III. The resources are numbered uniquely, and processes are allowed to request for resources only in decreasing resource numbers
IV. The resources are numbered uniquely. A process is allowed to request only for a resource with resource number larger than its currently held resources
Which of the above policies can be used for preventing deadlock?
Answer: (D)
Let us look at each policy:
- Policy I breaks hold-and-wait, because a process either gets all its resources or gets none.
- Policies II, III and IV each make requests follow one fixed order (increasing or decreasing). This breaks circular wait.
So all four policies prevent deadlock.
Answer: Any one of I, II, III, and IV
- Policy I breaks hold-and-wait, because a process either gets all its resources or gets none.
- Policies II, III and IV each make requests follow one fixed order (increasing or decreasing). This breaks circular wait.
So all four policies prevent deadlock.
Answer: Any one of I, II, III, and IV
Keep practising