Click here to Skip to main content
14,643,391 members
Articles » General Programming » Algorithms & Recipes » Algorithms
Posted 27 Jul 2014

Tagged as


14 bookmarked

Corporate projects & human resource management using Banker's algorithm

Rate this:
4.61 (9 votes)
Please Sign up or sign in to vote.
4.61 (9 votes)
27 Jul 2014CPOL
This will show the simple and useful way to implement Banker's algorithm in managing & scheduling projects,their resources & to give effective solution.


Normally, Banker's algorithm is used to  manage operating system process & their resources. Same idea is used here. Process are treated as "Projects" and resources are treated as "Project resources". for e.g. In "P1" project, 3 c++, 2 Java, 4 dot net resources are required & so on. This code takes "Claimed resources","Allocated resources" & "Available resources" as Input and gives proper project completion sequence as output. If unsafe state is occurred then, program will give you suggestion to hire number of employees of particular resources based on logic so that minimum number of resources have to be hired.


The Banker's algorithm is a resource allocation and deadlock avoidance algorithm developed by Edsger Dijkstra that tests for safety by simulating the allocation of predetermined maximum possible amounts of all resources, and then makes an "s-state" check to test for possible deadlock conditions for all other pending activities, before deciding whether allocation should be allowed to continue.


In the following output, code takes the number of processes,  number of resources, for each process required/claimed resources, allocated resources for each project, available resources as input & gives the proper sequence of completion of all projects as output (Following is an example of safe state).

Image 1

In the following output,  code evaluates the allocated & claimed resources & evaluates unsafe state. It tells user to hire particular number of employees to complete projects in the efficient & proper sequence.

Image 2

Using the code

Following code gives the logic to schedule project:

    if(chkpcmp[i]==0) {  // Do for those projects for who has not completed yet
   for(int j=0;j<nr;)
     for(int y=0;y<nr;y++)
             else {count=0;break;}
        if(count==nr) {count=0;break;}
     if((clm[i][j]-allo[i][j])<=avl[j])  //If required resources are available
       for(int k=0;k<nr;k++)       //After completion,transfer resources into available resources
       for(int k=0;k<nr;k++)     //After completion, make allocated resources as zero 
        for(int k=0;k<nr;k++)    //After completion, make claimed resources as zero
     cout<<"\nProject "<<"P"<<i+1<<" is completed\n";    

In the unsafe state, claimed/required resources are greater than the available. In such cases, we have to  hire more resources to complete the projects. Following code snippet suggests to hire minimum number of employees in order to complete all the projects.

          if(chkpcmp[cp]==0// Do for those projects who has not completed yet
           for(int j=0;j<nr;j++)     // Summation of all resources
               {minc=a+1;flag2=0;}  //Find minimum sum so that to hire minimum number of employees
               for(int t=0;t<nr;t++)      //Store it as per resources

Points of Interest

We can use this in real life managing Human Resources. In large scale, we can create HTML page as front-end and can use drop down menu to select project & resources and can use SQL/Oracle database to store the project information as back-end. This will be very useful & simple to use.

Future addition

In unsafe state, current program gives the suggestion to hire new resources. We can also add few more option to this.
For e.g. transfer resources from other projects in balanced way. i.e. if we transfer resources from only one project then, it may have some problem, we can not complete projects with the help of few resources. So, job is to tranfer resources from all the projects.



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Rakesh Waghulde
Software Developer
India India
No Biography provided

Comments and Discussions

GeneralMy vote of 5 Pin
Ștefan-Mihai MOGA13-Aug-14 3:17
professionalȘtefan-Mihai MOGA13-Aug-14 3:17 
This is a great inspiring article. I am pretty much pleased with your good work. You put really very helpful information. Keep it up once again.
GeneralRe: My vote of 5 Pin
Rakesh Waghulde13-Aug-14 23:44
MemberRakesh Waghulde13-Aug-14 23:44 
GeneralMy vote of 5 Pin
Matth Moestl28-Jul-14 10:21
professionalMatth Moestl28-Jul-14 10:21 
GeneralRe: My vote of 5 Pin
Rakesh Waghulde28-Jul-14 19:34
MemberRakesh Waghulde28-Jul-14 19:34 
GeneralImages missing Pin
Snorri Kristjansson27-Jul-14 23:51
professionalSnorri Kristjansson27-Jul-14 23:51 
GeneralRe: Images missing Pin
Rakesh Waghulde28-Jul-14 0:01
MemberRakesh Waghulde28-Jul-14 0:01 
GeneralRe: Images missing Pin
Rakesh Waghulde28-Jul-14 8:15
MemberRakesh Waghulde28-Jul-14 8:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.