Os 8
Os 8
#include<stdio.h>
void main()
{
int bsize[10], psize[10], bno, pno, flags[10], allocation[10], i, j;
scanf("%d",&np);
scanf("%d",&nb);
printf("Block no.%d:",i);
scanf("%d",&b[i]);
}
printf("Process no.%d:",i);
scanf("%d",&p[i]);
}
for(i=1;i<=np;i++)
{
for(j=1;j<=nb;j++)
{
if(barray[j]!=1)
{
tem=b[j]-p[i];
if(tem>=0)
if(low>tem)
{
parray[i]=j;
low=tem;
}
}
}
fragment[i]=low;
barray[parray[i]]=1;
low=10000;
}
printf("\n%d\t\t%d\t\t%d\t\t%d\t\t%d",i,p[i],parray[i],b[parray[i]],fragment[i]);
}
Output:
#include <stdio.h>
int main()
int n, m, i, j, k;
n = 5; // Number of processes
m = 3; // Number of resources
{ 2, 0, 0 }, // P1
{ 3, 0, 2 }, // P2
{ 2, 1, 1 }, // P3
{ 0, 0, 2 } }; // P4
{ 3, 2, 2 }, // P1
{ 9, 0, 2 }, // P2
{ 2, 2, 2 }, // P3
{ 4, 3, 3 } }; // P4
f[k] = 0;
int need[n][m];
int y = 0;
if (f[i] == 0) {
int flag = 0;
flag = 1;
break;
if (flag == 0) {
ans[ind++] = i;
avail[y] += alloc[i][y];
f[i] = 1;
Operating System
Output