When is a system in safe state?
A state is safe if the system can allocate resources to each process (upto its maximum) in some order and still avoid a deadlock.
A system is said to be in a safe state if there is a safe execution sequence. An execution sequence is an ordering for process execution such that each process, when executed, run until it terminates or is blocked, and all requests for resources are immediately granted (if the resource is available).
Thus, a safe execution sequence is an execution sequence in which all processes run to its completion.