Overview of I/O Management for Operating System Review

Table of contents

1. I/O equipment

2. I/O control method

3. I/O software hierarchy


1. I/O equipment

 I/O devices are external hardware devices that can input data to a computer, or receive data output from a computer

(1) classification

 Classified by characteristics:

 ①Human -computer interaction equipment . For the interaction between the computer and the user, the input device has a mouse and keyboard, the output device is a printer, etc.

 ②Storage device . Used to store various information, such as mobile hard disk, CD, etc.

 ③Network communication equipment . For remote device communication, such as various network interfaces, modems, etc.

 Classified by transmission rate:

 ① Low-speed equipment . Mouse, keyboard, etc., several to hundreds of bytes per second

 ② medium speed equipment . Laser printers, etc., thousands to tens of thousands of bytes per second

 ③ high-speed equipment . Disk, CD, etc., tens of kilobytes to gigabytes per second

 Classification by transmission unit:

 ① Block device . The access and transmission of this type of device information is based on data blocks, such as disks, etc., which have a high transmission rate and are addressable (read and write any block at will)

 ②Character device . The input and output of data is in units of characters, such as printers, etc., their transmission rate is low, they are not addressable, and interrupt-driven methods are often used

(2) I/O controller

 Definition : The CPU cannot directly control the mechanical parts of the I/O device, so the I/O device needs to have an electronic part as an "intermediary" between the CPU and the mechanical parts of the I/O device to realize the control of the device by the CPU. This electronic component is the I/O controller, also known as the device controller. It receives commands from the CPU to control the work of I/O devices.

function :

Receiving and identifying commands : There will be corresponding control registers in the I/O controller, which are used to store and receive commands and parameters sent from the CPU, and decode the received commands.

Data exchange : There will be corresponding data registers in the I/O controller to realize data exchange between the CPU and the controller, and between the controller and the device.

③Identify and report device status : There will be a corresponding status register in the I/O controller to record the status of the I/O device.

Address identification : use the address provided by the CPU to determine which register the CPU wants to read and write.

Data buffering : Alleviate the problem of mismatch between I/O device and CPU speed.

⑥Error control : Error detection is performed on the data transmitted from the I/O device.

composition:

Interface between CPU and controller : used to realize communication between CPU and controller. The CPU issues commands through the control line; specifies the device to be operated through the address line; inputs or outputs data through the data line

I/O logic : responsible for receiving and identifying various commands of the CPU (such as address decoding), and responsible for issuing commands to the device

③The interface between the controller and the device : used to realize the communication between the controller and the device, one controller may be connected to multiple devices

2. I/O control method

(1) Program direct control mode

 The computer reads data from an external device into memory, one word of data at a time. For each word read in, the CPU needs to check the state of the peripherals in a loop until it is determined that the word is already in the data register of the I/O controller.

 The direct program control method is simple and easy to implement , but most of the CPU time is spent waiting for the I/O device to complete the data I/O cycle test, resulting in a great waste of CPU resources and resulting in a rather low CPU utilization .

 (2)  Interrupt drive mode

 Due to the slow speed of the I/O device, after the CPU issues a read/write command, the process waiting for I/O can be blocked and switched to another process for execution. When the I/O is completed, the controller will send an interrupt signal to the CPU. After the CPU detects the interrupt signal, it will save the running environment information of the current process and transfer to execute the interrupt handler to handle the interrupt. During interrupt processing, the CPU reads a word of data from the I/0 controller and transfers it to the CPU register, and then writes it into the main memory. Next, the CPU restores the execution environment of the process (or other processes) waiting for I/O, and then continues execution.

 (3)  DMA mode

  In order to further reduce the CPU's intervention on I/O, a direct memory access method is introduced. At this time, data is transferred in units of blocks, directly between the device and the memory under the action of the DMA controller, and no CPU intervention is required.

DMA controller : The composition of the DMA controller is shown in the figure below. In order to realize the direct exchange of data between the host and the controller, the DMA controller also sets four types of registers:

DR  (Data Register): Temporarily store data from the device to the memory, or from the memory to the device.

MAR  (memory address register): When inputting, MAR indicates where the data should be placed in the memory; when outputting, MAR indicates where the data to be output is placed in the memory.

DC  (Data Counter): Indicates the remaining number of bytes to be read/written.

CR  (command/status register): used to store the I/0 command sent by the CPU, or the status information of the device.

The working process of DMA :

① When the CPU receives the DMA request from the I/O device, it sends a command to the I/O controller, starts the DMA controller, and then continues other work.

② After that, the CPU entrusts the control operation to the DMA controller, which is responsible for processing. The DMA controller interacts directly with the memory, transferring entire blocks of data, one word at a time, without CPU involvement.

③ After the transfer is completed, the DMA controller sends an interrupt signal to the processor.

 The whole process only requires CPU participation at the beginning and end of the transmission.

(4) Channel control mode

  The I/O channel is a processor specially responsible for input and output . It can recognize and execute a series of channel instructions. On the basis of DMA, it further reduces the intervention of the CPU, that is, the intervention of reading and writing a data block is reduced to the reading and writing of a group of data blocks and related control management, further improving the utilization rate of the CPU.

Three types of I/O channels:

 ①Byte multiplex channel: It is suitable for connecting low-speed or medium-speed I/O devices such as printers and terminals. This channel works interleaved in units of bytes: when a byte is transmitted for one device, it is immediately transferred to transmit a byte for another device.

 ②Array selection channel: It is suitable for connecting high-speed devices such as disks and tapes. This kind of channel works in "group mode" and transmits a batch of data at a time with a high transmission rate, but it can only serve one device at a time. Whenever an I/O request is processed, another device is selected and served for it. It can be seen that the channel utilization is very low

 ③Array multi-channel: This channel combines the characteristics of byte multi-channel time-sharing work and high transmission rate of selected channels. Its essence is: use multi-channel programming technology for channel programs, so that devices connected to channels can work in parallel.

Four I/O control modes:

3. I/O software hierarchy

  I/O software is usually organized into a hierarchical structure, that is, the system input and output functions are organized into a series of layers, and each layer uses the services provided by its lower layer to complete some sub-functions in the input and output functions, and shields the details of the implementation of these functions to provide services to the upper layer. Using a hierarchical structure can ensure that the interface between layers remains unchanged, and the software of a certain layer will not affect the changes of the upper and lower layers. The 1/0 software of the hierarchy only touches the specific characteristics of the hardware at the lowest level.

(1) User-level software

① Realize the interface for interacting with the user, and the user can directly use the library functions related to I/O operations provided by this layer to operate the device

②Translate user requests into formatted I/O requests, and request services from the operating system kernel through "system calls"

(2) Device independent software

Also known as device-independent software, almost all functions that have nothing to do with device hardware features are implemented at this layer. Mainly realize the following functions:

①Provide a unified call interface to the upper layer, like write/read system calls;

② equipment protection;

③Distribution and recovery of equipment;

④Establish the mapping relationship between the logical device name (defined in the application program and visible to the user) to the physical device name, that is, select and call the corresponding driver according to the device type (determine the physical device through the logical device table LUT, and then find the device driver)

(3) Device driver

Directly related to the hardware, it is responsible for implementing the instructions issued by the system to the device, and converting a series of commands (such as read/write) issued by the upper layer into a series of operations "understandable" by specific devices. Including setting device registers: checking device status, etc.

Different I/O devices have different hardware characteristics, and manufacturers need to design and provide corresponding drivers according to the hardware characteristics of the devices.

(4) Interrupt handler

It is used to save the CPU environment of the interrupted process, transfer to the corresponding interrupt handler for processing, and then restore the scene of the interrupted process and return to the interrupted process

When the I/0 task is completed, the I/0 controller will send an interrupt signal, and the system will find the corresponding interrupt handler according to the interrupt signal type and execute it:

(5) Hardware

Actually perform I/O operations, usually including a mechanical part and an electronic part (I/O controller, introduced earlier)

Guess you like

Origin blog.csdn.net/weixin_46516647/article/details/125088109