Module 2: Computer-System Structures 计算机系统结构 Computer System Operation 计算机系统运行 ●| o Structure O结构 Storage Structure 存储构造 Storage Hierarchy 存储层次 Hardware Protection 硬件保护 General System Architecture 般系统体系结构 Applied Operating System Concepts 2.1
Applied Operating System Concepts 2.1 Module 2: Computer-System Structures 计算机系统结构 • Computer System Operation 计算机系统运行 • I/O Structure I/O结构 • Storage Structure 存储构造 • Storage Hierarchy 存储层次 • Hardware Protection 硬件保护 • General System Architecture 一般系统体系结构
Computer-System Architecture 计算机系统体系结构 dek pinter tape drives dsk pinter mpe-drhre CPU controler contoller controler m ble memary cona dler memory Applied Operating System Concepts 2.2
Applied Operating System Concepts 2.2 Computer-System Architecture 计算机系统体系结构
Computer-System Operation 计算机系统运行 w/o devices and the CPU can execute concurrently. O设备与cPU可并行运行 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 cPU通过局部缓存与主存交换数据 o is from the device to local buffer of controller O从设备到设备控制器的局部缓存 Device controller informs cpu that it has finished its operation by causing an interrupt. 设备控制器通过引起中断通知cPU操作已完成 Applied Operating System Concepts 2.3
Applied Operating System Concepts 2.3 Computer-System Operation 计算机系统运行 • I/O devices and the CPU can execute concurrently. I/O 设备与CPU可并行运行 • 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 CPU 通过局部缓存与主存交换数据 • I/O is from the device to local buffer of controller. I/O从设备到设备控制器的局部缓存 • Device controller informs CPU that it has finished its operation by causing an interrupt. 设备控制器通过引起中断通知CPU操作已完成
Common Functions of Interrupts 中断的常见功能 Interrupts transfers control to the interrupt service routine generall through the interrupt vector, which contains the addresses of all the service routines 通常中断通过中断矢量把控制传送给中断服务程序,该中断矢量包含了所有 服务程序的地址 Interrupt architecture must save the address of the interrupted instruction.中断体系结构必须保护被中断指令的地址 Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt 当另一个中断正在处理时,刚进入的中断不能作用,以免丢失中断 e A trap is a software-generated interrupt caused either by an error or a user request陷阱是由于出错或用户请求引起的软件生成的中断 An operating system is interrupt driven 操作系统是中断驱动的 Applied Operating System Concepts 2.4
Applied Operating System Concepts 2.4 Common Functions of Interrupts 中断的常见功能 • Interrupts transfers control to the interrupt service routine generally, through the interrupt vector, which contains the addresses of all the service routines. 通常中断通过中断矢量把控制传送给中断服务程序,该中断矢量包含了所有 服务程序的地址 • Interrupt architecture must save the address of the interrupted instruction. 中断体系结构必须保护被中断指令的地址 • Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt. 当另一个中断正在处理时,刚进入的中断不能作用,以免丢失中断 • A trap is a software-generated interrupt caused either by an error or a user request.陷阱是由于出错或用户请求引起的软件生成的中断 • An operating system is interrupt driven. 操作系统是中断驱动的
Interrupt Handling 中断处理 The operating system preserves the state of the CPU by storing registers and the program counter. 操作系统通过存储寄存器和程序计数器而保留了cPU的状态 Determines which type of interrupt has occurred 确定哪一种中断发生了: polling轮询 vectored interrupt system矢量化中断系统 Separate segments of code determine what action should be H taken for each type of interrupt 对每一类中断分离代码段,以确定应该采取什么反应 Applied Operating System Concepts 2.5
Applied Operating System Concepts 2.5 Interrupt Handling 中断处理 • The operating system preserves the state of the CPU by storing registers and the program counter. 操作系统通过存储寄存器和程序计数器而保留了CPU的状态 • Determines which type of interrupt has occurred: 确定哪一种中断发生了: – polling 轮询 – vectored interrupt system 矢量化中断系统 • Separate segments of code determine what action should be taken for each type of interrupt 对每一类中断分离代码段,以确定应该采取什么反应
Interrupt Time Line For a Single Process Doing Output 单进程处理输出的中断时间线 CPU UsE proceaR erecting vO inte nup processing idle dace berberin banse ganshu reqest dce request done Applied Operating System Concepts 2.6
Applied Operating System Concepts 2.6 Interrupt Time Line For a Single Process Doing Output 单进程处理输出的中断时间线
lo Structure JO结构 After l/O starts, control returns to user program only upon l/O completion 在ⅣO开始之后,仅当O完成之后控制才返回用户程序 wait instruction idles the CPU until the next interrupt 等待指令空转cPU直至下一个中断 wait loop( contention for memory access)等候循环 At most one I/o request is outstanding at a time, no simultaneous I/o processing每一时刻最多一个O请求,无并行o处理 After lo starts, control returns to user program, without waiting for I/o completion.在O开始之后,不等O完成控制就返回用户程序 System call- request to the operating system to allow user to wait for o completion系统调用-请求操作系统允许用户等待lO完成 Device-status table contains entry for each l/o device indicating its type, address, and state设备状态表包括每个o设备的类型、地址和状态 Operating system indexes into o device table to determine device status and to modify table entry to include interrupt操作系统引用设备 状态表以确定设备状态并修改表入口加入中断 Applied Operating System Concepts 2.7
Applied Operating System Concepts 2.7 I/O Structure I/O结构 • After I/O starts, control returns to user program only upon I/O completion. 在I/O开始之后,仅当I/O完成之后控制才返回用户程序 – wait instruction idles the CPU until the next interrupt 等待指令空转CPU直至下一个中断 – wait loop (contention for memory access).等候循环 – At most one I/O request is outstanding at a time, no simultaneous I/O processing.每一时刻最多一个I/O请求,无并行I/O处理 • After I/O starts, control returns to user program, without waiting for I/O completion. 在I/O开始之后,不等I/O完成控制就返回用户程序 – System call – request to the operating system to allow user to wait for I/O completion.系统调用-请求操作系统允许用户等待I/O完成 – Device-status table contains entry for each I/O device indicating its type, address, and state.设备状态表包括每个I/O设备的类型、地址和状态 – Operating system indexes into I/O device table to determine device status and to modify table entry to include interrupt.操作系统引用设备 状态表以确定设备状态并修改表入口加入中断
Two l/o methods 两种JO方法 Synchronous Asynchronous 同步 异步 LeeI requesting process watng requesting pocess cdce dhet drice diet kerel interupt hander I interupt hender ferrel hardware hardwate data tansfer dsta tartet Ime tme Applied Operating System Concepts 2.8
Applied Operating System Concepts 2.8 Two I/O methods 两种I/O方法 Synchronous 同步 Asynchronous 异步
Device-Status Table 设备状态表 dce: cardreader 1 stu: idle dice: ine ptn 3 equest for shtus: busy adress sa546 face dsk un! T length 1372 deice: dsk unit 2 statu: ide dice: dsk urit 3 stus: busy request for dik int 3 sk int 3 operand艳e operator: write ds43046 adress (458 lenght 20000 lengt 500 Applied Operating System Concepts 2.9
Applied Operating System Concepts 2.9 Device-Status Table 设备状态表
Direct Memory Access(DMA) Structure 直接内存访问DMA结构 Used for high-speed l/o devices able to transmit information at close to memory speeds 用于高速MO设备能够以接近存储器的速率传送信息 Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention. 无须cPU的介入,设备控制器直接把数据块从缓冲区存储传送到 主存 Only one interrupt is generated per block, rather than the one interrupt per byte 每数据块只要一个中断,而不是每个字节一个中断 Applied Operating System Concepts 2.10
Applied Operating System Concepts 2.10 Direct Memory Access (DMA) Structure 直接内存访问(DMA)结构 • Used for high-speed I/O devices able to transmit information at close to memory speeds. 用于高速I/O设备能够以接近存储器的速率传送信息 • Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention. 无须CPU的介入,设备控制器直接把数据块从缓冲区存储传送到 主存 • Only one interrupt is generated per block, rather than the one interrupt per byte. 每数据块只要一个中断,而不是每个字节一个中断