Memory_Allocation_Programs_With_Comments
Memory_Allocation_Programs_With_Comments
#include <stdio.h>
int main() {
int bsize[20], psize[20], allocation[20]; // Arrays to hold block sizes, process sizes, and al
int bno, pno, i, j;
return 0;
}
// Best Fit Program with Comments
#include <stdio.h>
int main() {
int bsize[20], psize[20], allocation[20];
int bno, pno, i, j, best;
// Input processes
printf("Enter number of processes: ");
scanf("%d", &pno);
printf("Enter size of each process:\n");
for (i = 0; i < pno; i++)
scanf("%d", &psize[i]);
// Print result
printf("\nProcess No.\tProcess Size\tBlock No.\n");
for (i = 0; i < pno; i++) {
printf("%d\t\t%d\t\t", i + 1, psize[i]);
if (allocation[i] != -1)
printf("%d\n", allocation[i] + 1);
else
printf("Not Allocated\n");
}
return 0;
}
// Worst Fit Program with Comments
#include <stdio.h>
int main() {
int bsize[20], psize[20], allocation[20];
int bno, pno, i, j, worst;
// Initialize allocations to -1
for (i = 0; i < pno; i++)
allocation[i] = -1;
return 0;
}