Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of a segmented heap #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pantsman0
Copy link

This widens the implementation of the Heap struct into a SegmentedHeap, allowing multiple regions to be used for heap allocation. There is not, however, any fitting strategy - all allocations using allocate_first_fit will always use the first memory region, unless it fails. Allocations will cascade down the array of hole lists, failing to allocate when all regions fail to allocate.

This also makes the assumption that memory regions are non-overlapping, so construction from a list of pointer+sizes is unsafe and that invariant is left to the consumer to enforce.

WIP as this does not extend the testing or fuzzing to the wider implementation, but should theoretically be fine as the changes do not actually change any of the allocation login in hole.rs.

There is another change in there to make HoleList::allocate_first_fit return an Option type, which was done to make a functional pattern work in SegmentedHeap::allocate_first_fit (i.e. using Iterator::filter_map) but this can be reverted if we don't want that change mixed in with the other changes.

This widens the implementation of the `Heap` struct into a `SegmentedHeap`, allowing multiple regions to be used for heap allocation. There is not, however, any fitting strategy - all allocations using allocate_first_fit will always use the first memory region, unless it fails. Allocations will cascade down the array of hole lists, failing to allocate when all regions fail to allocate.

This also makes the assumption that memory regions are non-overlapping, so construction from a list of pointer+sizes is unsafe and that invariant is left to the consumer to enforce.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant