Deadlock MCQ Quiz in मराठी - Objective Question with Answer for Deadlock - मोफत PDF डाउनलोड करा
Last updated on Mar 9, 2025
Latest Deadlock MCQ Objective Questions
Top Deadlock MCQ Objective Questions
Deadlock Question 1:
Which of the following is not required condition for a deadlock?
Answer (Detailed Solution Below)
Deadlock Question 1 Detailed Solution
Necessary Conditions for Deadlock are as follows
- Mutual exclusion: At least one resource must be held in a non-sharable mode; that is, only one process at a time can use the resource. If another process requests that resource, the requesting process must be delayed until the resource has been released.
- Hold and wait: A process must be holding at least one resource and waiting to acquire additional resources that are currently being held by other processes.
- No preemption: Resources cannot be preempted; that is, a resource can be released only voluntarily by the process holding it, after that process has completed its task.
- Circular wait: A set {P0, P1, ..., Pn} of waiting processes must exist such that P0 is waiting for a resource held by P1, P1 is waiting for a resource held by P2, ..., Pn−1 is waiting for a resource held by Pn, and Pn is waiting for a resource held by P0.
Therefore pre-emptive is not required condition for a deadlock
Deadlock Question 2:
Let each process Pi, i = 1 to 7 executes the following code.
repeat
P(mutex);
CS
V(mutex);
forever
The process P8 executes the following code:
repeat
V(mutex);
CS
V(mutex);
forever
What is the maximum number of processes that can be present in the critical section at any point of time? Given that the initial value of binary semaphore variable “mutex” is 1.Answer (Detailed Solution Below)
Deadlock Question 2 Detailed Solution
Here mutex = 1
first, take Process 1, that is, P1
P(mutex);
CS
V(mutex);
This code will run. mutex = 0 and P1 will move into the critical section.
After this, try to enter the P8 in the critical section, it will run the code :
V(mutex);
CS
V(mutex);
In this case, it will changes mutex into 1, and P8 will enter into the critical section. After this, exit the P8 from the critical section, it will change mutex to 2. Then again enter P8. In this way, it increases the mutex value always.
In this way, if Mutex becomes 8 then all the 8 processes can simultaneously enter the critical section.
So, the maximum number of processes that can be present in the critical section at any point in time = 8.Deadlock Question 3:
An operating system uses the banker's algorithm for deadlock avoidance to manage the allocation of four resources A, B, C, and D. The table given below represents the current system state.
|
Allocation |
Max |
||||||
|
A |
B |
C |
D |
A |
B |
C |
D |
P1 |
1 |
2 |
1 |
0 |
1 |
3 |
1 |
2 |
P2 |
3 |
1 |
2 |
1 |
5 |
3 |
2 |
1 |
P3 |
4 |
2 |
3 |
0 |
7 |
2 |
3 |
4 |
P4 |
0 |
0 |
1 |
5 |
1 |
1 |
3 |
6 |
There are 3 units of type B, 2 units of type D still available. Which of the following sequence is a safe sequence?
Answer (Detailed Solution Below)
Deadlock Question 3 Detailed Solution
Available = {0, 3, 0, 2}
|
Allocation |
Max |
Needed |
|||||||||
|
A |
B |
C |
D |
A |
B |
C |
D |
A |
B |
C |
D |
P1 |
1 |
2 |
1 |
0 |
1 |
3 |
1 |
2 |
0 |
1 |
0 |
2 |
P2 |
3 |
1 |
2 |
1 |
5 |
3 |
2 |
1 |
2 |
2 |
0 |
0 |
P3 |
4 |
2 |
3 |
0 |
7 |
2 |
3 |
4 |
3 |
0 |
0 |
4 |
P4 |
0 |
0 |
1 |
5 |
1 |
1 |
3 |
6 |
1 |
1 |
2 |
1 |
The given system is not in a safe state.
Deadlock Question 4:
Consider a system having 'm' resources of the same type. The resources are shared by 3 processes A, B and C which have peak demands of 3, 4 and 6 respectively. The minimum value of 'm' that ensures that deadlock will never occur is:
Answer (Detailed Solution Below)
Deadlock Question 4 Detailed Solution
Let's consider the peak demand situation of resources (A, B, C)=(3,4,6).
To find the possibility of deadlock (not deadlock-free), we have to find at least one resource allocation which results in a deadlock.
There will be a deadlock in which each process wants a resource for completion of execution.
The resource allocation which results in a deadlock is assigning each process the number of resources equal to one less than peak demand.
Therefore, process A gets 2 resources, B gets 3 resources and C gets 5 resources.
Total number of resources = 2+3+5=10
By having 1 more resource of the same type, the state will be deadlock free.
Therefore, the minimum value of 'm' that ensures that deadlock will never occur is 11.
Deadlock Question 5:
Which of the following is/are true about deadlock recover?
Answer (Detailed Solution Below)
Deadlock Question 5 Detailed Solution
The correct answer is option 1, option 2, and option 4.
Concept:
When a deadlock is found, deadlock recovery takes place. When a deadlock is found, our system stops operating, and when the stalemate is resolved, our system resumes operation.
As a result, after detecting a deadlock, a method/way must be required to recover that impasse in order to restart the system. The procedure is known as deadlock recovery.
- Deadlock recovery through preemption.
- Deadlock recovery through rollback.
- Deadlock recovery through killing processes.
Explanation:
Banker’s algorithm is a deadlock avoidance mechanism, not a recovery mechanism.
- Abort all deadlock processes,
- Abort one process at a time,
- Roll back return to some safe state, and restart process for that state are 3 different recovery mechanisms.
Hence the correct answer is option 1, option 2, and option 4.
Deadlock Question 6:
Given a set of four, two resources with two units, each. The following resources allocation graph exits at a point in time:
The graph indicates:
Answer (Detailed Solution Below)
Deadlock Question 6 Detailed Solution
The allocation and request matrix for the above resource allocation graph is:
|
Allocation resources |
Request resources |
||
R1 |
R2 |
R1 |
R2 |
|
P1 |
0 |
1 |
1 |
0 |
P2 |
1 |
0 |
0 |
0 |
P3 |
1 |
0 |
0 |
1 |
P4 |
0 |
1 |
0 |
0 |
Cycle P1 → R1 → P3 → R2 → P1
Here, available resources are = {0, 0}
So, with this, we can satisfy the need for P2 or P4.
Suppose the need for P2 is satisfied, then P2 will release its resources.
Now avail become = 1 0
The need for P4 or P1 can be satisfied. Suppose P4 release the resources.
New avail = 1, 1
It can satisfy the need of both P1 and P3.
So, P1 need is satisfied, its resources are released.
New avail = 1 2
P3 needs will also be satisfied with this.
So, there is no deadlock in this even with a cycle in the resource-allocation graph.
Deadlock Question 7:
Consider a computer system having R resources of the same type and these resources are shared by 6 processes that have maximum demands of 7, 5, 3, 8, 4, 6 respectively. Then for what minimum values of R, the system will not be in deadlock?
Answer (Detailed Solution Below)
Deadlock Question 7 Detailed Solution
Concept:
Deadlock can occur If any process gets < needed (requested) resource
Max resource per process to be in deadlock = max demand – 1
For 6 process, max resource to be in deadlock = (7 – 1) + (5 – 1) + (3 – 1) + (8 - 1) + (4 - 1) + (6 - 1) =27
For 6 process, min resource not to be in a deadlock: 27 + 1 =28
Tips and Tricks:
\(\sum_i^nP_i\ -\ n +1 =(7+5+3+8+4+6)-6 + 1=28\)
where Pi is the max resource needed by the ith process and n is the total number of process
Deadlock Question 8:
Suppose a system has 12 magnetic tape drives and at time t0, three processes are allotted tape drives out of their as given below:
|
Maximum Needs |
Current Needs |
p0 |
10 |
5 |
p1 |
4 |
2 |
p2 |
9 |
2 |
At time t0, the system is in safe state. Which of the following is safe sequence so that deadlock is avoided?
Answer (Detailed Solution Below)
Deadlock Question 8 Detailed Solution
Data:
Remaining Need = Maximum need – Current need
|
Maximum Needs |
Current needs |
Remaining Needs |
p0 |
10 |
5 |
5 |
p1 |
4 |
2 |
2 |
p2 |
9 |
2 |
7 |
Total resources = 12
Total resources allocated = 5 + 2 + 2 = 9
Available resources = 12 – 9 = 3
Calculation:
Available resource ≥ remaining need of p1
Using 3 resources, p1 gets executed first. It frees 2 resources.
Available resources = 3 + 2 = 5
Available resource ≥ remaining need of p0
Using 5 resources, p0 gets executed first. It frees 5 resources.
Available resources = 5 + 5 = 10
Available resource ≥ remaining need of p2
Now, p2 can be executed easily. Hence, (p1, p0, p2) is a safe sequence.
Deadlock Question 9:
Which of the following is not true with respect to deadlock prevention and deadlock avoidance schemes?
Answer (Detailed Solution Below)
Deadlock Question 9 Detailed Solution
Concepts:
Deadlock prevention can be done by eliminating any of the below condition:
1. Mutual Exclusion
2. Hold and wait
3. No preemption
4. Circular Wait.
In deadlock prevention, the request for resources is not always granted if the resulting state is safe.
Deadlock avoidance can be done with Banker’s Algorithm.
Banker’s Algorithm
Banker’s Algorithm is resource allocation and deadlock avoidance algorithm which test all the request made by processes for resources, it checks for the safe state, if after granting request system remains in the safe state it allows the request and if there is no safe state it doesn’t allow the request made by the process. Deadlock avoidance requires knowledge of resource requirements a priori
Comparison
Deadlock prevention is more restrictive than deadlock avoidance.
Therefore statement 1 is false
Deadlock Question 10:
Which set of necessary conditions causes a ‘deadlock’ in an operating system?
Answer (Detailed Solution Below)
Deadlock Question 10 Detailed Solution
Concept:
It is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other processes, deadlock can arise if the following four conditions hold simultaneously.
→ Mutual exclusion: Only one process can use resources at a time.
→ Hold and Wait: A process is holding at least one resource and waiting for other resources.
→ No Preemption: A process can’t use a resource until it is released by other processes.
→ Circular wait: A set of processes are waiting for each other in a circular manner.