Q.2)
Variable size portion of a memory block
1. First fit
In this algorithm memory are divided into 5 block i.e 120,380,410,232,540(in order)
Process are 215,425,112,328(in order)
the first process will be allocated to the partition which is first sufficient block from the top of Main Memory.
So 215 kB process is not allocated to 120 KB memory block then check for the next block. 380 KB block is sufficient for it so first 215 KB process is allocated to 380KB block and the remaining memory will be 165 KB which can be used for upcoming processes.
Then 425 KB process is allocated to first sufficient block i.e 540 KB remaining 115 KB.
112 KB process is allocated to first sufficient block i.e 120 KB remaining 8 KB
328 KB process is allocated to first sufficient block i.e 410 KB remaining 82 KB
The remaining block is shaded
Best fit
Best Fit Allocate the process to the block which is the first smallest sufficient block among the free available block.
Process are 215,425,112,328(in order)
First 215 KB process is allocated to first smallest sufficient block i.e 232 KB remaining 17 KB
425 KB process is allocated to first smallest sufficient block i.e 540 KB remaining 115 KB
112 KB process is allocated to first smallest sufficient block i.e 115 KB remaining 3 KB
328 KB process is allocated to first smallest sufficient block i.e 350 KB remaining 52 KB
Worst fit
Worst Fit Allocate the process to the block which is the largest sufficient among the freely available block available in the main memory
Process are 215,425,112,328(in order)
First 215 KB process is allocated to first largest sufficient block i.e 540 KB remaining 325 KB
425 KB process is allocated to first largest sufficient block. But there is no memory block which can hold the 425 KB process. This will generate So algorithm move to the next process.
112 KB process is allocated to first largest sufficient block i.e 410 KB remaining 298 KB
328 KB process is allocated to first largest sufficient block i.e 380 KB remaining 52 KB
According to the question, the second one i.e BEST FIT algorithm is suited for variable partition memory. So write the Best-Fit algorithm is the most effective algorithm.
NOTE
(But actually, the worst fit algorithm is most efficient for variable size partition memory and the best-fit algorithm is most efficient for fix size partition memory)
Dept. of Computer Science and Information Systems-CSIS College of Arts and Sciences AUK CSIS 310 Textbook...
Operating Systems 1. Given memory partitions of 100 KB, 500 KB, 200 KB, 300 KB and 600 KB (in order), how would each of the first-fit, best-fit and worst-fit algorithms place processes of 212 KB, 417 KB, 112 KB and 426 KB (in that order)? Which algorithm makes the most efficient use of memory?