4. Given the following information
JOB # MEMORY REQUESTED
MEMORY BLOCK SIZE
Block 1 610k (low-order memory)
Block 2 850k
Block 3 700k (high-order memory)
a. Use the best-fit algorithm to allocate the memory blocks to the three arriving jobs.
b. Use the first-fit algorithm to allocate the memory blocks to the three arriving jobs.
Hello, Thanks for using just answers.Answer is :a. Best -Fit Algorithm - In best-fit algorithm , the arriving job is allocated the smallest memory chunk available which is large enough to provide the memory requested by that job.So here, J1 , only chunk large enough is Block2 so, Block 2 is allocated to J1J2 arrives, Now Block 1 and Block 3 are available (as Block 1 has been allocated ) and large enough to provide the requested memory but the smallest of them is Block 1, so J2 is allocated Block 1J3 arrives, Now Block 3 is available (as Block 1 and Block 2 have been allocated ) and large enough to provide the requested memory, so J3 is allocated Block3b. First -Fit Algorithm - In this algorithm, the arriving job is allocated the first memory chunk available which is large enough to provide the memory requested by that job.So here, J1 arrives, Block 1 is not large enough, so first chunk large enough is Block2, so Block 2 is allocated to J1Now, J2 arrives, Operating system checks if block 1 is large enough , it is large enough and available , hence block1 is assigned to J2Now, J3 arrives, Operating system checks for the first available chunk which is block3 and it is large enough, hence block3 is assigned to J3So, Order is : Process MEMORY BLOCK J1 Block 2 J2 Block 1 J3 Block 3So here in both algorithms , we have got same allocation which is not the case always. It will differ with the order of arrival of processes. e.g if order is 700k,500k,740k , in best fit, allocation will come to be same when we apply the algorithm but in first-fit, it will be 700k to Block2 , 500K to Block 1 and third process(740K) will have to wait for the 500Kprocess to finish so that it can get that memory block.
B-Tech Topper in CSE from IIT Roorkee, Experience as S/W design Engineer at Microsoft India