pub struct StackFrameAllocator {
unused: Range<PhysicalPageNumber>,
freed: Vec<PhysicalPageNumber>,
}Expand description
栈帧分配器
基于栈的帧分配器,用于分配和释放物理页帧。
在栈帧分配器中,未使用的物理页帧范围是一个左闭右开的区间,表示从未使用的物理页帧的起始页号到结束页号的范围。
释放帧栈维护了一个已释放的物理页帧列表,当需要分配物理页帧时, 首先从已释放的物理页帧列表中弹出一个物理页帧,如果列表为空,则从未使用的物理页帧范围中分配一个物理页帧。
包含未使用的物理页帧范围和已释放的物理页帧列表。
Fields§
§unused: Range<PhysicalPageNumber>未使用的物理页帧范围。
freed: Vec<PhysicalPageNumber>已释放的物理页帧列表。
Implementations§
Source§impl StackFrameAllocator
impl StackFrameAllocator
Sourcepub fn init(&mut self, range: Range<PhysicalPageNumber>)
pub fn init(&mut self, range: Range<PhysicalPageNumber>)
初始化栈帧分配器
将未使用的物理页号范围设置为传入的范围
Sourcepub fn init_frame_allocator()
pub fn init_frame_allocator()
初始化全局栈帧分配器
将未使用的物理页号范围设置为从内核结束地址到内存结束地址的范围
Sourcepub fn alloc_frame() -> Option<FrameTracker>
pub fn alloc_frame() -> Option<FrameTracker>
Sourcepub fn dealloc_frame(frame: PhysicalPageNumber)
pub fn dealloc_frame(frame: PhysicalPageNumber)
Trait Implementations§
Source§impl FrameAllocator for StackFrameAllocator
impl FrameAllocator for StackFrameAllocator
Auto Trait Implementations§
impl Freeze for StackFrameAllocator
impl RefUnwindSafe for StackFrameAllocator
impl Send for StackFrameAllocator
impl Sync for StackFrameAllocator
impl Unpin for StackFrameAllocator
impl UnwindSafe for StackFrameAllocator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more