操作系统教学课件OS13
*
**
A Typical PC Bus Structure (P497)
*
**
Registers on ports (P498)
An I/O port typically consists of four registers, called the status, control, data-in, and data-out registers. I/O端口通常有四种寄存器:
*
**
Interrupts (P499)
IRL _interrupt request line_中断请求线 CPU在执行完每条指令后,都将判断IRL,当CPU检测已经有控制器通过中断请求线发送了信号, CPU将保留少量状态如当前指令位置,并且跳转到内存特定的位置的中断处理程序。 中断处理程序判断中断原因,进行必要的处理
状态寄存器 控制寄存器 数据输入寄存器 数据输出寄存器
*
**
13.2.1 Polling轮询(P499)
主机与控制器之间的协调如下: 主机不断地读取忙位,直到该位被清除。 主机设置命令寄存器中的写位并向数据输出寄存器写入一个字节。 主机设置命令就绪位。 当控制器注意到命令就绪位已被设置,则设置忙位。 控制寄存器读取命令寄存器,并看到写入命令。它从数据输出寄存器中读取一个字节,并向设备执行I/O 操作。 控制寄存器清除命令就绪位,清除状态寄存器的故障位以表示设备的I/O成功,清除忙位以表示完成。
The role of OS in computer I/O is to: Manage and control I/O operations and I/O devices
*
**
Chapter 13: I/O Systems
Overview I/O Hardware
Polling, Interrupts,DMA Application I/O Interface Kernel I/O Subsystem Performance
This challenge is met by a combination of software and hardware techniques. T: ports, buses and device controllers. (I/O设备基本要素:端口,总线和设备控制器。)
操作系统教学课件OS_13
Chapter 13: I/O Systems (P496)
The two main jobs of a computer: I/O and processing. ( I/O操作和计算处理) E.g.: browsing websites, editing files.
*
**
end
*
**
谢谢!
Character-stream or block(字符流或者块设备) Sequential or random-access(顺序或随机设备) Sharable or dedicated(共享或独占设备) Speed of operation(操作速度的不同) read-write, read only, or write only(读写,只读,只写)
*
**
Kernel I/O Subsystem (I/O内核子系统) (P511)
Scheduling Some I/O request ordering via per-device queue Some OSs try fairness
Buffering - store data in memory while transferring between devices To cope with device speed mismatch (失谐) To cope with device transfer size mismatch To maintain “copy semantics”
*
**
Interrupts
CPU Interrupt request line triggered(触发)by I/O device. Interrupt handler receives interrupts. Maskable (可屏蔽的) to ignore or delay some interrupts.
*
**
13.1 Overview (P496)
I/O设备技术呈现两个矛盾的趋势, Increasing standardization of software and hardware interface. (标准化)--这一趋势有助于将众设备集成到 计算机操作系统。 Increasingly broad variety of I/O devices. (多样性)--有的设备与以前的设备区别很大以至于难以集成到 计算机和操作系统中。
*
**
13.2 I/O Hardware Basic names (P496)
Incredible variety of I/O devices Common concepts
Port端口: a connection point that the device communicates with the machine via. 设备与计算机通讯的连接 点 Bus (daisy chain or shared direct access): a set of wires and a rigidly defined protocol that specifies a set of messages that can be sent on the wires.是一组线和严格定义的可以描述在线上传输信息的协议。 Controller (host adapter主机适配器): a collection of electronics that can operate a port, a bus, or a device.用 于操作端口,总线或设备的一组电子器件 I/O instructions control devices Devices have addresses, used by (设备的寻址方式) Direct I/O instructions Memory-mapped I/O
*
**
Improving Performance
Reduce number of context switches Reduce data copying Reduce interrupts by using large transfers, smart controllers, polling Use DMA Balance CPU, memory, bus, and I/O performance for highest throughput(吞吐量)
*
**
A Kernel I/O Structure (P506)
*
**
Characteristics of I/O Devices (P507)
*
**
Blocking and Nonblocking I/O (P510)
系统调用的接口还同阻塞与非阻塞I/O的选择有关。 Blocking - process suspended until I/O completed
*
**
Six Step Process to Perform DMA Transfer (P504)
*
**
Application I/O Interface (P505)
I/O system calls encapsulate device behaviors in generic classes. I/O系统调用将设备行为封装成通用类别 Device-driver layer hides differences among I/O controllers from kernel. (设备驱动层对核心隐藏了I/O控制器 的不同) Devices vary in many dimensions(设备变化范围非常大)
*
**
Interrupt-Driven I/O Cycle
Direct Memory Access (P503)
主机向内存写入DMA控制块(包括传输的源地址指针,传输的目的地址指针,传输的字节数)。 CPU将该命令块的地址写入到DMA控制器后,就继续其他工作。 DMA控制器直接操作内存总线开始传输。
Easy to use and understand Insufficient for some needs Nonblocking - I/O call returns as much as available User interface, data copy (buffered I/O) Implemented via multi-threading Returns quickly with count of bytes read or written