Write a program to implement Dynamic allocation of memories in MVT.
Description of Multiprogramming with fixed no of tasks: MFT is the one of the memory management technique. In this technique, main memory is divided into no of static partitions at the system generated time. A process may be loaded into a partition of equal or greater size. The partition sizes are depending on o.s. in this memory management scheme the o.s occupies the low memory, and the rest of the main memory is available for user space. This scheme suffers from internal as well as external fragmentation.
Algorithm for Multiprogram Fixed Task:
Step1: start the process.
Step2: Declare variables.
Step3: Enter total memory size.
Step4: Allocate memory for operating system.
Step5: allocate total memory to the pages.
Step6: Display the wastage of memory.
Step7: Stop the process.
/* Program to simulate Multiprogram Fixed Task*/
Program Code:
#include < stdio.h>
#include <conio.h>
void main()
{
int i, p,a[10],c[15],temp=0,total=0;
float b,t;
clrscr();
printf(“Enter the total memory ”);
scanf(“%f”,&t);
printf(“Enter the processes :”);
scanf(“%d”, &p);
b=t/p;
for(i=0;i<p;i++)
a[i]=b;
for(i=0;i<p;i++)
{
lable: printf(“Enter memory for %d process: ",i);
scanf(“%d”,&temp);
if(temp<=b)
{
c[i]=a[i]-temp;
printf(“Internal fragmentation for this block”);
printf(“%d”,c[i]);
}
else
{
printf(“Required memory is not available”);
goto lable;
}
total=total+c[i];
}
printf(“Total internal fragmentation %d\n”,total);
getch();
}
Program Output:
Enter the total memory: 800
Enter the processes: 4
Enter memory for 0 process: 150
Internal fragmentation for this block: 50
Enter memory for 1 process: 100
Internal fragmentation for this block: 100
Enter memory for 2 process: 200
Internal fragmentation for this block: 0
Enter memory for 3 process: 200
Internal fragmentation for this block: 0
Total internal fragmentation 150
Post A Comment:
0 comments: