I/O 端口(8/16地址):特殊命令,如IN/OUT reg, port 将I/O端口的数据读或写到CPU寄存器
内存映射I/O(内存地址):通用指令,同一总线。
本质:视作内存
优势:设备驱动可以用C语言写; 不需要单独的I/O保护机制;指令重用
劣势:内存的缓冲机制对于外设很危险
现状:结合使用,memory-mapped i/o用于数据寄存器,i/o端口用于指令寄存器
硬件保护
dual mode operation: 0 for 内核,1 for 用户。设置在硬件上。
privileged instructions:I/o 保护。包括所有I/o命令。仅在内核态执行。
memory protection:控制内存可访问的范围。base register and limit register。【base, base + limit)
cpu protection: 防止单程序一直占用CPU。计时器(counter register 和 holding register)
系统调用
操作系统提供给用户程序访问的接口。
call wapper of system call in C run-time(CRT) library -> store system call number -> trap into os -> get system call service routine by indexing a system call table using system call number -> run system call service routine and return to user programs ...
如何trap into os? exception(INT 0x80/0x2e) or special instruction(SYSENTER and SYSEXIT)