CHAP 2 Computer-System Structures 计算机系统结构

Slides:



Advertisements
Similar presentations
1 I/O 设备访问方式和类型. 2 Overview n The two main jobs of a computer: l I/O (Input/Output) l processing n The control of devices connneted to the computer is.
Advertisements

Chapter 3: Operating-System Structures操作系统结构
CHAPTER 9 虛擬記憶體管理 9.2 分頁需求 9.3 寫入時複製 9.4 分頁替換 9.5 欄的配置法則 9.6 輾轉現象
第1单元 操作系统概论 第一节 绪论 操作系统定义.
Foundations of Computer Science
資料庫設計 Database Design.
操作系统结构.
Chapter 2: Computer-System Structures计算机系统结构
最新計算機概論 第3章 計算機組織.
第4章 VHDL设计初步.
第二讲 计算机系统结构 本讲主要内容: 计算机系统操作 I/O 结构 存储系统的结构 分级的存储体系 硬件保护 一般的系统结构 作业:
Chapter 9: Memory Management
大数据在医疗行业的应用.
Chapter 13 輸入/輸出系統 (I/O Systems)
天文望远镜集成建模研究 杨德华 南京天文光学技术研究所 30 NOV, 年中国虚拟天文台年会 广西师范大学 桂林
Operating System Process Management - 4 Monday, August 11, 2008.
Operating System CPU Scheduing - 2 Monday, August 11, 2008.
Operating System CPU Scheduing - 3 Monday, August 11, 2008.
Group multicast fanOut Procedure
CH.2 Introduction to Microprocessor-Based Control
Operating System Concepts 作業系統原理 Chapter 3 行程觀念 (Process Concept)
Windows Vista 操作系统最新安全特性
臺北市立大學 資訊科學系(含碩士班) 賴阿福 CS TEAM
Applied Operating System Concepts
作 業 系 統 第三組 楊育翰 顏瑞霖.
CHAPTER 8 VIRTUAL MEMORY
5 Computer Organization (計算機組織).
Operating System Concepts 作業系統原理 CHAPTER 2 系統結構 (System Structures)
Draft Amendment to STANDARD FOR Information Technology -Telecommunications and Information Exchange Between Systems - LAN/: R: Fast BSS.
Operating System Internals and Design principles
Protective Packaging and Materials Handling 保护性包装和物料搬运
第五章 MSP430中斷式數位I/O.
HLA - Time Management 陳昱豪.
Computer Organization
Chapter 3 行程觀念 (Process Concept)
微程序控制器 刘鹏 Dept. ISEE Zhejiang University
创建型设计模式.
Ch 9: Input/Output System 输入/输出系统
常见问题解答 II. App上重置并清空数据库之后,手机app找不到圣诞灯怎么办? I. 打开APP,发现并连接不了圣诞灯怎么办?
預官考試輔導 計算機概論提要 91年12月4日.
第三章 基本觀念 電腦繪圖與動畫 (Computer Graphics & Animation) Object Data Image
重點 資料結構之選定會影響演算法 選擇對的資料結構讓您上天堂 程式.
第五章,抢占式调度(lab3).
软件工程 Software Engineering
單元11: 事件結構 主題: a. 事件結構概述 b. 如何使用事件結構 c. 使用事件結構須注意的事項.
Operating System Principles 作業系統原理
第3章 認識處理元.
第三章 基本觀念 電腦繪圖與動畫 (Computer Graphics & Animation) Object Data Image
計算機概論 第3章 計算機組織與結構概觀.
Westmont College 网络应用软件 第一讲 (客户-服务器 概念, 协议端口的使用, 套接字API)
資料庫 靜宜大學資管系 楊子青.
Operation System(OS).
The Processor: Datapath and Control (Multi-cycle implementation)
5-6 串列埠模式0輸出埠擴充實習.
中国科学技术大学计算机系 陈香兰 2013Fall 第七讲 存储器管理 中国科学技术大学计算机系 陈香兰 2013Fall.
虚 拟 仪 器 virtual instrument
中国科学技术大学计算机系 陈香兰 Fall 2013 第三讲 线程 中国科学技术大学计算机系 陈香兰 Fall 2013.
计算机系统结构(2012年春) ----存储层次: Cache基本概念
第7章 進階的同步 觀念與實務.
Process Description And Control
第10章 存储器接口 罗文坚 中国科大 计算机学院
计算机问题求解 – 论题1-5 - 数据与数据结构 2018年10月16日.
CHAPTER 6 Concurrency:deadlock And Starvation
TinyDB資料庫 靜宜大學資管系 楊子青.
2012 程式設計比賽 Openfind 天使帝國 v2.0 (蓋亞的紋章).
Arguments to the main Function and Final Project
Operating System Software School of SCU
Race Conditions and Semaphore
MGT 213 System Management Server的昨天,今天和明天
Experimental Analysis of Distributed Graph Systems
Presentation transcript:

CHAP 2 Computer-System Structures 计算机系统结构 Applied Operating System Concepts

Applied Operating System Concepts 内容 A Sample 一个例子 Computer-System Architecture计算机系统体系结构 Computer System Operation 计算机系统运行 I/O Structure I/O结构 Storage Structure 存储构造 Storage Hierarchy 存储层次 Hardware Protection 硬件保护 General System Architecture 一般系统体系结构 Summary(总结) Homework作业 Applied Operating System Concepts

Applied Operating System Concepts 操作系统做什么?—一个例子 #include <stdio.h> int main(int argc, char *argv[]) { puts("hello world"); return 0; } Applied Operating System Concepts

Applied Operating System Concepts Process Create 进程创建 用户告诉操作系统执行hello程序 操作系统找到该程序,检查其类型 检查程序首部,找出正文和数据的地址 文件系统找到第一个磁盘块 父进程需要创建一个新的子进程,执行hello程序 操作系统需要将执行文件映射到进程结构 Applied Operating System Concepts

Process Running进程执行过程 1、操作系统设置CPU上下文环境,并跳到程序开始处 2、程序的第一条指令执行,失败,缺页中断发生 3、操作系统分配一页内存,并将代码读入,继续执行 4、更多的缺页中断,读入更多的页面 5、程序执行系统调用,在文件描述符中写一字符串 6、操作系统检查字符串的位置是否正确 7、操作系统找到字符串被送往的设备 8、设备是一个伪终端,由一个进程控制 Applied Operating System Concepts

Process Running (cont.) 进程执行过程(续) 9、操作系统将字符串送给该进程 10、该进程告诉窗口系统它要显示字符串 11、窗口系统确定这是一个合法的操作,然 后将字符串转换成像素 12、窗口系统将像素写入存储映像区 13、视频硬件将像素表示转换成一组模拟信号控制显示器(重画屏幕) 14、显示器发射电子素 15、你在屏幕上看到hello world Applied Operating System Concepts

Computer-System Architecture 计算机系统体系结构 Applied Operating System Concepts

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操作已完成 Applied Operating System Concepts

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. 操作系统是中断驱动的 Applied Operating System Concepts

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 对每一类中断分离代码段,以确定应该采取什么反应 Applied Operating System Concepts

Interrupt Time Line For a Single Process Doing Output单进程处理输出的中断时间线 Applied Operating System Concepts

Applied Operating System Concepts 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.操作系统引用设备状态表以确定设备状态并修改表入口加入中断 Applied Operating System Concepts

Two I/O methods 两种I/O方法 Synchronous 同步 Asynchronous 异步 Applied Operating System Concepts

Device-Status Table 设备状态表 Applied Operating System Concepts

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. 每数据块只要一个中断,而不是每个字节一个中断 Applied Operating System Concepts

Storage Structure 存储结构 Main memory – only large storage media that the CPU can access directly.主存- CPU可以直接访问的唯一大型存储介质 Secondary storage – extension of main memory that provides large nonvolatile storage capacity.二级存储器-主存的扩展提供了非易失的存储容量 Magnetic disks – rigid metal or glass platters covered with magnetic recording material 磁盘-覆盖了磁记录材料的硬金属或玻璃盘片 Disk surface is logically divided into tracks, which are subdivided into sectors.磁盘表面逻辑划分了磁道、再划分为扇面 The disk controller determines the logical interaction between the device and the computer. 磁盘驱动器确定设备和计算机之间的相互作用 Applied Operating System Concepts

Moving-Head Disk Mechanism 磁头移动机制 Applied Operating System Concepts

Storage Hierarchy 存储层次 Storage systems organized in hierarchy.存储系统分层组织 Speed 速度 cost 成本 volatility 易失性 Caching – copying information into faster storage system; main memory can be viewed as a last cache for secondary storage. 缓存- 把信息复制进较快的存储系统;主存可看作为二级存储器的最后一个缓存 Applied Operating System Concepts

Storage-Device Hierarchy 存储设备层次 寄存器 缓存 主存储器 电子盘 磁盘 光盘 磁带 Applied Operating System Concepts

Hardware Protection 硬件保护 Dual-Mode Operation 两状态运行 I/O Protection I/O保护 Memory Protection 内存保护 CPU Protection CPU 保护 Applied Operating System Concepts

Dual-Mode Operation 两状态运行 Sharing system resources requires operating system to ensure that an incorrect program cannot cause other programs to execute incorrectly. 共享系统资源要求操作系统确保有误程序不会引起其他程序的运行错误 Provide hardware support to differentiate between at least two modes of operations. 至少在两个运行状态之间提供硬件支持 1. User mode – execution done on behalf of a user. 用户态-代表用户执行完毕 2. Monitor mode (also supervisor mode or system mode) – execution done on behalf of operating system. 管态(特权模式或系统模式)-代表操作系统执行 Applied Operating System Concepts

Dual-Mode Operation (Cont.) 两状态运行(续) Mode bit added to computer hardware to indicate the current mode: monitor (0) or user (1). 状态位添入计算机硬件,指示正确的状态:管态(0) 或用户态(1) When an interrupt or fault occurs hardware switches to monitor mode. 当中断或错误出现,硬件切换至管态 monitor user Interrupt/fault set user mode Privileged instructions can be issued only in monitor mode. 特权指令只能在管态下使用 Applied Operating System Concepts

Applied Operating System Concepts I/O Protection I/O保护 All I/O instructions are privileged instructions. 所有I/O指令是特权指令 Must ensure that a user program could never gain control of the computer in monitor mode (I.e., a user program that, as part of its execution, stores a new address in the interrupt vector). 必须确保用户程序决不能以管态控制计算机(即,用户程序的执行部分在中断向量中存放一个新的地址) Applied Operating System Concepts

Memory Protection 存储保护 Must provide memory protection at least for the interrupt vector and the interrupt service routines.至少要为中断向量和中断服务程序提供存储保护 In order to have memory protection, add two registers that determine the range of legal addresses a program may access: 为了进行存储保护,增加2个寄存器用于确定一个程序的合法地址范围 base register – holds the smallest legal physical memory address. 基址寄存器- 存有最小的合法物理存储器地址 Limit register – contains the size of the range 限长基址寄存器-存有允许范围的大小 Memory outside the defined range is protected. 在定义范围之外的存储器受到保护 Applied Operating System Concepts

Applied Operating System Concepts A Base And A limit Register Define A Logical Address Space 基址与限长寄存器定义逻辑地址空间 Applied Operating System Concepts

Protection Hardware 保护硬件 When executing in monitor mode, the operating system has unrestricted access to both monitor and user’s memory. 在管态下运行时,操作系统对监控和用户存储空间有不受限制的访问权 The load instructions for the base and limit registers are privileged instructions. 用于基址和限长寄存器的装载指令是特权指令 Applied Operating System Concepts

Applied Operating System Concepts CPU Protection CPU保护 Timer – interrupts computer after specified period to ensure operating system maintains control. 定时器-在指定的时间段之后中断计算机,以确认操作系统保持控制 Timer is decremented every clock tick.每一时钟滴答定时器减少 When timer reaches the value 0, an interrupt occurs.定时器为零时中断发生 Timer commonly used to implement time sharing. 定时器通常用于实现时间共享 Time also used to compute the current time.定时器也用于计算当前时间 Load-timer is a privileged instruction.装载定时器是特权指令 Applied Operating System Concepts

General-System Architecture 一般系统体系结构 Given the I/O instructions are privileged, how does the user program perform I/O? I/O指令是要特权的,用户程序如何完成I/O? System call – the method used by a process to request action by the operating system.系统调用- 方法是进程请求操作系统的一个动作 Usually takes the form of a trap to a specific location in the interrupt vector.通常以陷阱形式出现 ,以指定中断向量的地址 Control passes through the interrupt vector to a service routine in the OS, and the mode bit is set to monitor mode. 控制通过中断向量传递给OS中的服务程序,状态位设为管态 The monitor verifies that the parameters are correct and legal, executes the request, and returns control to the instruction following the system call. 监控程序验证参数正确合法,执行请求,返回控制给系统调用后的指令 Applied Operating System Concepts

Use of A System Call to Perform I/O 使用系统调用完成I/O Applied Operating System Concepts

Applied Operating System Concepts Summary(总结) Chapter 2 discusses the general structure of computer systems. It may be a good idea to review the basic concepts of machine organization and assembly language programming. The students should be comfortable with the concepts of memory, CPU, registers, I/O, interrupts, instructions, and the instruction execution cycle. Since the operating system is the interface between the hardware and user programs, a good understanding of operating systems requires an understanding of both hardware and programs. Applied Operating System Concepts

Applied Operating System Concepts 作业 P41 2.1 P42 2.9 Applied Operating System Concepts