I was reading about next-fit algorithm for memory management but could not find an answer to a specific detail.
From: https://www.geeksforgeeks.org/program-for-next-fit-algorithm-in-memory-management/
Next fit is a modified version of ‘first fit’. It begins as the first fit to find a free partition but when called next time it starts searching from where it left off, not from the beginning.
What if no match was found from point x and what comes after (until the last block). will this algorithm continue in cyclic way to search from 0 to x, or it will stuck?
(probably the answer will be yes since it makes much more sense but not sure and I really want to know this information).
Yes, this will treat the memory as a cyclical buffer. The search sequence is x->end->begin->x
. If you reach your starting point x
again, the search failed, so the requested memory isn't available.
What you do next depends on earlier details - can you somehow make a larger block available? Shuffle memory around? In the simple cases (this is a tutorial after all), you just fail.