Partial chapter 2 summary.
This commit is contained in:
parent
fed8339de9
commit
d2beeaa0c9
1 changed files with 57 additions and 0 deletions
57
notes/chapter2-os-organization
Normal file
57
notes/chapter2-os-organization
Normal file
|
@ -0,0 +1,57 @@
|
|||
XV6 as most OSs is monolithic, preemptive and time-sharing multiplexing.
|
||||
|
||||
Isolation comes from the CPU which provides machine, supervisor and user modes.
|
||||
|
||||
- machine: just for the boot time
|
||||
- supervisor: each time the kernel is active
|
||||
including when calling a syscall (with `ecall` in RISC-V)
|
||||
- user: for all user code
|
||||
|
||||
Minix, L4 (seL4) and QNX operating systems have been mentioned as micro-kernel OSs.
|
||||
|
||||
Memory layout of a process:
|
||||
[text; data; user stack; heap (large) ; trapframe; trampoline]
|
||||
0 ↑------------------------------------------------------------↑ 2^38-1
|
||||
|
||||
text: instructions
|
||||
data: global variables
|
||||
heap: explicitly allocated memory
|
||||
trapframe: saved process registers when switching in and out of the kernel
|
||||
trampoline (4 KiB): code to transition in and out of the kernel
|
||||
|
||||
trapframe & trampoline: explained in chapter 4
|
||||
|
||||
kernel `proc` structure contains:
|
||||
|
||||
- (kstack) kernel stack used when the process calls for syscalls
|
||||
- (pagetable) pointers to physical memory pages actually used by the process,
|
||||
provided to the hardware for translation (virtual @ ←→ physical @)
|
||||
- (state) UNUSED, USED, SLEEPING, RUNNABLE, RUNNING or ZOMBIE
|
||||
- (trapframe) saved process registers when switching in and out of the kernel
|
||||
- (pid) process identification number
|
||||
- (ofile) list of opened files
|
||||
- (name) process name
|
||||
- (cwd) current directory
|
||||
- (context) kernel registers used to enter the process
|
||||
- (sz) size of process's memory
|
||||
- (parent) pointer to the process's parent proc structure
|
||||
- (xstate) exit status (given to its parent when it "waits" for it)
|
||||
- (killed) non-zero when the process has been killed
|
||||
- (chan) TODO: not currently explained
|
||||
- (lock) TODO: not currently explained
|
||||
|
||||
|
||||
RISC-V instructions
|
||||
|
||||
- ecall: raise hardware privilege level
|
||||
program counter change to a kernel-defined entry point which then switches to the
|
||||
process's kernel stack and executes kernel instructions for this syscall
|
||||
once done, the kernel calls sret
|
||||
- sret: lower hardware privilege level
|
||||
|
||||
A process is the abstraction of memory and CPU for a running program,
|
||||
giving it the illusion of being alone on the hardware.
|
||||
A process is:
|
||||
|
||||
- an address space to give a running program the illusion of owning the entire memory
|
||||
- a thread to give a running program the illusion of having a CPU for himself
|
Loading…
Add table
Reference in a new issue