ros666::mm::frame_allocator

Struct StackFrameAllocator

Source
pub struct StackFrameAllocator {
    unused: Range<PhysicalPageNumber>,
    freed: Vec<PhysicalPageNumber>,
}
Expand description

栈帧分配器

基于栈的帧分配器,用于分配和释放物理页帧。

在栈帧分配器中,未使用的物理页帧范围是一个左闭右开的区间,表示从未使用的物理页帧的起始页号到结束页号的范围。

释放帧栈维护了一个已释放的物理页帧列表,当需要分配物理页帧时, 首先从已释放的物理页帧列表中弹出一个物理页帧,如果列表为空,则从未使用的物理页帧范围中分配一个物理页帧。

包含未使用的物理页帧范围和已释放的物理页帧列表。

Fields§

§unused: Range<PhysicalPageNumber>

未使用的物理页帧范围。

§freed: Vec<PhysicalPageNumber>

已释放的物理页帧列表。

Implementations§

Source§

impl StackFrameAllocator

Source

pub fn init(&mut self, range: Range<PhysicalPageNumber>)

初始化栈帧分配器

将未使用的物理页号范围设置为传入的范围

Source

pub fn init_frame_allocator()

初始化全局栈帧分配器

将未使用的物理页号范围设置为从内核结束地址到内存结束地址的范围

Source

pub fn alloc_frame() -> Option<FrameTracker>

从全局栈帧分配器分配一个物理页帧,并返回一个 FrameTracker 实例。

§返回

如果成功,返回一个 FrameTracker,否则返回 None。

Source

pub fn dealloc_frame(frame: PhysicalPageNumber)

从全局栈帧分配器释放一个物理页帧。

§参数
  • frame - 要释放的物理页帧。

Trait Implementations§

Source§

impl FrameAllocator for StackFrameAllocator

Source§

fn new() -> Self

创建一个新的帧分配器实例。 Read more
Source§

fn alloc(&mut self) -> Option<PhysicalPageNumber>

分配一个物理页帧。 Read more
Source§

fn dealloc(&mut self, frame: PhysicalPageNumber)

释放一个物理页帧。 Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.