• 100% Satisfaction Guarantee
abhi_iitian, Computer Software Engineer
Category: Programming
Satisfied Customers: 1757
Experience:  B-Tech Topper in CSE from IIT Roorkee, Experience as S/W design Engineer at Microsoft India
16530347
abhi_iitian is online now

# 4. Given the following information JOB LIST JOB

### Resolved Question:

4. Given the following information
JOB LIST:
JOB #                    MEMORY REQUESTED

J1                    740k
J2                    500k
J3                    700K
MEMORY LIST:
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.
Submitted: 8 years ago.
Category: Programming
Expert:  abhi_iitian replied 8 years ago.
Hello, Thanks for using just answers.

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 J1
J2 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 1

J3 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 Block3

b. 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 J1
Now, J2 arrives, Operating system checks if block 1 is large enough , it is large enough and available , hence block1 is assigned to J2
Now, J3 arrives, Operating system checks for the first available chunk which is block3 and it is large enough, hence block3 is assigned to J3

So, Order is :
Process MEMORY BLOCK
J1 Block 2
J2 Block 1
J3 Block 3

So 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.