Crate keos_project2

Crate keos_project2 

Source
Expand description

§Project 2: Memory Management

In Project 2, you will expand your operating system with memory management system, forming the isolation boundary between user applications and the kenrel. This project builds upon the concepts from Project 1 and introduces key topics such as page tables, memory state management, and user program loading. By the end of this project, your kernel will be capable of running multiple user programs in an isolated, virtual memory environment.

§Getting Started

To begin, navigate to the keos-project2/grader directory and run:

$ cargo run

§Modifiable Files

In this project, you can modify the following six files:

  • page_table.rs
  • mm_struct.rs
  • eager_pager.rs
  • loader/mod.rs
  • loader/elf.rs
  • loader/stack_builder.rs

§Project Outline

This project consists of three major components:

  • Page Table: Implement an x86_64 page table mechanism to manage virtual memory and perform address translation for user processes.

  • Memory State: Develop memory state management and implement system calls for dynamic memory allocation and deallocation.

  • User Program Loader: Build a loader that loads ELF executables into memory, sets up the stack, and transitions into user mode execution.

Successfully completing this project will enable KeOS to run simple C programs, setting the stage for more complex user-space features in future projects.

§Debugging a User Process

Because KeOS’s internal backtrace only support for kernel’s virtual addresses, user program’s instruction address may be shown as unknown. For such cases, you may utilize addr2line utility to see which user mode codes are responsible for the error. For example, if you get the following error message:

User process ABORT at sys_mmap_err.c:14 in main(): assertion `write(1, NULL, 0x1000) < 0' failed.
Call stack: 0x402a83 0x401100 0x402a02
The `addr2line' program can make call stacks useful.
Read "Debugging a User Process" chapter in the
KeOS documentation for more information.

You translate the address to respective source code’s line by passing the program’s name and address to addr2line utility:

$ addr2line -e sys_mmap_err 0x402a83
../../kelibc/debug.c:29
$ addr2line -e sys_mmap_err 0x401100
userprog/sys_mmap_err.c:16

Re-exports§

pub use process::Process;

Modules§

eager_pager
Pager with Eager Paging Policy
loader
ELF Loading.
mm_struct
Memory State of a process
page_table
Four-Level Page Table of x86_64
pager
Pager, a trait for paging policy
process
The process model for project2

Enums§

SyscallNumber
Represents system call numbers used in project2