本文内容整理自西安交通大学软件学院田丽华老师的课件,仅供学习使用,请勿转载

操作系统系列笔记汇总:操作系统笔记及思维导图汇总附复习建议_Qlz的博客-CSDN博客

文章目录

文章目录

  • 文章目录
  • 思维导图
  • Computer System Operation
  • 中断机制
    • 分类
    • 目的
    • 功能
  • I/O Structure
    • I/O Interrupts
    • synchronous I/O
    • DMA structure
  • Storage Structure
    • Main Memory
    • Secondary Storage
    • cache
    • coherency and consistency (一致性)
  • Storage Hierarchy(存储层次)
  • Hardware Protection(硬件保护)
    • Introduce
    • 可以进行的保护操作
    • Dual-Mode Operation(两状态操作)
    • I/O Protection
    • Memory Protection
    • CPU protection
      • The timer(定时器)

思维导图

计算机系统结构思维导图

Computer System Operation

计算机体系结构 Computer-System Architecture

image-20210923215410914

  • 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操作已完成

中断机制

分类

  • hardware interrupt 硬件中断

    • device controller informs CPU that it has finished its operation by causing an interrupt

      • disk, timer, etc.
  • **software interrupt (trap) ** 软件中断(陷阱)
    • a trap (or an exception异常)

      • division by zero, invalid memory access
    • a system call 系统调用(also called a monitor call)
      • read( ), write( )

目的

make the system more efficient and meanwhile more responsive

功能

a modern operating system is interrupt driven
现代操作系统是中断驱动

  • interrupt transfers control to the interrupt service routine (interrupt handler) generally
    中断将控制权转移到中断服务程序

    • separate segments of code determine what action should be taken for each type of interrupt 不同类型的中断将要执行的操作不一样
    • a generic routine to examine the interrupt information, and in turn call the specific handler 有一个程序用来检验终端的类型,然后调用对应的程序
    • through the interrupt vector (中断向量表), which contains the addresses of all the service routines
      • e.g. MS-DOS, UNIX
  • 中断向量是中断服务程序的入口地址

I/O Structure

  • peripheral(外围) device(s) attached to device controller设备与设备控制器相连

  • a device controller (hardware)

    • local buffer storage 本地缓冲器
    • a set of registers 一组寄存器
  • device driver, usually a software program embedded into an OS设备驱动程序

I/O Interrupts

  • two ways of an I/O operation 两种I/O操作

    • Synchronous 同步
    • Asynchronous异步
  • synchronous I/O mode: after I/O starts, control returns to user program only upon I/O completion 等待I/O完成后继续接下来的操作

  • asynchronous I/O mode: after I/O starts, control returns to user program without waiting for I/O completion 不等待I/O完成继续进行接下来的操作

    • the user program will be notified about the I/O completion on a later time

      • Windows message, or call back function

synchronous I/O

  • busy wait method 忙等方式

    • wait instruction idles(空转) the CPU until the next interrupt
    • wait loop (contention for memory access)
      • Loop: jmp Loop
    • drawbacks: at most one I/O request is outstanding at a time, no simultaneous I/O processing 每次只能有一个I/O请求,没有同时的I/O处理
  • interrupt based method: multiple I/O 中断方式
    • device-status table contains entry for each I/O device indicating its type, address, and state
    • a wait queue (a list of waiting requests) for each I/O device

DMA structure

DMA:Direct Memory Access

  • low speed device like a typical terminal input device(典型输入终端设备) leaves most CPU time for other operations 在发出I/O请求后CPU正常运行,当运行完成后产生中断通知CPU,CPU处理中断完成后继续正常运行

    • usually assigned a low interrupt priority, allowing other more important interrupts to be processed first 低中断优先级
  • high-speed I/O devices able to transmit information at close to memory speeds

    • if the CPU needs to respond to each interrupt for every byte, it does not have much time for process execution 每次发出I/O请求都相应会浪费资源,会等很多一起响应
  • DMA - device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention设备控制器在本地缓冲和内存之间直接传输一整块数据而无需CPU干预

    • setting up buffers, pointers, and counters
    • only one interrupt is generated per block, rather than the one interrupt per byte
  • DMA controller steals memory cycles from CPU DMA控制器从CPU中窃取内存周期

Storage Structure

image-20210923223226953

  • Storage systems organized in hierarchy.存储系统分层组织

    • Speed 速度
    • cost 成本
    • volatility 易失性

Main Memory

  • random access memory (RAM, DRAM)
  • main memory are the only large storage that the CPU can access directly CPU可以直接访问的唯一大型存储介质
  • store data and instructions
  • problems with RAM
    • not big enough, too small to store all programs and data needed permanently 不够大
    • volatile(易失性), contents lost when power is turned off

Secondary Storage

  • extension of main memory主存的扩展

    • big enough
    • non-volatile, permanent 提供了非易失的存储容量
  • magnetic disk 磁盘-覆盖了磁记录材料的硬金属或玻璃盘片
    • random access (随机存取)
  • magnetic tape 磁带
    • sequential access (顺序存取)
  • floppy disks (软盘), CD-ROMs, etc.
    • data exchange (small and light, easy to carry)

cache

  • use of high-speed memory to hold recently-accessed data 使用高速存储保存近期访问的数据

    • cache (built into CPU)
    • data cache
    • instruction cache, code cache
  • cache management
    • locality
    • above 80% hit ratio(命中率)
  • caching introduces another level in storage hierarchy, and it requires data that is simultaneously(同时) stored in more than one level to be consistent(保持一致)

coherency and consistency (一致性)

image-20210923223902720

  • the copy of a datum(数据) appears in many levels of storage hierarchy

    • single process, easy 单道程序,正常
    • multiprogramming environment
    • multiprocessor environment
      • cache coherency, handled by hardware
    • distributed environment

Storage Hierarchy(存储层次)

  • Caching – copying information into faster storage system; 缓存- 把信息复制进较快的存储系统;
  • main memory can be viewed as a last cache for secondary storage. 主存可看作为二级存储器的最后一个缓存

Hardware Protection(硬件保护)

Introduce

  • single-user programmer-operated system, complete control of the computer system, no protection 单用户系统,程序员可完全控制系统
  • early OS, called resident monitor, still no protection 早期OS称为常驻监督程序,没有保护
  • batch system, need some protection
    • e.g. an indefinite loop reading cards不断读取卡片
  • multiprogramming, a program may accidentally or deliberately/maliciously modify the code or data of another program
  • multi-user environment, need protection for files, data on disk/tape 多用户环境,需要保护磁盘上的文件、数据
  • hardware trap to the OS, 硬件陷入到OS ; when
    • illegal instructions, or access memory not in the address space, etc.非法指令,或访问不属于自己的地址空间的内存
    • process terminated/aborted, core dumped 进程终止

可以进行的保护操作

  • Dual-Mode Operation 两状态操作
  • I/O Protection I/O保护
  • Memory Protection 内存保护
  • CPU Protection CPU 保护

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.
    至少在两个运行状态之间提供硬件支持

    • User mode – execution done on behalf of a user.
      用户态-代表用户执行
    • Monitor mode (also supervisor mode or system mode) – execution done on behalf of operating system.
      管态(特权模式或系统模式)-代表操作系统执行
  • mode bit added to computer hardware to indicate the current mode: monitor (0) or user (1)
    模式位添加到计算机硬件,表示当前模式

    • mode bits in PSW
  • at boot time, the hardware starts in monitor mode 系统引导时,硬件处于管态

  • starts user processes in user mode 在用户模式下执行用户进程

  • when an interrupt or fault occurs hardware switches to monitor mode 出现中断或陷阱,硬件切换到管态

image-20210923224707710

  • dual-mode protect OS from errant users, and errant users from one another 双模式保护操作系统免受错误用户和错误用户之间的伤害

  • privileged instructions 特权指令: change mode, I/O 特权指令必须在管态下执行,

    • in user mode: always change mode to kernel

      • the way to implement system call
      • arguments passed via registers, stack, or memory (with pointers in registers or stack)
    • in kernel mode: just do it!

I/O Protection

  • all I/O instructions are privileged instructions 所有的I/O指令都是特权指令

    • memory mapped I/O, disk I/O (file access), display I/O, printer I/O, network I/O
    • a user cannot issue I/O instructions directly, he must do it through system call用户不能直接用i/o指令,必须通过系统调用
  • it must be ensured that a user program could never gain control of the computer in monitor mode 确保用户程序不能在管态下控制计算机
    • e.g., a user program that, as part of its execution, stores a new address in the interrupt vector

      • a way to inject a virus or Trojan horse on DOS system

Use of a system call to perform I/O

当处在用户态的时候发出system call后,会陷入OS总,同时切换到管态,执行相应的I/O操作,完成后切换回用户态

image-20210923235256106

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 ** 确定进程能访问的合法空间
    • base register 基址寄存器– holds the smallest legal physical memory address.
    • limit register界限寄存器 – contains the size of the range
  • memory outside the defined range is protected

image-20210923235530700

在对内存访问时,需要检查寻址地址是否合法,首先检查该地址是否大于基址地址,如果大于则检查是否在界限寄存器中间,如果不在则陷入OS中,正常则继续运行

  • every address generated in every instruction in user mode is hardware checked用户态下所生成的每个地址都要经过硬件检查
  • base and limit registers can be loaded by only the OS by using a special privileged instruction 只有在OS下通过特权指令才可以更改基址寄存器和界限寄存器
  • when executing in monitor mode, the operating system has unrestricted access to both monitor and user’s memory 当在监视器模式下执行时,操作系统可以无限制地访问监视器和用户的内存
    • change the (base and limit) registers
    • load users’ programs into users’ memory
    • dump memory map of those programs in case of errors
    • access and modify parameters of system calls

CPU protection

  • we must prevent a program from getting stuck in an infinite loop(死循环), or not calling OS services and never returning control to the OS 需防止用户程序陷入死循环或者不调用系统服务且不将控制权返回到OS
  • timer 定时器interrupts computer after specified period to ensure operating system maintains control
    • fixed timer, e.g. 1/32 second
    • variable timer, a fixed-rate clock and a counter
      • the counter is decremented every clock tick
      • when the counter reaches the value 0, an interrupt occurs

The timer(定时器)

  • load-timer is a privileged instruction

    • before turning over control to the user’s program, the OS ensures that the timer is set to interrupt 设定计时器以便产生中断
    • if the timer interrupts, control transfers to the OS, and the user program may be killed or given more time to run定时器中断,控制权会返回给OS
  • timer commonly used to implement time sharing 用来实现分时系统
    • time slice (every N milliseconds)
  • timer also used to compute the current time计算当前时间

操作系统第二章笔记---计算机系统结构相关推荐

  1. 计算机系统结构第二章课件,计算机系统结构第二章new解析课件

    计算机系统结构第二章new解析课件 计算机系统结构 第二章 数据表示与指令系统 阿迪达斯三条纹标志是由阿迪达斯的创办人阿迪·达斯勒设计的,三条纹的阿迪达斯标志代表山区,指出实现挑战.成就未来和不断达成 ...

  2. 计算机组成原理第二章笔记---计算机进化与性能

    本文内容整理自西安交通大学软件学院李晨老师的课件,仅供学习使用,请勿转载 计算机组成原理系列笔记汇总:计算机组成原理笔记及思维导图汇总附复习建议_Qlz的博客-CSDN博客 文章目录 文章目录 文章目 ...

  3. 笔记篇:操作系统第二章 进程管理

    笔记篇:操作系统第二章 进程管理 目录 笔记篇:操作系统第二章 进程管理 2.1 进程的基本概念 2.1.1 程序的顺序执行及其特征 2.1.2 前驱图 2.1.3 程序的并发执行及其特征 2.1.4 ...

  4. 第1章:计算机系统结构的基础知识

    第1章:计算机系统结构的基础知识 第1章:计算机系统结构的基础知识 1.1 计算机系统结构的基本概念 1.1.1 计算机系统的层次结构 ⭐ 1.1.2 计算机系统结构的定义 ⭐ (1)定义: (2)计 ...

  5. 模拟进程创建、终止、阻塞、唤醒原语_操作系统第二章--进程的描述与控制

    操作系统第二章--进程的描述与控制 前趋图和程序执行 前趋图 前趋图是一个有向无循环图DAG,用来描述进程之间执行的前后关系 初始结点:没有前趋的结点 终止结点:没有后继的结点 重量:表示该结点所含有 ...

  6. 《Spring Recipes》第二章笔记:Creating Beans by Invokin...

    2019独角兽企业重金招聘Python工程师标准>>> <Spring Recipes>第二章笔记:Creating Beans by Invoking an Insta ...

  7. (王道408考研操作系统)第二章进程管理-第三节10:经典同步问题之哲学家进餐问题

    本文接: (王道408考研操作系统)第二章进程管理-第三节6:经典同步问题之生产者与消费者问题 ((王道408考研操作系统)第二章进程管理-第三节7:经典同步问题之多生产者与多消费者问题 (王道408 ...

  8. (王道408考研操作系统)第二章进程管理-第三节8:经典同步问题之吸烟者问题

    本文接: (王道408考研操作系统)第二章进程管理-第三节6:经典同步问题之生产者与消费者问题 ((王道408考研操作系统)第二章进程管理-第三节7:经典同步问题之多生产者与多消费者问题 文章目录 一 ...

  9. (王道408考研操作系统)第二章进程管理-第三节7:经典同步问题之多生产者与多消费者问题

    注意:生产者与消费者问题Linux系统编程专栏有案例讲解 Linux系统编程39:多线程之基于阻塞队列生产者与消费者模型 Linux系统编程40:多线程之基于环形队列的生产者与消费者模型 本文接:(王 ...

最新文章

  1. 线程池是怎样工作的?
  2. Python Django 图片上传及显示代码示例
  3. android 点击侧滑代码,代码分析Android实现侧滑菜单
  4. Bzoj4556 [Tjoi2016Heoi2016]字符串
  5. 进阶13 Lambda表达式
  6. 39-如何共享数据?
  7. aliyun redis 链接超时_超详细的Redis入门指导
  8. Tomcat安装配置(详细步骤)
  9. 服务器系统驱动精灵,驱动精灵2009 新版启动快运行稳
  10. 计算机基础操作知识带答案,计算机应用基础知识试题带答案
  11. 教师个人三年发展规划
  12. JavaScript实现语音助手核心代码
  13. CSP CCF: 201909-3 字符画) (C++)
  14. 首席新媒体运营黎想教程:可复用的社群运营+直播流程
  15. IMAP和POP有什么区别?
  16. 【调剂】苏州科技大学电子与信息工程学院2021年硕士研究生招生第二批调剂信息公告...
  17. 福神喜神贵神财神方位查询
  18. Windows服务器双网卡绑定的方法(HP/Broadcom网卡)
  19. 场景,或许才是未来空间设计的关键词,可能是最接近元宇宙的空间体验? | 浅空间专栏...
  20. TP5做工资条群发系统

热门文章

  1. 【软考中级】多媒体应用设计师复习笔记第八章
  2. Horizon Cloud Service 云桌面水印组策略配置
  3. Log4j修复——Vmware Horizon
  4. 作业调度和进程调度的区别
  5. cesium编辑功能CesiumEdit.js
  6. C语言中数组的七十二变
  7. LED显示屏组装常见故障及解决方案
  8. linux crs,linux上oracle rac集群 crs常用命令
  9. 为什么常说程序员35岁是道坎?
  10. akcms升级后台编辑器完美教程