views:

53

answers:

1

Hi, just a quick query about safe/unsafe states in Dijkstra's Banker's algorithm...

If one of the processes in the snapshot of the system (for example the one below) already has all of its needs fulfilled and there are not sufficient resources available to fulfil the needs of any of the other processes, is the system in a safe state? I know normally we assume that once a process receives its required resources it will terminate soon after and return all resources, but is this assumption factored in when we calculate the state of the system?

  Allocated        Maximum     Available

    | A | B         | A | B      A | B
 ---+---+---     ---+---+---    ---+---
 P1 | 1 | 2      P1 | 1 | 2      1 | 3
 P2 | 5 | 3      P2 | 7 | 8    

EDIT

Just to make my question a bit clearer: is the system in the example above in a safe state or an unsafe state? Do we assume that requests from P2 are delayed until P1 returns resources, at which point P2's requests can be fulfilled and therefore the system is safe, or is the system unsafe because currently none of the possible requests can be fulfilled?

+1  A: 

The system is in a safe state because Process 1 can run. When it finishes, there will be enough copies of resource A and resource B for process 2 to finish. Thus, there exists a "schedule" with which the system may run its processes to completion. This means it's safe.

YGL