This algorithm handles multiple instances of the same
resource.
The resources requested may not exceed the total available in
the system. The algorithm allocates resources to a requesting thread if the
allocation leaves the system in a safe state. Otherwise, the thread must wait.
Preventing Deadlock with Banker’s Algorithm
class ResourceManager
{!
int n; // # threads !
int m; // # resources!
int avail[m], // # of available resources of each type!
max[n,m], // # of each resource that each thread may want!
alloc[n,m], //# of each resource that each thread is using!
need[n,m], // # of resources that each thread might still
request
!}
No comments:
Post a Comment
Post You Comment Here. Always Respect Others . . . . . .