in Operating System
968 views
0 votes
0 votes
MSQ

 

Which of the following statements is/are TRUE?

  1. If safe state exists, deadlock can be avoided if resources are allocated properly
  2. If safe state exists, deadlock is never possible in future
  3. Unsafe state always leads to a deadlock
  4. Even if safe state exists, deadlock is possible, if resources are poorly allocated
  5. Unsafe state may lead to a deadlock
in Operating System
968 views

4 Comments

1,4,5are true
2
2
How 4 and 5 are true?
0
0
Safe state does not guarantee a deadlock free system. Safe state means we have a sequence, which if followed will give us a deadlock free operation. But resources can be allocated in such a manner that the system may enter into deadlock.

Suppose you have $4$ processes ($P_1$,$P_2$,$P_3$,$P_4$) where $P_3$ and $P_4$ has no requirements now, but $P_1$ and $P_2$ needs $3$ and $4$ instance of resources respectively to finish execution.
Let’s say $P_3$ holds $2$ instances of resource at max and $P_4$ holds $3$ instances of resource max. Now, if both releases the resources we’ll get total of $5$ instances of resources. Now coming to Option A, it is saying that my system is deadlock free as max requirement is by $P_2$ which is $4$ and it is less than total free reources $5$.
But what if we allocate $2$ out of the $5$ resources to $P_3$ and remaining $3$ resources to $P_4$. $P_3$ and $P_4$ will both still need 1 resource but we have exhausted all resource. Hence system gets into deadlock.\

Even unsafe state does not guarantee deadlock. A process can pre-empt and release all its resources to make the state safe.
3
3
How you're getting 4 and 5 .. it's 1 4  5
0
0

1 Answer

1 vote
1 vote

The following statements are true:

  1. If a safe state exists, deadlock can be avoided if resources are allocated properly.

This statement is true. A safe state means that there exists at least one sequence of processes that can complete execution while avoiding a deadlock. If resources are allocated properly, i.e., according to some safe allocation algorithm, then we can ensure that we always remain in a safe state, and hence avoid a deadlock.

  1. If a safe state exists, deadlock is never possible in the future.

This statement is not true. Even if a system is in a safe state currently, it is still possible for it to enter into a deadlock in the future if resources are not allocated properly. A safe state only guarantees that there exists at least one sequence of processes that can complete execution while avoiding a deadlock. It does not guarantee that a deadlock will never occur in the future.

  1. An unsafe state always leads to a deadlock.

This statement is not true. An unsafe state is a state in which there is at least one sequence of processes that can lead to a deadlock. However, it is still possible to avoid a deadlock in an unsafe state if resources are allocated properly.

  1. Even if a safe state exists, deadlock is possible if resources are poorly allocated.

This statement is true. A safe state only guarantees that there exists at least one sequence of processes that can complete execution while avoiding a deadlock. However, if resources are poorly allocated, i.e., not according to some safe allocation algorithm, then we can still end up in a deadlock even if a safe state exists.

  1. An unsafe state may lead to a deadlock.

This statement is true. An unsafe state is a state in which there is at least one sequence of processes that can lead to a deadlock. Therefore, an unsafe state may lead to a deadlock if the resources are allocated improperly.

Related questions