Adnan
Adnan
5
Implementation of Contiguous Memory Allocation Techniques: Worst Fit and Best Fit
Objective:
Apparatus/Software Required:
Theory:
i) Worst Fit
Allocates memory in the smallest block that is large enough to fit the process.
Reduces internal fragmentation initially.
May result in external fragmentation due to many small leftover blocks.
Worst Fit:
1. For each process, find the largest available memory block that fits.
2. Allocate the process to that block.
3. Reduce the size of the block accordingly.
4. If no block fits, mark the process as unallocated.
Best Fit:
Sample Input:
Memory Blocks: 100 KB, 500 KB, 200 KB, 300 KB, 600 KB
Process Sizes: 212 KB, 417 KB, 112 KB, 426 KB
Expected Output:
Result:The memory allocation techniques Worst Fit and Best Fit were implemented
successfully. Their effectiveness was compared using sample input data, and differences
in allocation patterns were observed.