0% found this document useful (0 votes)
18 views2 pages

MFT and MVT Memory Management Simulation

The document describes a C program that simulates two memory management techniques: MFT (Multiprogram Fixed Task) and MVT (Multiprogram Variable Task). The MFT implementation allocates fixed-size partitions to processes and calculates internal fragmentation, while the MVT implementation allocates variable sizes to processes and calculates external fragmentation. Both implementations include user input for memory size, operating system size, and process sizes, and provide outputs indicating allocation status and fragmentation results.

Uploaded by

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

MFT and MVT Memory Management Simulation

The document describes a C program that simulates two memory management techniques: MFT (Multiprogram Fixed Task) and MVT (Multiprogram Variable Task). The MFT implementation allocates fixed-size partitions to processes and calculates internal fragmentation, while the MVT implementation allocates variable sizes to processes and calculates external fragmentation. Both implementations include user input for memory size, operating system size, and process sizes, and provide outputs indicating allocation status and fragmentation results.

Uploaded by

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

Experiment 4: Write a C program to simulate the MFT(MULTIPROGRAM FIXED TASK) and

MVT(MULTIPROGRAM VARIABLE TASK) memory management


techniques.

(A)
Aim: To implement and simulate the MFT(MULTIPROGRAM FIXED TASK) algorithm.
#include<stdio.h>
int main()
{
int ms,i,ps[20],n,size,p[20],s,intr=0; /*ms-main memory size,i for loop
repetation, ps is size of each process,n is number of processes, size- size of each
partition, p-process identity, s-size of operating system, intr-for calculation
internal fragmentation*/
printf("Enter size of memory:");
scanf("%d",&ms);
printf("Enter memory for OS:");
scanf("%d",&s);
ms-=s;
printf("Enter [Link] partitions to be divided:");
scanf("%d",&n);
size=ms/n;
for(i=0;i<n;i++)
{
printf("\n Enter process and process size:");
scanf("%d%d",&p[i],&ps[i]); /*process id and process size*/
if(ps[i]<=size)
{
intr=intr+size-ps[i]; /*intr is 0 means there is no internal
fragmentation*/
printf("process%d is allocated\n",p[i]);
}
else
printf("\n process%d is blocked",p[i]);
}
printf("\n internal fragmentation is %d",intr);
return 0;
}

Output:
Enter size of memory:100
Enter memory for OS:40
Enter [Link] partitions to be divided:4

Enter process and process size:1 15


process1 is allocated

Enter process and process size:2 30

process2 is blocked
Enter process and process size:3 5
process3 is allocated

Enter process and process size:4 40

process4 is blocked
internal fragmentation is 10

(B)
Aim: To implement and simulate the MVT(MULTIPROGRAM VARIABLE TASK) algorithm.
#include<stdio.h>
int main()
{
int i,m,n,tot,s[20];
printf("Enter total memory size:");
scanf("%d",&tot);
printf("Enter no. of processes:");
scanf("%d",&n);
printf("Enter memory for OS:");
scanf("%d",&m);
for(i=0;i<n;i++)
{
printf("Enter size of process %d:",i+1);
scanf("%d",&s[i]);
}
tot=tot-m;
for(i=0;i<n;i++)
{
if(tot>=s[i])
{
printf("\nProcess %d is allocated ",i+1);
tot=tot-s[i];
}
else
printf("\nprocess p%d is not allocated\n",i+1);
}
printf("External Fragmentation is=%d",tot);
return 0;
}

Output:
Enter total memory size:100
Enter no. of processes:4
Enter memory for OS:40
Enter size of process 1:15
Enter size of process 2:30
Enter size of process 3:5
Enter size of process 4:35

Process 1 is allocated
Process 2 is allocated
Process 3 is allocated
process p4 is not allocated
External Fragmentation is=10

You might also like