This section contains carefully selected MCQs and Previous Year Questions with explanations to help students understand concepts and prepare effectively for examinations, interviews, and competitive tests.
Q: 1Consider a system with 3 processes P0 to P2 and 3 resources types A, B and C. Resource type A has 10 instances, resource type B has 5 instances and resource type C has 7 instances. The following snapshot of the system has been taken at a given time.
| Allocation | Max | Available | |||||||
|---|---|---|---|---|---|---|---|---|---|
| A | B | C | A | B | C | A | B | C | |
| P0 | 0 | 1 | 0 | 7 | 5 | 3 | 5 | 4 | 5 |
| P1 | 2 | 0 | 0 | 3 | 2 | 2 | |||
| P2 | 3 | 0 | 2 | 9 | 0 | 2 | |||
Which of the following is true?
Option C
The Banker’s Algorithm is used in operating systems to avoid deadlock by checking whether the system is in a safe state before allocating resources. A system is said to be in a safe state if there exists a safe sequence of processes such that each process can obtain its required resources, execute, and release the resources without causing deadlock.
To determine this, we calculate the Need matrix using, Need = Max-Allocation and then check whether each process's Need ≤ Available resources.
Compute Need :
Need = Max – Allocation
| Process | Allocation (A B C) | Max (A B C) | Need (A B C) |
|---|---|---|---|
| P0 | 0 1 0 | 7 5 3 | 7 4 3 |
| P1 | 2 0 0 | 3 2 2 | 1 2 2 |
| P2 | 3 0 2 | 9 0 2 | 6 0 0 |
Available = (5, 4, 5)
Thus, a safe sequence exists: P1→P0→P2. Since a safe sequence is found, the system is in a safe state.
Q: 2Which of the following is a scheme for deadlock avoidance?
Option A
Deadlock Avoidance is a method used by an operating system to ensure that a system never enters a deadlock state. In deadlock avoidance, the OS makes decisions dynamically by checking whether allocating a requested resource will keep the system in a safe state.
A safe state means that there is at least one sequence in which all processes can complete their execution without getting stuck waiting for each other. The Banker’s Algorithm is a well-known example of deadlock avoidance that works by finding at least one safe sequence before granting a request.
Q: 3A system has 2 processes and 3 shared identical resources. Each process needs maximum 2 of those resources. Which of the following is TRUE?
Option B
Deadlock happens when processes are waiting for resources in such a way that none of them can proceed. To check whether deadlock is possible, we compare total resources and maximum demand of processes.
Given:
Deadlock can occur only if Total resources < (Processes * (Max Need - 1))
Since total resources are 3, which is greater than 2, the system will always have at least one free resource, allowing a process to complete and release resources.
Once the resources are released, the other process can also complete. Therefore, the situation of circular waiting does not arise, and Deadlock Will Never Occur.
Q: 4Consider the resource allocation graph. “This system is always in deadlock state.” This remark is :

Option B
The given resource allocation graph shows two resources, R₁ and R₂, each having two instances, and four processes, T₁, T₂, T₃, and T₄. In this graph, T₁ is waiting for an instance of R₁, while T₂ and T₃ are already holding instances of R₁. Similarly, T₄ is holding an instance of R₂, and T₁ is requesting it.
Since both resources have multiple instances available, all processes can still be allocated resources without creating a circular wait. Therefore, the system is not always in a deadlock state, and the statement that it is always in deadlock is false.
Q: 5Which one of these is not a condition for Resource Deadlock?
Option C
A Deadlock occurs in an operating system when two or more processes wait indefinitely for resources held by each other. Certain conditions must exist simultaneously for a deadlock to occur. These are known as Coffman Conditions.
The four necessary conditions for deadlock are:
| Deadlock Condition | Description |
|---|---|
| Mutual Exclusion | Only one process can use a resource at a time. |
| Hold-and-Wait | A process holds one resource while waiting for another. |
| No Preemption | Resources cannot be forcibly taken away. |
| Circular Wait | Processes wait for resources in circular form. |
Q: 6Consider a system with ten units of resource R and three processes: X, Y, and Z. The maximum resource requirement and current allocation to these processes are as follows:
| X | Y | Z | |
|---|---|---|---|
| Maximum Resource Requirement | 8 | 7 | 5 |
| Current Allocation | 4 | 1 | 3 |
Now, consider the following resource requests:
(i) X makes a request for 2 resource units
(ii) Y makes a request for 2 resource units
(iii) Z makes a request for 2 resource units
For the system to be in safe state, which of the following must be granted?
Option C
This question is based on the Banker's Algorithm, which is a deadlock avoidance algorithm used to determine whether granting a resource request will keep the system in a safe state.
A system is said to be in a safe state if there exists at least one sequence in which all processes can complete their execution and release their resources. If no such sequence exists, the system is in an unsafe state, which may eventually lead to a deadlock.
Given:
| Process | Maximum Requirement | Current Allocation |
|---|---|---|
| X | 8 | 4 |
| Y | 7 | 1 |
| Z | 5 | 3 |
Total Resource Units = 10
Calculate Available Resources:
Calculate Remaining Need:
| Process | Maximum | Allocation | Need |
|---|---|---|---|
| X | 8 | 4 | 4 |
| Y | 7 | 1 | 6 |
| Z | 5 | 3 | 2 |
Case (i): X Requests 2 Units: After granting the request.
| Process | Allocation | Need |
|---|---|---|
| X | 6 | 2 |
| Y | 1 | 6 |
| Z | 3 | 2 |
Available Resources: 2-2 = 0
Now all processes still need resources:
But no resources are available. Therefore, no process can complete. Unsafe State.
Case (ii): Y Requests 2 Units : After granting the request.
| Process | Allocation | Need |
|---|---|---|
| X | 4 | 4 |
| Y | 3 | 4 |
| Z | 3 | 2 |
Available Resources: 2-2 = 0
Now all processes still need resources:
But no resources are available. Therefore, no process can complete. Unsafe State.
Case (iii): Z Requests 2 Units : After granting the request.
| Process | Allocation | Need |
|---|---|---|
| X | 4 | 4 |
| Y | 1 | 6 |
| Z | 5 | 0 |
Available Resources: 2-2 = 0
Notice that, Need(Z) = 0. This means Z has obtained all the resources it needs and can complete immediately.
After Z completes, it releases all its allocated resources : 5
Now, available = 0+5 = 5
Now, process X requires 4 more resource units to complete. Since 5 resource units are available, X can obtain the required resources and finish its execution. After completion, X releases its allocated resources, increasing the available resources from 5 to 9.
Next, process Y requires 6 resource units to complete. Since 9 resource units are now available, Y can also obtain the required resources and finish its execution successfully.
Thus, all processes can complete in the following order: Z → X → Y.
Since a sequence exists in which all processes can complete without causing a deadlock, the system remains in a safe state.
Q: 7Consider a system with five processes P0 to P4 and three resource types A, B, C. suppose that, at time T0, the following snapshot of the system has been taken:
| Allocation | Need | Available | |
|---|---|---|---|
| ABC | ABC | ABC | |
| P0 | 010 | 743 | 230 |
| P1 | 302 | 020 | |
| P2 | 302 | 600 | |
| P3 | 211 | 011 | |
| P4 | 002 | 431 |
Check whether a request for (0,2,0) by P0 can be granted according to Banker’s Algorithm?
Option B
Banker’s Algorithm is used in operating systems to avoid deadlock by ensuring that resource allocation keeps the system in a safe state.
Steps to check if a request can be granted:
Q: 8Which of the following will be used for a system having multiple instances of a resource type?
Option B
In a multiprogramming system, several processes may compete for limited resources such as printers, tape drives, memory, or files. When multiple instances of a resource type are available, the operating system must allocate these resources carefully to avoid deadlock.
A Deadlock occurs when a group of processes waits indefinitely for resources held by one another.
To prevent such situations, the operating system uses algorithms that determine whether granting a resource request will keep the system in a safe state.
The Banker's Algorithm, is specifically designed for systems having multiple instances of each resource type.
Before allocating a resource, it checks whether the system will remain in a safe state after the allocation. If the system may enter an unsafe state, the request is postponed.
Therefore, Banker's Algorithm is used for Deadlock Avoidance in systems with multiple resource instances.
Q: 9In operating system, the purpose of ostrich algorithm is
Option B
In operating systems, deadlock is a situation where processes are stuck waiting for resources held by each other, and none can proceed. Different strategies exist to handle deadlocks, such as prevention, avoidance, detection, and recovery.
The Ostrich Algorithm follows a very simple approach, it ignores the possibility of deadlock completely.
The idea is based on the behavior of an ostrich (शुतुरमुर्ग) that hides its head in the sand to avoid danger. Similarly, the operating system assumes that deadlocks occur very rarely and chooses not to spend resources handling them.
Q: 10Which of the following is not a necessary condition for deadlock?
Option C
In Operating Systems, a deadlock occurs when a set of processes are permanently blocked because each process is waiting for a resource held by another process.
There are four necessary conditions for deadlock (Coffman Conditions):
| CONDITION | DESCRIPTION |
|---|---|
| Mutual Exclusion | At least one resource must be non-shareable means only one process can use it at a time. |
| Hold and Wait | A process holding at least one resource is waiting to acquire additional resources held by other processes. |
| No Pre-emption | Resources cannot be forcibly taken from a process. They must be released voluntarily. |
| Circular Wait | A circular chain of processes exists where each process waits for a resource held by the next process in the cycle. |
On the other hand, Starvation means, a process waits indefinitely because other processes continuously get the required resources.
You have reached the end of this topic. Continue learning with the next topic below.
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.