Skip to content

Chapter 1: Introduction

:material-circle-edit-outline: 约 594 个字 :material-clock-time-two-outline: 预计阅读时间 2 分钟

Computer System Organization

OS 是一个资源分配器,也是一个控制程序

*Device controller

计算机硬件如何工作的

  • Each device controller is in charge of a particular device type
  • Each device controller has a local buffer
  • Each device controller type has an operating system device driver to manage it
  • Device controller informs CPU that it has finished its operation by causing an interrupt

Computer Startup

  • bootstrap program is loaded at power-up or reboot,
    • Initializates all aspects of system
    • Loads operating system kernel and starts execution

Common Functions of Interrupts

An operating system is interrupt driven

  • 中断(Interrupt):指系统发生某个异步/同步事件后,处理机暂停正在执行的程序,转去执行处理该事件程序的过程。
  • Interrupt transfers control to the interrupt service routine generally, through the interrupt vector(中断向量), which contains the addresses of all the service routines.
    • Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt.
    • Interrupt architecture must save the address of the interrupted instruction.
  • A trap(陷入) is a software-generated interrupt caused either by an error or a user request.

Interrupts

image-20240919145223910

  • 外部中断 (interrupt) (异步中断)
    • 外部设备所发出的I/O请求
    • 由一些硬件设备产生, 可以在指令执行的任意时刻产生
  • 异常(exception)、陷入(trap) (内部中断,同步中断)
    • 由CPU(正在执行的进程)产生,一条指令终止执行后CPU才会发出中断

Interrupt Handling(中断处理)

  1. The operating system preserves the state of the CPU by storing registers and the program counter.
  2. Determines which type of interrupt has occurred
  3. Separate segments of code determine what action should be taken for each type of interrupt

image-20240919145612172

I/O Structure

I/O方式

  • 程序I/O (Programmed I/O)
  • 中断 I/O (Interrupt I/O)
    • 同步I/O
    • 异步I/O
  • DMA方式
    • 直接内存访问(DMA), Direct Memory Access Structure
  • 通道方式

DEFINITIONS OF COMPUTER SYSTEM COMPONENTS

image-20240912133526749

Operating-System Operations

什么时候运行操作系统程序?

  • Interrupt driven by hardware
  • Software error or request creates exception(异常) or trap(陷入)
  • Other process problems include infinite loop, processes modifying each other or the operating system

Privileged instructions

Privileged instructions(特权指令) can be issued only in monitor (kernel)mode.

  • 特权指令:不允许用户程序中直接使用的指令。例如:I/O指令、设置时钟、 置控制寄存器等指令都是特权指令。
  • 非特权指令: 用户程序中所使用的指令。

Dual-mode operation

User mode(用户模式,用户态) and kernel mode (also monitor mode or system mode or supervisor mode or privileged mode) (内核模式,内 核态)

  • 用户态:执行用户程序时
  • 内核态(管态、核心态、系统态、特权模式):执行操作系统程序时

内核态与用户态之间的区别

image-20240919152927766