0
$\begingroup$

I read that system being in safe state doesn't guarantee that deadlock is not possible.

Can someone give me an example where system is in safe state and deadlock is possible?

$\endgroup$
  • 1
    $\begingroup$ Where did you read that? What specifically did they say? What definition of 'safe state' are you using? $\endgroup$ – D.W. Jul 30 '17 at 23:05
  • $\begingroup$ I guess you got confuse for the safe state definition. Safe state means the safe sequence of process s.t. allocation of resources in this order will not result in deadlock. Although unsafe state doesn't always mean that the system will result into deadlock. $\endgroup$ – Pragya Jul 31 '17 at 9:16
  • $\begingroup$ I read that even if the system is in safe state, then there can be some another execution sequence which can lead to deadlock. $\endgroup$ – Zephyr Jul 31 '17 at 12:53
  • $\begingroup$ @Zephyr There are 2 units of resource A and 2 units of resource B. Job $j$ requires 2 As and 1 B. Job $k$ requires 1 A and 2Bs. System is in safe state since we can run $j$ to the end, after which we can run $k$ to the end. However, if 1 A and 1 B is assigned to $i$ while 1A and 1B is also assigned to $k$, here comes the deadlock. $\endgroup$ – Apass.Jack Mar 12 at 0:38
1
$\begingroup$

That is not possible, when a deadlock occurs, the system is in an UNSAFE state. A safe state wouldn't have any purpose if a deadlock could occur.

$\endgroup$
  • $\begingroup$ Please check my comment here. Although system is safe, a deadlock would occur if the following operations are not safe, as shown by my example. Of course, we can run a system at a safe state to another safe state if we want to. $\endgroup$ – Apass.Jack Mar 12 at 17:23
  • $\begingroup$ I understand your example, but the following operations have to be done in order that a deadlock can occur. A safe state is a setting where it is guaranteed to be deadlock-free. (without doing any operations ofcourse) $\endgroup$ – NimaKimi Mar 12 at 21:06
  • $\begingroup$ We are saying the two sides of exactly the same thing. You are saying the part of definition that deadlock is not happening right now. I am emphasizing that deadlock might happen in the future. It occurs to me that "deadlock is possible" refers to future. However, it could mean "deadlock might be possible right now", which is false as you pointed out. $\endgroup$ – Apass.Jack Mar 12 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.