Please modify this base code so that it properly outputs the correct block no.'s for the following
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 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.
Computer Architecture A Quantitative Approach
ISBN: 978-0123704900
4th edition
Authors: John L. Hennessy, David A. Patterson