Chap 12: I/O Systems(I/O系统)

Download Report

Transcript Chap 12: I/O Systems(I/O系统)

Chapter 12
I/O Systems(I/O系统)
Applied Operating System Concepts
12.1
Content (内容)
Overview (概述)
I/O hardwared(I/O硬件)
Application I/O Interface(应用程序I/O接口)
Kernel I/O Subsystem(核心I/O子系统)
Transforming I/O Requests to Hardware Operations
(转换I/O请求为硬件操作)
Performance(性能)
Summary(总结)
Applied Operating System Concepts
12.2
Overview(概述)
the task of I/O subsystem(I/O子系统的任务)
Device-Driver Modules(设备驱动模式)
Device Independency(设备无关性)
Virtual Device(虚拟设备)
The structure of I/O subsystem(I/O子系统结构)
Applied Operating System Concepts
12.3
I/O Hardware(I/O硬件)
Incredible variety of I/O devices(难以置信的I/O设备种类)
Common concepts(基本概念)
Port (端口)
Bus (daisy chain or shared direct access)
(总线:菊花链或者共享总线)
Controller (host adapter)(控制器,主机适配器)
I/O instructions control devices(I/O指令控制设备)
Devices have addresses, used by (设备的寻址方式)
Direct I/O instructions(直接I/O指令)
Memory-mapped I/O(存储器映射I/O指令)
Applied Operating System Concepts
12.4
I/O Hardware(I/O硬件)
Applied Operating System Concepts
12.5
多样的I/O设备
Applied Operating System Concepts
12.6
Polling(轮询)
Determines state of device (决定设备的状态)
command-ready(等待命令)
Busy(忙)
Error(错误)
Busy-wait cycle to wait for I/O from device
(忙等待循环等待设备的I/O操作)
Applied Operating System Concepts
12.7
Interrupts(中断)
CPU Interrupt request line triggered by I/O device
(CPU的中断需要有I/O设备的触发)
Interrupt handler receives interrupts
(中断处理例程接收中断)
Maskable to ignore or delay some interrupts
(通过屏蔽来忽略或者延迟某些中断)
Interrupt vector to dispatch interrupt to correct handler
(中断向量给中断分配正确的中断处理例程)
Based on priority(以优先级为基础)
Some unmaskable(某些中断不可屏蔽)
Interrupt mechanism also used for exceptions
(中断机制也用在异常)
Applied Operating System Concepts
12.8
Interrupt-drive I/O Cycle
(中断驱动的I/O循环)
Applied Operating System Concepts
12.9
Direct Memory Access(直接内存存取)
Used to avoid programmed I/O for large data movement
(用来避免编程I/O来传输大量的数据)
Requires DMA controller(需要DMA控制器)
Bypasses CPU to transfer data directly between I/O device
and memory (绕过CPU来在I/O设备和内存之间直接传输数据)
Applied Operating System Concepts
12.10
Six step process to perform DMA transfer
(通过六步来完成DMA传输)
Applied Operating System Concepts
12.11
Application I/O Interface
(应用程序I/O接口)
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(设备变化范围非常大)
Character-stream or block(字符流或者块设备)
Sequential or random-access(顺序或随机设备)
Sharable or dedicated(共享或独占设备)
Speed of operation(操作速度的不同)
read-write, read only, or write only(读写,只读,只写)
Applied Operating System Concepts
12.12
Block and Character Devices
(块或字符设备)
Block devices include disk drives(块设备包括磁盘)
Commands include read, write, seek
(命令包括读,写,搜寻)
Raw I/O or file-system access
(原始的I/O或文件系统存取)
Memory-mapped file access possible
(存储器映射文件访问的可能性)
Character devices include keyboards, mice, serial ports
(字符设备包括键盘,鼠标和串口设备)
Commands include get, put(命令有get,put)
Libraries layered on top allow line editing
(顶层的函数库允许行编辑)
Applied Operating System Concepts
12.13
Network Devices(网络设备)
Varying enough from block and character to have own
interface
(从块设备和字符设备变化而来,有独自的接口)
Unix and Windows/NT include socket interface
(Unix和Windows/NT包括socket接口)
Separates network protocol from network operation
(分离网络协议于网络操作)
Includes select functionality(包括select功能)
Approaches vary widely (pipes, FIFOs, streams, queues,
mailboxes)(方式广泛:管道,FIFOs,流,队列,邮箱)
Applied Operating System Concepts
12.14
Clocks and Timers(时钟和记时器)
Provide current time, elapsed time, timer
(提供当前的时间,经过的时间,计时器)
if programmable interval time used for timings, periodic
interrupts(如果把可编程的时间间隔用于计时,那么定期中断)
ioctl (on UNIX) covers odd aspects of I/O such as clocks
and timers
(在UNIX中,ioct1掩盖了I/O设备(象时钟和计时器)之间区别)
Applied Operating System Concepts
12.15
Blocking and Nonblocking I/O
阻塞和非阻塞I/O
Blocking - process suspended until I/O completed
(阻塞—进程挂起直到I/O完成)
Easy to use and understand(容易使用和理解)
Insufficient for some needs(在某些场合没有效率)
Nonblocking - I/O call returns as much as available
(非阻塞—I/O调用返回一个代表是否成功的值)
User interface, data copy (buffered I/O)
(用户界面,数据拷贝(对I/O缓冲))
Implemented via multi-threading(通过多线程来实现)
Returns quickly with count of bytes read or written
(迅速的返回读写的字节数)
Asynchronous - process runs while I/O executes
(异步:在I/O处理的时候进程同时运行)
Difficult to use(难以使用)
I/O subsystem signals process when I/O completed
(当I/O操作完成的时候,I/O子系统向进程发信号)
Applied Operating System Concepts
12.16
Kernel I/O Subsystem(核心I/O子系统)
Scheduling(调度)
Some I/O request ordering via per-device queue
(某些I/O需要按设备队列的顺序)
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”
(为了维持拷贝语句的语义要求)
Applied Operating System Concepts
12.17
Kernel I/O Subsystem(核心I/O子系统)
Caching - fast memory holding copy of data
(高速缓存—存放数据的快速存储器)
Always just a copy(总是数据的拷贝)
Key to performance(性能的关键)
Spooling - hold output for a device
(spooling—保存设备的输出)
If device can serve only one request at a time
(如果设备一次只能服务于一个请求)
i.e., Printing(比如,打印机)
Device reservation - provides exclusive access to a device
(设备预定—提供对设备的独占访问)
System calls for allocation and deallocation
(分配和再分配的系统调用)
Watch out for deadlock(小心死锁)
Applied Operating System Concepts
12.18
Error Handling(错误处理)
OS can recover from disk read, device unavailable, transient
write failures
(操作系统可以恢复磁盘读,设备无效,暂时的失败)
Most return an error number or code when I/O request fails
(当I/O失败时,大多数返回一个错误码 )
System error logs hold problem reports
(系统日志记录了出错报告)
Applied Operating System Concepts
12.19
Kernel Data Structures
(核心数据结构)
Kernel keeps state info for I/O components, including open
file tables, network connections, character device state
(核心保存着I/O组件的状态,包括打开文件表,网络连接,字符
设备状态)
Many, many complex data structures to track buffers,
memory allocation, “dirty” blocks
(许多的数据结构是为了记录缓冲,内存分配和“脏”块)
Some use object-oriented methods and message passing to
implement I/O(有些用面向对象的方法和消息机制来实现I/O)
Applied Operating System Concepts
12.20
I/O Requests to Hardware Operations
I/O请求到硬件操作
Consider reading a file from disk for a process
(考虑一个进程从磁盘中读取一个文件)
Determine device holding file (决定保存文件的设备)
Translate name to device representation
(转换名字到设备使用的表示法)
Physically read data from disk into buffer
(把数据从磁盘读到缓冲区中)
Make data available to requesting process
(通知进程数据现在是有效的)
Return control to process
(把控制权返回给进程)
Applied Operating System Concepts
12.21
Life Cycle of an I/O Request
(I/O请求的周期)
Applied Operating System Concepts
12.22
Performance(性能)
I/O a major factor in system performance
(I/O是系统性能的主要因素)
Demands CPU to execute device driver, kernel I/O code
(需要CPU执行设备驱动,核心I/O代码)
Context switches due to interrupts
(因为中断而导致的上下文转换)
Data copying(数据拷贝)
Network traffic especially stressful(网络状况尤其重要)
Applied Operating System Concepts
12.23
Intercomputer communications
内部通信
Applied Operating System Concepts
12.24
Improving Performance(改进性能)
Reduce number of context switches(减少上下文转换)
Reduce data copying (减少数据的拷贝量)
Reduce interrupts by using large transfers, smart controllers,
polling
(通过使用一次大量数据传输,智能控制器和轮换来减少中断)
Use DMA(使用DMA)
Balance CPU, memory, bus, and I/O performance for highest
throughput(平衡CPU,内存,总线和I/O性能以达到高吞吐率)
Applied Operating System Concepts
12.25
Summary(总结)
The role of the operating system in computer I/O is to
manage and control I/O operations and I/O devices. (在
计算机输入/输出中操作系统担当的角色是管理和控制I/O操
作和I/O设备。)
Although related topics appear in other chapters, here
we bring together the pieces to paint a complete
picture. (尽管相关的话题出现在其它章节中,在此我们将
片断合在起来绘出一副完整的图片。)
In this chapter we describe I/O Structure, Devices,
Device Drivers, Caching, and Terminal I/O.(本章中我
们描述了I/O结构,设备,设备驱动程序,缓冲和I/O终端。)
Applied Operating System Concepts
12.26