基本构成

  • CPU
    • PC
    • IR
    • Execution unit
    • MAR: Memory address register
    • MBR: Memory buffer register
    • I/O AR
    • I/O BR
  • I/O Module
    • Buffers
  • Main Memory
    • Instruction
    • Data
  • System Bus

指令

指令周期

  • Basic Instruction Cycle
    1. Start
    2. Fetch Next Instruction (Fetch Cycle)
    3. Execute Instruction (Execute Cycle, then goto Fetch stage)
    4. HALT

中断

  • No interrupts
  • Interrupts: short I/O wait
  • Interrupts: long I/O wait

中断和指令周期

  • 加入中断的指令周期
    1. START
    2. Fetch Next Instuction (fetch cycle)
    3. Execute Instruction (execute cycle)
      1. if interrupts disabled, jump to 2
      2. if interrupts enabled, jump to 4
      3. or HALT
    4. Check for interrupt; Service interrupt (interrupt cycle)

中断处理

  • 中断的典型处理顺序,
  • 涉及软硬件协作,硬件负责处理 PC 和 PSW;
    • Hardware
      1. Device controller or other system hardware issues an interrupt
      2. Processor finishes execution of current instruction
      3. Processor signals acknowledgment of interrupt
      4. Processor pushes PSW and PC onto control stack
      5. Processor loads new PC value based on interrupt
    • Software
      1. Save remainder of process state infomation
      2. Process interrupt
      3. Restore process state information
      4. Restore old PSW and PC

多中断处理

  • 顺序处理和嵌套处理;

存储器层次结构

  • Processor
    • CPU: processor register
    • Cache: L1, L2, L3
  • SD-RAM DDR-SDRAM
    • Physical memory: RAM
  • Solid State Drives
    • Non-volatile flash-based memory
  • Mechanical Hard Drives (Virtual Memory)
    • File-based memory

高速缓存

高速缓存结构

高速缓存读操作

高速缓存设计考虑因素

高速缓存大小

块大小

映射函数

置换算法

写策略

高速缓存级数

直接内存存取(DMA)

DMA 工作流程

  1. 处理器需要读或写一块数据,则向 DMA 模块发送包含以下信息的命令
    • 请求读 or 写操作的信号,通过 DMA 模块与 CPU 之间的读写控制线发送;
    • 相关 I/O 设备的地址,通过数据线发送;
    • 从存储器中读 or 向存储器中写的起始地址,通过数据线发送并保存在 DMA 模块的地址寄存器中;
    • 读 or 写的字数,也通过数据线传送,保存在 DMA 模块的数据计数寄存器中;
  2. CPU 继续执行其他工作,I/O 任务完全由 DMA 模块执行,DMA 模块直接从存储器中(或向存储器)逐字传送整块数据
  3. 传送结束后,DMA 模块向 CPU 发送中断请求,CPU 执行中断处理例程
指向原始笔记的链接

多处理器与多核计算机

对称多处理器SMP