program 1
program 1
PROGRAM 1)
#include<stdio.h>
void main()
{
int n,i,p[10],r,a[10][10],j,max[10][10],av[10],need[10][10];
char res;
printf("\nNeed : ");
for (i=0;i<n;i++)
{
printf("\n%d\t",i);
for (j=0;j<r;j++)
{
need[i][j]=max[i][j]-a[i][j];
printf("%d\t",need[i][j]);
}
}
printf("\n Available : ");
for (i=0;i<n;i++)
if (i==0)
for (j=0;j<r;j++)
printf("%d\t",av[j]);
}
/*
Output
ty28@pc56:~/TY28/SEM-6/OS-2/ASSIGNEMENT_01$ cc slot1.c
ty28@pc56:~/TY28/SEM-6/OS-2/ASSIGNEMENT_01$ ./a.out
Enter the No. of Processes : 5
Enter Available : 3 4 1
Allocation Matrix :
0 1 0
2 0 0
3 0 2
2 1 1
0 0 2
Max Allocation Matrix
p0 7 5 3
p1 3 2 2
p2 9 0 2
p3 2 2 2
p4 4 3 3
Need :
0 7 4 3
1 1 2 2
2 6 0 0
3 0 1 1
4 4 3 1
Available : 3 4 1
*/