Struct kalloc::buddy::BuddySystem [−][src]
#[repr(C)]pub struct BuddySystem<P> { /* fields omitted */ }
Expand description
Buddy System Allocator Structure.
Memory Layout
bitmap_begin page_begin page_end
| | |
v v v
+-------------+--------+-----------+-------------------+
| this struct | bitmap | (padding) | 2^max_order pages |
+-------------+--------+-----------+-------------------+
^
|
page_begin is a multiple of P
Implementations
impl<P: Unsigned + PowerOfTwo> BuddySystem<P>
[src]
impl<P: Unsigned + PowerOfTwo> BuddySystem<P>
[src]pub unsafe fn build(begin: usize, end: usize) -> Result<&'static mut Self, ()>
[src]
pub unsafe fn build(begin: usize, end: usize) -> Result<&'static mut Self, ()>
[src]Construct a buddy system allocator at memory [begin, end) with specific page size.
Notice that it guarantees safety only if the access to [begin, end) is safe
and self
is a static variable.
pub unsafe fn free(&mut self, ptr: *mut u8, order: usize) -> usize
[src]
pub unsafe fn free(&mut self, ptr: *mut u8, order: usize) -> usize
[src]Free the block of memory starting from ptr
with specific order.
Return the order of the freed page after merging possible buddy pages.