Shishu

MFT Operating Systems program in C

Oct 24th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. main()
  4. {
  5. int mems, bls, nobl, extf,n, mp[10],intf=0;
  6. int i,p=0;
  7. printf("Enter the total memory  ");
  8. scanf("%d",&mems);
  9.  
  10. printf("Enter the block size  ");
  11. scanf("%d", &bls);
  12. nobl=mems/bls;
  13. extf=mems - nobl*bls;
  14.  
  15. printf("\nEnter the number of processes  ");
  16. scanf("%d",&n);
  17.  
  18. for(i=0;i<n;i++)
  19. {
  20. printf("Enter memory required for process %d  ",i+1);
  21. scanf("%d",&mp[i]);
  22. }
  23. printf("\nNo. of Blocks available in memory  %d",nobl);
  24. printf("\n\nPROCESS\tMEMORY REQUIRED\t ALLOCATED\tINTERNAL FRAGMENTATION");
  25. for(i=0;i<n && p<nobl;i++)
  26. {
  27. printf("\n %d\t\t%d",i+1,mp[i]);
  28. if(mp[i] > bls)
  29. printf("\t\tNO\t\t---");
  30. else
  31. {
  32. printf("\t\tYES\t%d",bls-mp[i]);
  33. intf = intf + bls-mp[i];
  34. p++;
  35. }
  36. }
  37. if(i<n)
  38. printf("\nMemory is Full, Remaining Processes cannot be accomodated");
  39. printf("\n\nTotal Internal Fragmentation is %d",intf);
  40. printf("\nTotal External Fragmentation is %d",extf);
  41. getch();
  42. }
Advertisement
Add Comment
Please, Sign In to add comment