Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- main()
- {
- int mems, bls, nobl, extf,n, mp[10],intf=0;
- int i,p=0;
- printf("Enter the total memory ");
- scanf("%d",&mems);
- printf("Enter the block size ");
- scanf("%d", &bls);
- nobl=mems/bls;
- extf=mems - nobl*bls;
- printf("\nEnter the number of processes ");
- scanf("%d",&n);
- for(i=0;i<n;i++)
- {
- printf("Enter memory required for process %d ",i+1);
- scanf("%d",&mp[i]);
- }
- printf("\nNo. of Blocks available in memory %d",nobl);
- printf("\n\nPROCESS\tMEMORY REQUIRED\t ALLOCATED\tINTERNAL FRAGMENTATION");
- for(i=0;i<n && p<nobl;i++)
- {
- printf("\n %d\t\t%d",i+1,mp[i]);
- if(mp[i] > bls)
- printf("\t\tNO\t\t---");
- else
- {
- printf("\t\tYES\t%d",bls-mp[i]);
- intf = intf + bls-mp[i];
- p++;
- }
- }
- if(i<n)
- printf("\nMemory is Full, Remaining Processes cannot be accomodated");
- printf("\n\nTotal Internal Fragmentation is %d",intf);
- printf("\nTotal External Fragmentation is %d",extf);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment