comments
This commit is contained in:
parent
25a76fce29
commit
1bfdff2a76
2 changed files with 2 additions and 1 deletions
|
|
@ -34,6 +34,8 @@ impl AreaFrameAllocator {
|
||||||
|
|
||||||
fn choose_next_area(&mut self) {
|
fn choose_next_area(&mut self) {
|
||||||
self.current_area = self.areas.clone().filter(|area| {
|
self.current_area = self.areas.clone().filter(|area| {
|
||||||
|
// filter in areas with remaining free frames
|
||||||
|
// i.e. next_free_frame is before the last frame
|
||||||
let address = area.base_addr + area.length - 1;
|
let address = area.base_addr + area.length - 1;
|
||||||
Frame::containing_address(address as usize) >= self.next_free_frame
|
Frame::containing_address(address as usize) >= self.next_free_frame
|
||||||
}).min_by_key(|area| area.base_addr);
|
}).min_by_key(|area| area.base_addr);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ pub struct Frame {
|
||||||
|
|
||||||
pub const PAGE_SIZE: usize = 4096;
|
pub const PAGE_SIZE: usize = 4096;
|
||||||
|
|
||||||
|
|
||||||
impl Frame {
|
impl Frame {
|
||||||
fn containing_address(address: usize) -> Frame {
|
fn containing_address(address: usize) -> Frame {
|
||||||
Frame{ number: address / PAGE_SIZE }
|
Frame{ number: address / PAGE_SIZE }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue