Question: Please modify this base code so that it properly outputs the correct block no.'s for the following memory allocations.... - first fit - needed output

 

Please modify this base code so that it properly outputs the correct block no.'s for the following memory allocations....

- first fit - needed output for block no: 1,5,1,1,3, respectively in that order

- best fit- needed output for block no: 4,5,2,3,1, respectively in that order

- worst fit- needed output for block no: 1,5,3,3, Not allocated, respectively in that order

- next fit - needed output for block no: 1,5,1,1,3, respectively in that order

***** Logic for the fits******

First Fit Implementation: a. Input memory blocks with size and processes with size. b. Initialize all memory blocks as free. c. Start by picking each process and check if it can be assigned to current block. d. If size-of-process <= size-of-block if yes then assign and check for next process. e. If not then keep checking the further blocks.

2. Best Fit Implementation: a. Input memory blocks with size and processes with size. b. Initialize all memory blocks as free. c. Start by picking each process and find the minimum block size that can be assigned to current process i.e., find min(blockSize[1], blockSize[2],.....blockSize[n]) > processSize[current], if found then assign it to the current process. d. If not, then leave that process and keep checking the further processes.

3. Worst Fit Implementation: a. Input memory blocks with size and processes with size. b. Initialize all memory blocks as free. c. Start by picking each process and find the maximum block size that can be assigned to current process i.e., find max(blockSize[1], blockSize[2],.....blockSize[n]) > processSize[current], if found then assign it to the current process. d. If not, then leave that process and keep checking the further processes.

 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To modify the code for First Fit Best Fit Worst Fit and Next Fit memory allocation algorithms the basic structure of the code will remain the same wit... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!