Lecture 4: Virtual memory

Preparation

Download the source code of xv6.

git clone https://github.com/xiw/xv6.git

You should be able to build and run xv6 using make qemu or make qemu-nox, using the same tools for JOS.

Let’s do a quick exercise to get familiar with xv6. Recall that last week we used strace to observe the arguments and return values of Linux system calls. Modify xv6 to print out similar information (hint: syscall() in syscall.c). For example, you should see the following after booting:

...
fork() = 2
exec() = 0
open("console", 0x2) = 3
close(3) = 0
$write(2, "$", 1) = 1
 write(2, " ", 1) = 1

This is init forking and execing sh, sh making sure only two file descriptors are open, and sh writing the $ prompt.

Questions

Paging recap

Memory management overview in JOS