Agenda

<aside> 📌 Reminders

Virtual vs Physical Memory

A physical memory address refers to a location on the actual hardware. We will never deal, modify, or even look at these types of addresses; they are completely under the control of the hardware (specifically the Memory Management Unit). There are many reasons for this distinction that you will cover in class (e.g. abstract, virtualization, etc), what’s important now is that we recognize this distinction.

Translation between from virtual to physical addresses are done by the MMU

pintOS adds another layer of distinction between user addresses and kernel addresses (both are still virtual addresses though!).

User addresses in PintOS refer to memory locations accessible by user processes, while kernel addresses are reserved for the OS itself. The kernel must handle transitions between these spaces carefully to maintain security and stability.

Memory is allocated in fixed-size chunks called pages, typically 4KB in size. This simplifies memory management and enables efficient use of hardware resources.

Address translation is done via page tables, which map virtual addresses to physical ones. The MMU consults these tables on every memory access, ensuring correct translation and enforcing protection mechanisms. You’ll explore how PintOS sets up and manages these mappings later in the course.

❓Tutorial Questions

Example of passing arguments:

Questions:

  1. Where are the command line arguments stored when they are initially passed into the program?
  2. When passing command-line arguments to a program, in which order should the arguments be pushed onto the user program stack?
  3. Which method is responsible for setting up the stack of a user program? In other words, when and where are the pages allocated for the user program?
  4. What is the (virtual) address of the beginning of the stack when the kernel thread is executing the user’s program in user mode (when running the user program for instance)?
  5. What is the (virtual) address of the beginning of the stack when the kernel thread is setting/accessing that stack in kernel mode (when executing a system call for instance)?