(13)IO系统

I/O Hardware

通用概念:

  • port
  • bus
  • controller(连接bus和host CPU)

IO设备具有地址,可用于

  • 特殊IO指令
  • Memory-mapped I/O

IO Port Registers

四种概念寄存器:

  • Data-in: read by the host to get input,CPU从IO设备中读数据
  • Data-out: written by the host to send output,CPU向设备中写数据
  • Status: device status read by the host
  • Control: written by the host to start a command or change the mode of a device

polling(轮询)

  1. host反复读busy bit,直至其不再busy
  2. host将command寄存器中write bit置位,并向data-out寄存器写出一个字节。
  3. host将command-ready位置位
  4. 当设备的controller注意到command-ready置位后,它将busy位置位。
  5. controller读取command寄存器,发现write置位,于是它读取data-out中的字节,并在IO设备完成操作
  6. controller将command-ready清零;将command寄存器中的error清零来只是IO成功;将busy位清零来表示IO操作结束。

会产生忙等待

中断驱动的IO

在这里插入图片描述
各种终端:

  • Page fault
  • trap
  • 低优先级会被高优先级的打断

DMA

提供更高的处理效率(针对磁盘等block-based设备)
在这里插入图片描述

Application I/O Interface

在这里插入图片描述

Kernel I/O Subsystem

  • 缓存(caching)
  • 假脱机(spooling):外部设备练级并行操作

Error Handling

错误恢复,返回错误代码,打印内核错误日志

I/O Protection

使用系统调用保护IO

Transforming I/O Requests to Hardware Operations

一个进程请求读磁盘的步骤(大体步骤):

  • 决定持有文件的设备
  • 将文件名转换为设备可识别的表示方式
  • 将物理存储中的数据从磁盘读到buffer(涉及到内核空间和用户空间的buffer copy)
  • 让读取的数据对请求进程可用
  • 将控制权返回进程
    在这里插入图片描述

Streams
Performance

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值