Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Bankers algorithm in c

Bankers algorithm in c

Ratings: (0)|Views: 2,078|Likes:
Published by Chaman Singh

More info:

Published by: Chaman Singh on May 27, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less





#include<stdio.h>#include<conio.h>void main(){int aloc[10][10],need[10][10],max[10][10],av[10],rv[10];int nr=0,np=0,complete[10];int i=0,j=0,sum=0,ctr=0;clrscr();//GETTING REQUIRED DATA....printf("\nEnter num of process: ");scanf("%d",&np);printf("\nEnetr num of resources: ");scanf("%d",&nr);if(np==0  nr==0){printf("\nwrong input...\nplease enter correct value");getch();return;}printf("\nEnter resource vector: ");for(i=0;i<nr;i++){scanf("%d",&rv[i]);}printf("\nEnter max claim matrix: ");for(i=0;i<np;i++){for(j=0;j<nr;j++){scanf("%d",&max[i][j]);}}printf("\nEnter allocation matrix: ");for(i=0;i<np;i++){for(j=0;j<nr;j++){scanf("%d",&aloc[i][j]);}}//find need matrix...for(i=0;i<np;i++){for(j=0;j<nr;j++){need[i][j] = 0;need[i][j] = max[i][j] - aloc[i][j] ;}}//find avilable resources..for(i=0;i<nr;i++){av[i]=0;
for(j=0;j<np;j++){sum = sum + aloc[j][i] ;}av[i] = rv[i] - sum ;sum=0;}//initialising complete vector...for(i=0;i<np;i++){complete[i]=0;}//DISPLAY THE INPUT WITH INITIAL SITUATION...printf("\nALOC_MATRIX\tMAX_CLAIM\tNEED");for(i=0;i<np;i++){printf("\n");for(j=0;j<nr;j++){printf("%d ",aloc[i][j]);}printf("\t\t ");for(j=0;j<nr;j++){printf("%d ",max[i][j]);}printf("\t ");for(j=0;j<nr;j++){printf("%d ",need[i][j]);}}printf("\nResource vector: ");for(i=0;i<nr;i++){printf("%d ",rv[i]);}printf("\nAvailable resources: ");for(i=0;i<nr;i++){printf("%d ",av[i]);}//FINDING SAFE SEQUENCE...again:for(i=0;i<np;i++){if(complete[i]==1){continue;}else{

Activity (18)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
serhadkeles liked this
Suraj Gaikwad liked this
Buse Köksal liked this
EduardoPaiva liked this
Nilgun Turhan liked this
772518 liked this
Moksha Bhargava liked this
Sridhar Mocherla liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->