Function memory::allocate_pages_deferred
pub fn allocate_pages_deferred(
request: AllocationRequest<'_>,
num_pages: usize
) -> Result<(AllocatedPages<Page4K>, DeferredAllocAction<'static>), &'static str>
Expand description
The core page allocation routine that allocates the given number of virtual pages,
optionally at the requested starting VirtualAddress
.
This simply reserves a range of virtual addresses, it does not allocate
actual physical memory frames nor do any memory mapping.
Thus, the returned AllocatedPages
aren’t directly usable until they are mapped to physical frames.
Allocation is based on a red-black tree and is thus O(log(n))
.
Fragmentation isn’t cleaned up until we’re out of address space, but that’s not really a big deal.
Arguments
request
: whether to allocatenum_pages
pages at any address, at a specific virtual address, or withing a specified range.num_pages
: the number ofPage
s to be allocated.
Return
If successful, returns a tuple of two items:
- the pages that were allocated, and
- an opaque struct representing details of bookkeeping-related actions that may cause heap allocation.
Those actions are deferred until this returned
DeferredAllocAction
struct object is dropped, allowing the caller (such as the heap implementation itself) to control when heap allocation may occur.