Ex 14
Ex 14
Ex 14
NO :
FILE ALLOCATION STRATEGIES
DATE :
AIM :
ALGORITHM :
PROGRAM :
#include<stdio.h>
main()
int n,i,j,b[20],sb[20],t[20],x,c[20][20];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&b[i]);
scanf("%d",&sb[i]);
t[i]=sb[i];
for(j=0;j<b[i];j++)
printf("Filename\tStart block\tlength\n");
for(i=0;i<n;i++)
printf("%d\t %d \t%d\n",i+1,t[i],b[i]);
for(i=0;i<n;i++)
{ printf("file no %d",i+1);
for(j=0;j<b[i];j++)
printf("\t%d",c[i][j]);
printf("\n");
OUTPUT :
RESULT :
Thus contiguous allocation is done for files with the available free blocks.
AIM :
To implement file allocation on free disk space in a linked file memory allocation manner.
ALGORITHM :
PROGRAM :
#include<stdio.h>
struct file
char fname[10];
int start,size,block[10];
}f[10];
main()
int i,j,n;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s",&f[i].fname);
f[i].block[0]=f[i].start;
scanf("%d",&f[i].size);
for(j=1;j<=f[i].size;j++)
scanf("%d",&f[i].block[j]);}}
printf("File\tstart\tsize\tblock\n");
for(i=0;i<n;i++)
printf("%s\t%d\t%d\t",f[i].fname,f[i].start,f[i].size);
for(j=0;j<f[i].size;j++)
printf("%d--->",f[i].block[j]);
printf("%d",f[i].block[j]);
printf("\n");
} }
OUTPUT :
RESULT :
Thus Linked file allocation is done for files with the available free blocks.
AIM :
To implement file allocation on free disk space using indexed file allocation method
ALGORITHM :
PROGRAM:
#include<stdio.h>
main()
int n,m[20],i,j,ib[20],b[20][20];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&ib[i]);
scanf("%d",&m[i]);
for(j=0;j<m[i];j++)
scanf("%d",&b[i][j]);
} printf("\nFile\t index\tlength\n");
for(i=0;i<n;i++)
printf("%d\t%d\t%d\n",i+1,ib[i],m[i]);
{ printf("fileno%d",i+1);
for(j=0;j<m[i];j++)
printf("\t%d--->%d\n",ib[i],b[i][j]);
printf("\n");
OUTPUT :
RESULT:
Thus indexed file allocation is done for files with the available free blocks.