Each lab has its own branch in the repository. Labs completed so far:
Prep -> Lec video&slides -> Lab
in retrospect, seems that simply taking all the pre-lecture readings seriouly will do (even for os new comers)
Completed whitin 3 months (part-time).
- 【0820】init repo && materials && setup
- 【0821】reading1+lec1
- 【0824】lab util
- 【0912】prep2, lec2(slidesOnly)
- 【0915】review concepts+labUtil, lec 3 prep + live
- 【0917】lab syscall
- 【0920+】prep3, lec4+5+6, lab pgtbl
- 【0928】preps, lec 7+8, lab traps
- 【0930】preps, lec 9, lab lazy
- 【1003】prep (ch6 & code), lec 10,
- 【1005】lab cow, prep11, lec 11, lab thread
- 【1011】prep, lab lock
- 【1013】prep fs, lec 14 & lec 15
- 【~1028】prep, lec 16, lab fs
- 【1030】prep, lec 17, 18
- 【1031】lab networking, lec 19, lec 20, FIN!
Prep
- chap 8
- code
lab fs:
- see notes
Prep:
- chapter 6&7
- code examples
lab thread + lock:
- see notes
Prep:
- chapter 4.6
- code pieces (trap.c, uart.c, plic.c, console.c)
Lab lazy alloc:
- see lab lazy notes
Prep:
- riscv calling convention
- lec5&6&7
Lab traps:
- see lab traps notes
Prep:
- xv6book Chap3
- kernel/memlayout.h, kernel/vm.c, kernel/kalloc.c, kernel/riscv.h, and kernel/exec.c
- Lec 3&4
Lab pgtbl (Page tables):
- see lab pgtbl notes
Prep:
-
pointers in K&R C programming
-
chap2, 4.3, 4.4 of xv6 book
-
syscall和process相关的源码
Lab syscall:
-
一开始想复杂了 实际上实现trace要做的只是:
- 给每个process打上"标签" ==>
- 并把这个标签传递给子进程 ==>
- 最后在syscall()时根据标签判断是否需要print trace
-
实现syscall:
- 【准备】完成各种文件里的函数/变量申明
sysproc.c
中call sysinfo()sysinfo.c
中,call nproc() 和freemem(),然后用copyout()把sysinfo拷贝到user处kernel/kalloc.c
中实现freemem() :统计free memory的大小(利用struc run统计N of free page,可以参考函数kalloc())kernel/proc.c
中实现nproc() :统计进程数量(穷举NPROC并判断struc proc里的state以计数)
Prep work: Read Chapter 1 of http://xv6.dgs.zone/
Lec:
Lab Util:
- Useful commands:
make qemu
: xv6 bootingctrl-a + x
: quit qemumake clean
: clean production filesctrl-p
: print information about each processmake grade
: local test for all commands./grade-lab-util someCommand
ormake GRADEFLAGS=someCommand grade
: runs the local tests for a specific command
- Reminder: dont forger to add command to
UPROGS
in Makefile - Error fix:
- [Mac M1]
make grade
reportsenv: python: No such file or directory
. Solution:ln -s $(which python3) /usr/local/bin/python
- 对于每个branch,需要在user/sh.c的runcmd函数前添加
__attribute__((noreturn))
,不然xv6启动会报错
- [Mac M1]
About How to use GDB https://zhuanlan.zhihu.com/p/354794701
-
make qemu-gdb
-
in another window && same dir:
riscv64-unknown-elf-gdb