操作系统结构分析解析
1.5
Example
处理文档 电话铃响 暂停文档 文档中作暂停记号 电话交谈 找出暂停记号位置 继续处理文档
执行主程序(日常事务程序) 中断申请信号有效 (中断请求) 暂停执行主程序响应中断 当前PC及寄存器入栈(保护现场) 处理外设要求(中断服务) 寄存器及PC出栈(恢复现场及中断返回 ) 继续执行主程序
–
e.g., only higher-priority interrupts may be handled
resumes the interrupted program
Most modern OSes are interrupt-driven
Operating System Concepts – 6th Edition
Device controllers
I/O devices and the CPU can execute concurrently(并发). Each device controller is in charge of a particular device
type. Each device controller has a local buffer. CPU moves data from/to main memory to/from local buffers I/O is from the device to local buffer of controller. Device controller informs CPU that it has finished its operation by causing an interrupt.
Operating System Concepts – 6th Edition
1.2
The Hardware of a Modern Computer System
Operating System Concepts – 6th Edition
1.3
Computer-System Structures (1): Input/Output
After I/O starts, control returns to user program only upon I/O completion
triggered by special instructions in user program
Other than the above, handling of interrupts and traps is identical Traps are the hardware mechanism for implementing system calls
Operating System Concepts – 6th Edition
ቤተ መጻሕፍቲ ባይዱ
1.8
I/O Operation
Two approaches: Synchronous(同步) and Asynchronous(异步)
Operating System Concepts – 6th Edition
Operating System Concepts – 6th Edition
1.4
Interrupt Handling
Interrupts are “asynchronous(异步) requests for service”
signal on a wire connecting the devices preserves the present CPU state
When an interrupt occurs, the CPU
this includes its registers and program counter this may be dependent on the source of the interrupt(中断源) typically, table-driven: a table stores addresses of interrupt handlers
Operating System Concepts – 6th Edition
1.6
Interrupt Handling (contd.)
Operating System Concepts – 6th Edition
1.7
Interrupts vs. Traps
Interrupts
asynchronous(异步)
After I/O starts, control returns to user program without waiting for I/O completion
Triggered(触发) by devices outside the CPU Traps(陷阱) synchronous(同步)
memory, secondary storage, tape
Hardware support for protection different views: functional, components, services, structure
Operating-system structures
–
forces execution of code at an interrupt address
indexed by the interrupt number (ISR 中断服务程序)
interrupt handlers
perform the requested service selective processing of other interrupts
Chapter 2: Computer System and OS Structures
Chapter 2: Computer System and OS Structures
Computer-system structures
I/O structures Storage structures and hierarchy