Oslab 2
Oslab 2
h>
#define max 20
int main()
{
int bsize[max], fsize[max], nb, nf, temp, low = 10000;
static int bflag[max], fflag[max];
int i, j;
BFT
FFT
#include<stdio.h>
#define max 25
void main()
{
int frag[max], b[max], f[max], i, j, nb, nf, temp;
static int bf[max], ff[max];
printf("\nFile_no\tFile_size\tBlock_no\tBlock_size\tFragment\n");
for (i = 1; i <= nf; i++) {
printf("\n%d\t%d\t\t%d\t\t%d\t\t%d", i, f[i], ff[i], b[ff[i]],
frag[i]);
}
}
FFT
WFT
#include<stdio.h>
#define max 25
void main()
{
int frag[max], b[max], f[max], i, j, nb, nf, temp, highest = 0;
static int bf[max], ff[max];
printf("\n\tMemory Management Scheme Worst Fit");
printf("\nEnter the number of blocks: ");
scanf("%d", &nb);
printf("Enter the number of files: ");
scanf("%d", &nf);
printf("\nEnter the size of the blocks:\n");
for(i = 0; i < nb; i++)
{
printf("Block %d: ", i + 1);
scanf("%d", &b[i]);
}
printf("Enter the size of the files:\n");
for(i = 0; i < nf; i++)
{
printf("File %d: ", i + 1);
scanf("%d", &f[i]);
}
for(i = 0; i < nb; i++)
{
bf[i] = 0;
}
for(i = 0; i < nf; i++)
{
highest = -1;
for(j = 0; j < nb; j++)
{
if(bf[j] == 0)
{
temp = b[j] - f[i];
WFT