Contents
xv6 general information
xv6 is a teaching operating system built by MIT. It is based on Sixth Edition Unix, which was originally built for the PDP-11. Unlike Sixth Edition Unix, it runs on x86 and supports multiple cores.
The authors of xv6 have written a detailed book with commentary on it (which refers to line numbers in a corresponding source code printout), which we strongly recommend referring to. You can also see the authors’ explanation of why they wrote xv6.
The version of xv6 we will be using has some changes from the original:
- a
yield
system call is added - a
shutdown
utility and system call is added (only works in qemu) - the default number of cores to run with is changed to 1
- user programs are linked against libgcc.a, so things like long long will work; this means, however, that some modifications will be needed to build this version of xv6 with clang or other compilers.
- the
V2P
,P2V
,PTE_ADDR
, andPTE_FLAGS
macros are changed into static inline functions which provide slightly better error checking - the Makefile is modified so assembly files depend on their #include’d files
- the FSSIZE value in param.h was increased
- the Makefile was modified to delete intermediate files, so a failed
mkfs
does not leave behind a filesystem image mkfs
was modified to give more consistent and informative errors when it runs out of space in the disk image- CFLAGS are modified to change the optimization level to
-Og
(optimize for debugging) to enable-fno-delete-null-pointer-checks
- a Makefile target to aid in submission is added.
- the linker script is updated to avoid a problem with recent versions of binutils
ld
that prevented xv6 from botting with some recent Linux versions (including Arch Linux)
A copy of that version of xv6 is available via
git clone https://github.com/uva-reiss-cs4414/xv6.git
files in xv6
To help navigate the xv6 source code a brief explanation of some selected files:
- shared user/kernel header and utility files
types.h
,fcntl.h
,stat.h
- utility (non-xv6) programs
mkfs.c
— create filesystem images so xv6 can boot in qemu
- user-mode code
user.h
— declarations of system call wrappers and standard library functionsusys.S
— assembly code (generated by preprocessor macros) for system call wrappersulib.c
,printf.c
,umalloc.c
— user mode standard library, includingprintf
,malloc,
free`, …- supplied xv6 programs
cat.c
,echo.c
,forktest.c
,grep.c
,init.c
,kill.c
,ln.c
,ls.c
,mkdir.c
,rm.c
,sh.c
,shutdown.c
,stressfs.c
,usertests.c
,wc.c
,zombie.c
- kernel-mode code: everything else
defs.h
— declarations of functions callable within the kernelparam.h
— declarations of hard-coded limits (like number of file descriptors per process)- process-related:
proc.h
,proc.c
exec.c
,elf.h
— loading executables into memoryfile.h
,file.c
,pipe.c
, — file/file descriptor handling related code
- memory management:
mmu.h
,vm.c
,kalloc.c
- multicore
mp.c
,mp.h
- synchronization
spinlock.h
,spinlock.c
,sleeplock.h
,sleeplock.c
- exception/trap handling:
traps.h
, trap.c,
trapasm.S,
ioapic.c,
lapic.c,
picirq.c`,
- system call handling
syscall.h
,syscall.c
— system call handling/dispatch codesysproc.c
— process-related system call implementationssysfile.c
— file-related system call implementationskshutdown.c
,
- I/O
buf.h
, bio.c,
console.c,
ide.c,
kbd.h,
kbd.c,
memide.c,
uart.c`
- filesystem:
fs.h
,fs.c
,log.c
,
- boot handling
bootmain.c
,bootasm.S
,main.c