Struct kalloc::buddy::MultiBuddySystem[][src]

pub struct MultiBuddySystem<P> { /* fields omitted */ }
Expand description

Allocator that holds multiple buddy systems.

Implementations

impl<P: Unsigned + PowerOfTwo + 'static> MultiBuddySystem<P>[src]

pub const fn new() -> Self[src]

Create an empty multi-buddy system allocator.

pub unsafe fn add_zone(&mut self, begin: usize, end: usize)[src]

Add zone [begin, end) with page size into this allocator.

Note that size of the memory handled by one buddy system is requied to be a power of two. But this may waste a large amount of memory if it’s slightly smaller than a power of two. Thus, to make full use of the memory, we recursively build buddy systems on the memory left by previous buddy system and terminate when it fails to build.

This may add O(logN) buddy systems, where N = end - begin.

pub unsafe fn alloc1(&self, order: usize) -> *mut u8[src]

Allocate memory of 2^order pages.

Loop through every registered zone and try allocating. O(logN) per zone.

pub unsafe fn alloc(&self, layout: Layout) -> *mut u8[src]

Allocate memory according to layout.

pub unsafe fn free(&self, ptr: *mut u8, order: usize) -> usize[src]

Free memory pointed by ptr with specific layout.

Return the order of the freed page after merging possible buddy pages. Loop through every registered buddy system and try deallocating. O(logN) per zone.

pub unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)[src]

Free memory of specific layout.

pub unsafe fn check(&self)[src]

Check that buddy systems donot overlap with each other.

pub unsafe fn overlap(
    &self,
    begin: usize,
    end: usize,
    ignore: *mut BuddySystem<P>
) -> bool
[src]

Check that if memory [begin, end) is overlapped with any zone in the buddy system except the ignored one.

Auto Trait Implementations

impl<P> RefUnwindSafe for MultiBuddySystem<P>

impl<P> !Send for MultiBuddySystem<P>

impl<P> !Sync for MultiBuddySystem<P>

impl<P> Unpin for MultiBuddySystem<P>

impl<P> UnwindSafe for MultiBuddySystem<P>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.