涉及到的部件:program counter,register,execution flags 和stack.
fetch, decode, execute, write, next PC
相关的register保存thread的context, rsp, base pointer, heap pointer,data等 当一个线程驻留在处理器的寄存器上时,它在该寄存器上运行.
一个线程的root state 放在寄存器上,其余放在内存里
the set of accessible addresss and state associate with it. 程序执行时会遇到的段: code segment,包含可执行指令,只读并且定长 Data segment :包含global ,static variable,还有string BSS, 存储unintialized, initialized 0 static Heap malloc stack 存放 autamatic variable 和return address
illusion of multiple processors: multiplex in time 每个virtual processor 都要维护一定状态: pc, sp, register 如何在virtual CPU之间进行转换: load 和store 怎样触发转换: Timer, voluntary yield, I/O, other
资源只有一个, hardware, i/o 每个线程都认为他们都对资源有着独一无二的拥有权, 系统需要处理进程,中断,i/o 最终采用vitrual machine abstraction 来进行抽象。
需要为该模型添加protection
primary mechanism:limit translation from program address space to physical address.
additional Mechanisms:
privileged instructions, inout instructions, special registers syscall processing, subsystem implementaiton
execution environment with restricted rights
address space with several threads owns file descriptors, file system context
hardware 至少提供俩种mode, user mode 和kernel mode hardware如何支持俩种mode:采用一些位的设置, 一些操作或行为只允许发生在kernel mode中,在user mode将导致trap 或者 fail
user 向 kernal 转化 system mode and save PC kernal 向user 转化 user mode restore PC protection的机制: base & bound , translation
syscall :
Hardware schedulinb technique
vector through defined syscall entry point locate local arguments: some in reg some in memory copy arguments:
from user mem to kernel mem validate arguments copy result back into user space
Interrupt processing non visble to the usr process
OS kernel may enable or disable interrupts: x86 CLI, STI 有atomic的操作: 选择下一个thread或者process去执行,或者由syscall,interrupt的返回 interrupt 有优先级, 可以通过mask off 禁止某些 interrupt, 有些interrupt是non maskable-interrupts(NMI:例如segmention fault, 如何安全