课程链接:https://pdos.csail.mit.edu/6.828/2018/schedule.html
最新版课程链接:https://pdos.csail.mit.edu/6.828
课程仓库:https://pdos.csail.mit.edu/6.828/2018/jos.git
参考资料:https://pdos.csail.mit.edu/6.828/2018/reference.html
未完待续~~~
文章目录
- Lecture
- Lecture1 Operating Systems
- Lecture2 PC hardware and x86 programming
- Lecture3 C and gdb
- Lecture4 Shell & OS organization
- Lecture5 Isolation mechanisms
- Lecture6 Virtual Memory (1)
- Lecture7 Virtual Memory (2)
- Lecture8 Interrupts, System calls, and Exceptions
- Lecture9 Multiprocessors and locking
- Lecture10 Processes, threads, and scheduling
- Lab
- Homework
Lecture
Lecture1 Operating Systems
The purpose of an O/S
- Support applications
- Abstract the hardware for convenience and portability
- Multiplex the hardware among multiple applications
- Isolate applications in order to contain bugs
- Allow sharing among applications
- Provide high performance
Lecture2 PC hardware and x86 programming
EIP
- EIP is incremented after each instruction
- Instructions are different length
- EIP modified by CALL, RET, JMP, and conditional JMP
Registers
8个32-bit通用寄存器:%eax, %ebx, %ecx, %edx, %edi, %esi, %ebp, %esp
(32-bit可分为16-bit如%ax, %bx,16-bit可分为8bit如%al和%ah)
1个32-bit程序计数器:%eip
1个80-bit浮点寄存器
控制寄存器:%cr0, %cr2, %cr3, %cr4
调试寄存器:%dr0, %dr1, %dr2, %dr3
段寄存器:%cs, %ds, %es, %fs, %gs, %ss
全局和局部描述符表伪寄存器:%gdtr, %ldtr
Memory
movl %eax, %edx edx = eax register mode
movl $0x123, %edx edx = 0x123 immediate
movl 0x123, %edx edx = *(int32_t*)0x123 direct
movl (%ebx), %edx edx = *(int32_t*)ebx indirect
movl 4(%ebx), %edx edx = *(int32_t*)(ebx+4) displaced
Stack memory
pushl %eax = subl $4, %esp & movl %eax, (%esp)
popl %eax = movl (%esp), %eax & addl $4, %esp
call 0x12345 = pushl %eip(*) & movl $0x12345, %eip(*)
ret = popl %eip(*)
I/0 space and instructions
inb/outb
Memory-mapped I/O
GCC calling conventions
int main(void) {return f(8)+1; }
int f(int x) {return g(x); }
int g(int x) {return x+3; }
_main:
(prologue)
pushl %ebp
movl %esp, %ebp
(body)
pushl $8
call _f
addl $1, %eax
(epilogue)
movl %ebp, %esp
popl %ebp
ret
_f:
(prologue)
pushl %ebp
movl %esp, %ebp
(body)
pushl 8(%esp)
call _g
(epilogue)
movl %ebp, %esp
popl %ebp
ret
_g:
(prologue)
pushl %ebp
movl %esp, %ebp
(save %ebx)
pushl %ebx
(body)
movl 8(%ebp), %ebx
addl $3, %ebx
movl %ebx, %eax
(restore %ebx)
popl %ebx
(epilogue)
movl %ebp, %esp
popl %ebp
ret
Lecture3 C and gdb
Lecture4 Shell & OS organization
xv6 follows a traditional design: all of the OS runs in kernel mode
microkernel design
exokernel
Lecture5 Isolation mechanisms
Lecture6 Virtual Memory (1)
Lecture7 Virtual Memory (2)

UVPT/UVPD
Lecture8 Interrupts, System calls, and Exceptions
Lecture9 Multiprocessors and locking
Lecture10 Processes, threads, and scheduling
xv6 solution:
1 user thread and 1 kernel thread per process
1 scheduler thread per processor
xv6 has lots of kernel threads sharing the single kernel address space
xv6 has only one user thread per process
Overview of xv6 processing switching:
- user -> kernel thread (via system call or timer)
- kernel thread yields, due to pre-emption or waiting for I/O
- kernel thread -> scheduler thread
- scheduler thread finds a RUNNABLE kernel thread
- scheduler thread -> kernel thread
- kernel thread -> user
Lab
6.828:Lab1 Booting a PC 实验总结
6.828:Lab2 Memory Management 实验总结
6.828:Lab3 User Environments 实验总结
6.828:Lab4 Preemptive Multitasking 实验总结
6.828:Lab5 File system, Spawn and Shell 实验总结
6.828:Lab6 Network Driver 实验总结