- 🥂课程资料
- 🥞本仓库资源
- 🍱课程索引
- LEC 1 (rtm): Introduction and examples
- LEC 2 (TAs/dm): C and gdb
- LEC 3 (fk): OS organization and system calls
- LEC 4 (fk): Page tables
- LEC 5 (TAs/nk): Calling conventions and stack frames RISC-V
- LEC 6 (rtm): Isolation & system call entry/exit
- LEC 7 (fk): Q&A labs
- LEC 8 (fk): Page faults
- LEC 9 (fk): Interrupts
- LEC 10 (fk): Multiprocessors and locking
- LEC 11 (rtm): Thread switching
- LEC 12 (rtm): Q&A labs
- LEC 13 (rtm): sleep&wakeup and code
- LEC 14 (fk): File systems
- LEC 15 (fk): Crash recovery
- LEC 16 (rtm): File system performance and fast crash recovery
- LEC 17 (fk): Virtual memory for applications
- LEC 18 (rtm): OS Organization
- LEC 19 (rtm): Virtual Machines
- LEC 20 (fk): Kernels and HLL
- LEC 21 (rtm): Networking
- LEC 22 (rtm): Meltdown
- LEC 23 (rtm): RCU
- LEC 24 (fk): Q&A
- 🥪Lab 笔记索引
实际上,这门课就是大名鼎鼎的 MIT 6.828 ,只不过2020年课号改成了 6.S081 。
官方课程安排与资源索引:
中文文档与翻译:
B 站视频:
实验:
- 本课程用到
xv6
系统,我从GitHub
上fork
了一个:https://github.com/PiperLiu/xv6-riscv - 本课程进行实验的作业系统:
git clone git://g.csail.mit.edu/xv6-labs-2020
- Lab 的心得笔记汇总可以参考: ./lab.md
参考:
- 教材(主要用作预习):xv6: a simple, Unix-like teaching operating system
- 其他的资源比如课堂资料、作业要求在docs/assignment/和docs/lec/中
- 实验说明:6.S081 _ Fall 2020.html
sep 2
- LEC 1 (rtm): Introduction and examples (handouts: xv6 book) video
- Preparation: Read chapter 1 (for your amusement: Unix)
- Homework 1 due: Question
- Assignment: Lab util: Unix utilities
我认真读了书(第一张,一些 Unix 6 接口简单原理与使用),记了笔记:./docs/drafts/lec.01.md。
然后听课,课堂笔记:./docs/drafts/lec.01c.md
本节作业笔记:./docs/drafts/lec.01hw.md
sep 9
- LEC 2 (TAs/dm): C and gdb (pointers example)
- Preparation: 2.9 (Bitwise operators) and 5.1 (Pointers and addresses) through 5.6 (Pointer arrays) and 6.4 (pointers to structures) by Kernighan and Ritchie (K&R)
- Assignment: Lab syscall: System calls
课前预习,读书:./docs/drafts/lec.02.md
- C 的读书笔记
- Using the GNU Debugger
- 读书: Chapter 2 Operating system organization
- 2.1 Abstracting physical resources
- 2.2 User mode, supervisor mode, and system calls ( ecall 是 RISC-V CPU 用于从用户态转为内核态的指令)
- 2.3 Kernel organization
- 2.4 Code: xv6 organization
- 2.5 Process overview 进程与页表
- 2.6 Code: starting xv6 and the first process
- 插曲:内联汇编的格式
- 仔细阅读 start 发现是把汇编操作封装
- 2.7 Real world
- 插曲:安装 riscv64-unknown-elf-gdb
- 2.8 Exercises 尝试 gdb
- 读书: Chapter 4 Traps and system calls
- 阅读一些代码
这节课就是读书课,留了个 lab ,下节课听完再做。
- LEC 3 (fk): OS organization and system calls (boards) video
- Preparation: Read chapter 2 and xv6 code: kernel/proc.h, kernel/defs.h, kernel/entry.S, kernel/main.c, user/initcode.S, user/init.c, and skim kernel/proc.c and kernel/exec.c
这节课需要预习的东西和上节课一样。
听课笔记在这里:./docs/drafts/lec.03c.md
- Isolation / Kernel mode / User mode / System calls
- 硬件对于强隔离的支持
- 宏内核 vs 微内核 (Monolithic Kernel vs Micro Kernel)
- 编译运行kernel
然后把 lab 2 做了吧:./docs/drafts/lec.03hw.md
sep 16
- LEC 4 (fk): Page tables (boards) video
- Preparation: Read Chapter 3 and kernel/memlayout.h, kernel/vm.c, kernel/kalloc.c, kernel/riscv.h, and kernel/exec.c
- Assignment: Lab pgtbl: Page tables
课前预习是读书第三章,我的笔记在这了:./docs/drafts/lec.04.md
lab 3 地址如下:./docs/drafts/lec.04hw.md
这个实验对我来讲真的是难,断断续续做了五天。做完后,发现其实真的很简单:只要捋清了页表在哪里会被创建(与进程被创建、被 fork 、被扩容有关),在哪里被取消映射、取消哪里的映射。实际上,由于这个操作系统的优秀设计,把用户虚拟地址和内核虚拟地址放在一个页表上完全不会冲突。
sep 21
- LEC 5 (TAs/nk): Calling conventions and stack frames RISC-V (slides) video
- Preparation: Read Calling Convention
课前读书是关于 the C compiler standards for RV32 and RV64 programs ,读书笔记在此:./docs/drafts/lec.05.md
sep 23
- LEC 6 (rtm): Isolation & system call entry/exit (video)
- Preparation: Read Chapter 4, except 4.6 and kernel/riscv.h, kernel/trampoline.S, and kernel/trap.c
- Assignment: Lab traps: Trap
课前读书笔记在这里:./docs/drafts/lec.06.md
课堂笔记在这里:./docs/drafts/lec.06c.md
lab 先不做,先把下节课答疑听了再做。
sep 28
一些课堂笔记:./docs/drafts/lec.07c.md
好了,现在把 Lab traps: Trap 给做了吧,笔记:./docs/drafts/lec.07hw.md
sep 30
- LEC 8 (fk): Page faults (boards) video
- Preparation: Read Section 4.6
- Assignment: Lab lazy: Lazy allocation
读了一个小节,与课堂内容有很多重叠,不详细记录了:./docs/drafts/lec.08.md
- page fault 课程内容概述
- Lazy page allocation (sbrk)
- Zero Fill On Demand
- Copy On Write Fork
- Demand paging
- Memory Mapped Files
lab 就是设计一个 lazy allocation ,挺简单的:./docs/drafts/lec.08hw.md
oct 5
- LEC 9 (fk): Interrupts (boards) video
- Preparation: Read Chapter 5 and kernel/kernelvec.S, kernel/plic.c, kernel/console.c, kernel/uart.c, kernel/printf.c
课前预习读读书:./docs/drafts/lec.09.md
- 真实操作系统内存使用情况
- Interrupt硬件部分
- Interrupt软件部分
- 详细看UART驱动实现
- Interrupt相关的并发(对buffer的producer/consumer并发)
- UART读取键盘输入
- Interrupt的演进(引出polling)
好了,在进入 Multiprocessors and locking 之前,先把 page allocation 的内容解决掉,把 Lab 6 Copy-on-Write Fork for xv6 写了:./docs/drafts/lec.09hw.md
oct 7
- LEC 10 (fk): Multiprocessors and locking (boards) video
- Preparation: Read "Locking" with kernel/spinlock.h and kernel/spinlock.c
- Assignment: Lab cow: Copy-on-write fork
这个 Lab 上节课写完了。
读书预习一下:./docs/drafts/lec.10.md
oct 14
- LEC 11 (rtm): Thread switching (video)
- Preparation: Read "Scheduling" through Section 7.4, and kernel/proc.c, kernel/swtch.S
- Assignment: Assignment: Lab thread: Multithreading
课前预习把书 7.4 读了:./docs/drafts/lec.11.md
作业很简单:./docs/drafts/lec.11hw.md
oct 19
- LEC 12 (rtm): Q&A labs (video)
这节课不记录了。
oct 21
- LEC 13 (rtm): sleep&wakeup and code (video)
- Preparation: Read remainder of "Scheduling", and corresponding parts of kernel/proc.c, kernel/sleeplock.c
- Assignment: Lab lock: Parallelism/locking
读书收获总是很小,因此先把课听了,之后有什么问题再查书。听课笔记:./docs/drafts/lec.13c.md
- 线程切换过程中锁的限制
- 通过Sleep与Wakeup实现Coordination
- sleep函数为什么需要一个锁使用作为参数传入
- Pipe 中的 sleep 和 wakeup
- 一些 Coordination 相关的系统调用
- 个人总结: sleep 与 spinlock 的区别
课上没讲的信号量 semaphore ,读书看看:./docs/drafts/lec.13.md
把实验做了吧:./docs/drafts/lec.13hw.md
oct 26
- LEC 14 (fk): File systems (boards) (video)
- Preparation: Read kernel/bio.c, kernel/fs.c, kernel/sysfile.c, kernel/file.c and "File system" (except for the logging sections)
先把课听了:./docs/drafts/lec.14c.md
趁热打铁,把下节课课后 Lab fs: File system 写了吧:./docs/drafts/lec.14hw.md
oct 28
- LEC 15 (fk): Crash recovery (boards) video
- Preparation: Read kernel/log.c and the logging sections of "File system"
- Assignment: Lab fs: File system
这个 Lab 在上节课课后写了。
首先先把课听了:./docs/drafts/lec.15c.md
- File System Crash 概述
- File System Crash 示例
- File System Logging
- 从代码看 logging 机制
- File System Challenges
nov 2
- LEC 16 (rtm): File system performance and fast crash recovery (video)
- Preparation: Read Journaling the Linux ext2fs Filesystem (1998)
nov 4
- LEC 17 (fk): Virtual memory for applications (boards) (sqrt example) (baker example) video
- Preparation: Read Virtual Memory Primitives for User Programs (1991)
- Assignment: Lab mmap: Mmap
- 应用程序使用虚拟内存所需要的特性
- 支持应用程序使用虚拟内存的系统调用
- 虚拟内存系统实现
- Baker's Real-Time Copying Garbage Collector 垃圾回收机制
- 总结:应该使用虚拟内存吗?
把 mmap 系统调用 map 做了吧:./docs/drafts/lec.17hw.md
nov 9
- LEC 18 (rtm): OS Organization (video)
- Preparation: Read The Performance of micro-Kernel-Based Systems (1997)
nov 16
- LEC 19 (rtm): Virtual Machines (video)
- Preparation: Read Dune: Safe User-level Access to Privileged CPU Features (2012)
- Virtual Machine 虚拟机概述
- Trap-and-Emulate
- 硬件对虚拟机的支持(以 Intel VT-x 为例)
- Dune: Safe User-level Access to Privileged CPU Features
nov 18
- LEC 20 (fk): Kernels and HLL (slides) video
- Preparation: Read the Biscuit paper (2018), FAQ
- Assignment: Lab net: Network stack
先把课听了:./docs/drafts/lec.20c.md
lab 下节课听完再做。
nov 30
- LEC 21 (rtm): Networking (video)
- Preparation: Read Receive Livelock (1996)
这节课很重要,收获很大,让你彻底理解网络分层、协议栈:./docs/drafts/lec.21c.md
把最后一个 lab 写了:./docs/drafts/lec.21hw.md
dec 2
- LEC 22 (rtm): Meltdown (video)
- Preparation: Read Meltdown (2018)
dec 7
- LEC 23 (rtm): RCU notes, 2018 slides (video)
- Preparation: Read RCU paper (2013), FAQ
dec 9
- LEC 24 (fk): Q&A (video)
最后的内容,没什么可记录的。所有的 lab 都已经 bug-free 并且 make grade 满分。
🎉 完结撒花!
原地址: https://github.com/PiperLiu/xv6-labs-2020 (已经设为 private)
具体笔记索引、 Lab 配置见: ./lab.md