Expand description
§Pager with Eager Paging Policy
The EagerPager is a concrete implementation of the Pager trait used
in Project 2 to manage memory mapping behavior during mmap system calls.
As its name implies, it follows an eager allocation strategy: physical
pages are allocated and mapped into the page table immediately at the
time of mmap, regardless of whether they are subsequently accessed.
This approach ensures that all virtual pages in the mapped region are backed
by initialized physical memory at the time of mapping. These pages are
typically zero-filled and mapped with the requested permissions (e.g., read,
write, execute). This simplifies the memory model and avoids page faults
after mapping, making EagerPager a useful baseline for implementing
memory management in early-stage systems like KeOS.
The paging interface is defined by the Pager trait, which abstracts the
core functionality for virtual memory: allocation (mmap), deallocation
(munmap), access resolution (get_user_page), and permission checking
(access_ok).
In later stages of KeOS (Project 3), you will implement demand paging using
LazyPager, which defers physical memory allocation until the first
access (e.g., page fault). That approach provides a more efficient
and realistic memory model used by modern operating systems.
§Memory Loading
The eager pager supports both anonymous and file-backed memory mappings.
Anonymous mappings in eager paging are typically backed by
zero-initialized memory. On the other side, when mapping a file-backed
page, the RegularFile::mmap method must be used to register the
mapping. In Project 5, you will extend this method with the page cache,
a core mechanism that allows shared, read-consistent access to file data
across processes. Although EagerPager currently does not utilize the
page cache, the RegularFile interface and paging trait are designed to
accommodate it cleanly for future extensions.
Note that, KeOS does not provide write-back behavior for the file-backed pages.
§Implementation Requirements
You need to implement the followings:
By implementing the eager pager, your kernel now have sufficient
functionalities to load user program in the next section.
Structs§
- Eager
Pager EagerPageris a struct that implements thePagertrait. It represents a pager strategy that is responsible for eager memory paging.- Mapping
- Represent a mapping of contiguous memory.