diff --git a/kernel-rs/src/memory/area_frame_allocator.rs b/kernel-rs/src/memory/area_frame_allocator.rs index 123aa879..3693f45d 100644 --- a/kernel-rs/src/memory/area_frame_allocator.rs +++ b/kernel-rs/src/memory/area_frame_allocator.rs @@ -34,6 +34,8 @@ impl AreaFrameAllocator { fn choose_next_area(&mut self) { 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; Frame::containing_address(address as usize) >= self.next_free_frame }).min_by_key(|area| area.base_addr); diff --git a/kernel-rs/src/memory/mod.rs b/kernel-rs/src/memory/mod.rs index a1358219..8cd88e6e 100644 --- a/kernel-rs/src/memory/mod.rs +++ b/kernel-rs/src/memory/mod.rs @@ -11,7 +11,6 @@ pub struct Frame { pub const PAGE_SIZE: usize = 4096; - impl Frame { fn containing_address(address: usize) -> Frame { Frame{ number: address / PAGE_SIZE }