Given memory partition: 150k, 500k, 200k, 300k & 550k (in order)
Process requiring spacing
220k, 430k, 110k & 425k (in order)
First Fit
The first process arrives with the requirement of 200k memory. As we search through the memory partition. The first partition which would fit in the current request is a hole of 200k.
For the next process memory partition would be searched again from beginning. A hole which would satisfy 430k requirement is 500k leaving 70k of memory unused.
For the next request of 110k, again the search start from beginning and the memory hole satisfying the request would be 330k leaving 220k of memory unused.
The last request of 430k would be satisfying by the available memory hole of 550k leaving 125k of memory unused.
Next Fit
This algorithm start searching for next memory hole, where it stopped last time.
- First request 200k satisfied by 200k memory hole
- 2nd request 430k satisfied by next suitable memory hole i.e. 500k the lest space is 70k
- 3rd request 110k satisfied by remaining 220k
- 4th request 430k satisfied by 500k memory hole.
Best Fit
This algorithm chooses the free block closest to the requested size.