0% found this document useful (0 votes)
3 views1 page

Best

The document contains a C program that implements the Best Fit memory management scheme. It prompts the user to input the number of processes and blocks, as well as their respective sizes, and then allocates memory accordingly while calculating the fragmentation. The output displays the process number, process size, block number, block size, and the resulting fragmentation for each process.

Uploaded by

vaishnavak77
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Best

The document contains a C program that implements the Best Fit memory management scheme. It prompts the user to input the number of processes and blocks, as well as their respective sizes, and then allocates memory accordingly while calculating the fragmentation. The output displays the process number, process size, block number, block size, and the resulting fragmentation for each process.

Uploaded by

vaishnavak77
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<stdio.

h> temp=b[j]-p[i];
void main() if(temp>=0)
{ if(low>temp)
int {
fragment[20],b[20],p[20],i,j,nb,np,temp,low=9 parray[i]=j;
999; low=temp;
static int barray[20],parray[20]; }
printf("Memory management scheme-Best }
Fit\n"); }
printf("Enter the no. of processes:"); fragment[i]=low;
scanf("%d",&np); barray[parray[i]]=1;
printf("Enter the no. of blocks:"); low=10000;
scanf("%d",&nb); }
printf("Enter the size of the blocks:"); printf("Process no.\tProcess size\tBlock
for(i=1;i<=nb;i++) no.\tBlocksize\tFragment\n");
{ for(i=1;i<=np&&parray[i]!=0;i++)
printf("Block no. % d:",i); printf("%d\t\t%d\t\t%d\t\t%d\t\t%d\n",i,p[i],
scanf("%d",&b[i]); parray[i],b[parray[i]],fragment[i]);
} }
printf("Enter the size of the processes: ");
for(i=1;i<=np;i++) OUTPUT
{ Memory management scheme-Best Fit
printf("Process no. %d:",i); Enter the no. of processes:3
scanf("%d",&p[i]); Enter the no. of blocks:3
} Enter the size of the blocks:Block no. 1:100
for(i=1;i<=np;i++) Block no. 2:150
{ Block no. 3:200
for(j=1;j<=nb;j++) Enter the size of the processes: Process no.
{ 1:80
if(barray[j]!=1) Process no. 2:120
{ Process no. 3:180

Process no. Process size Block no. Blocksize Fragment


1 80 1 100 20
2 120 2 150 30
3 180 3 200 20

You might also like