MFT
AIM: The main of this program is to implement the Multiprogramming with a Fixed number of Tasks in c
MFT:
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int ms, bs, nob, ef,n, mp[10],tif=0;
int i,p=0;
clrscr();
printf("Enter
the total memory available (in Bytes) -- ");
scanf("%d",&ms);
printf("Enter
the block size (in Bytes) -- ");
scanf("%d",
&bs);
nob=ms/bs;
ef=ms - nob*bs;
printf("\nEnter
the number of processes -- ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter
memory required for process %d (in Bytes)-- ",i+1);
scanf("%d",&mp[i]);
}
printf("\nNo.
of Blocks available in memory -- %d",nob);
printf("\n\nPROCESS\tMEMORY
REQUIRED\t ALLOCATED\tINTERNAL FRAGMENTATION");
for(i=0;i<n
&& p<nob;i++)
{
printf("\n %d\t\t%d",i+1,mp[i]);
if(mp[i] >
bs)
printf("\t\tNO\t\t---");
else
{
printf("\t\tYES\t%d",bs-mp[i]);
tif = tif + bs-mp[i];
p++;
}
}
if(i<n)
printf("\nMemory is Full, Remaining Processes
cannot be accomodated");
printf("\n\nTotal Internal Fragmentation is
%d",tif);
printf("\nTotal External Fragmentation is
%d",ef);
getch();
}
Input:
Enter the total memory available (in
Bytes) -- 1000
Enter the block size (in Bytes) -- 300
Enter the number of processes – 5
Enter memory required for process 1 (in
Bytes) -- 275
Enter memory required for process 2 (in
Bytes) -- 400
Enter memory required for process 3 (in
Bytes) -- 290
Enter memory required for process 4 (in
Bytes) -- 293
Enter memory required for process 5 (in
Bytes) -- 100
No. of Blocks available in memory -- 3
Output:
PROCESS MEMORY
REQUIRED ALLOCATED INTERNAL FRAGMENTATION
1 275 YES 25
2 400 NO -----
3 290 YES 10
4 293 YES 7
Memory is Full, Remaining Processes
cannot be accommodated
Total Internal Fragmentation is 42
Total External Fragmentation is 100
Result:


0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home