From 1bfdff2a766e3d3a1c0484c5ecc837f680ae4a1f Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 5 Feb 2018 20:15:08 +0100 Subject: [PATCH] comments --- kernel-rs/src/memory/area_frame_allocator.rs | 2 ++ kernel-rs/src/memory/mod.rs | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) 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 }