Consider the requests from processes in given order $300K$, $25K$, $125K$ and $50K$. Let there be two blocks of memory available of size $150K$ followed by a block size $350K$.
Which of the following partition allocation schemes can satisfy above requests?
- Best fit but not first fit.
- First fit but not best fit.
- Both First fit & Best fit.
- neither first fit nor best fit.
Solution: Let us try all options.
Best Fit:
$300K$ is allocated from block of size $350K$. $50$ is left in the block.
$25K$ is allocated from the remaining $50K$ block. $25K$ is left in the block.
$125K$ is allocated from $150 K$ block. $25K$ is left in this block also.
$50K$ can’t be allocated even if there is $25K + 25K $ space available.
First Fit:
$300K$ request is allocated from $350K$ block, $50K$ is left out.
$25K$ is be allocated from $150K$ block, $125K$ is left out.
Then $125K$ and $50K$ are allocated to remaining left out partitions.
So, first fit can handle requests.
So option B is the correct choice.
DOUBT: Here we assumed a partition can be allocated to a process even if some other process occupies a part of that partition. But in many other questions, no process can be allocated to partition already allocated to some other process even if there is space available in the partition.
Eg. If we have a partition of $300KB$ already occupied by a process of $200KB$ then a process with size $100KB$ can't be allocated to this partition.
Which approach is correct?