Operating system ~ Concept and management of I/O settings

What is an I/O device

"I/o" is "Input/Output" (Input/Output)
I/o devices are external devices that can input data to a computer or receive data output from a computer. They are hardware components in a computer.
Insert picture description here

Classification of I/O devices

Insert picture description here
Insert picture description here
Insert picture description here

I/O controller

The CPU cannot directly control the mechanical components of the /o device, so the I/o device also has an electronic component as an "intermediary" between the CPU and the mechanical components of the /o device to realize the control of the device by the CPU.

This electronic component is the l/o controller, also known as the device controller. The CPU can control the I/O controller, and the /o controller controls the mechanical parts of the device.

Insert picture description here

The composition of the IO controller

Insert picture description here
If the CPU wants to read data, send the command to the I/O logic. After the I/O logic recognizes the command, it sends the command to the corresponding device interface. The device interface immediately returns the status and control signals to the I/O logic. Save the status and control signal of this I/O device to the corresponding register. After the device reads the data, it sends the data to the I/O logic first, and the I/O logic sends the data to the data register, and the CPU then sends the data to the data register. Read data into the data register

If the CPU wants to write data, first send the corresponding command to the I/O logic, check the status signal and control signal of the corresponding device, and then write the data to the data register. The I/O logic reads the data in the data register and sends it to the corresponding I/O device

Noteworthy small details: ①One I/o controller may correspond to multiple devices;
②There may be multiple data registers, control registers, and status registers (such as: each control/status register corresponds to a specific device), and These registers must have corresponding addresses to facilitate CPU operation. Some computers will let these registers occupy part of the memory address, which is called memory mapping /o; other computers use I/o dedicated addresses, that is, register independent addressing.

Memory mapping l/o vs register independent addressing

Insert picture description here

I/O control method

Direct program control method

1. The process of completing a read/write operation
Insert picture description here

2. The frequency of
CPU intervention is very frequent. The CPU needs to intervene before and after the I/O operation is completed, and the CPU needs to poll and check continuously while waiting for the I/O to complete.

3. The unit of data transmission,
read/write one word at a time

4. Data flow
Reading operation (data input): I/o device→CPU→>memory write operation (data output): memory→CPU→>I/o device Each word of reading/writing requires CPu's help

5. Main disadvantages and main advantages
Advantages: Simple to implement. After the read/write instruction, add a series of instructions to realize the loop check (so it is called the "program direct control method")
Disadvantages: CPU and I/o devices can only work serially, and the CPU needs to poll and check for a long time. In the "busy waiting" state, the CPU utilization is low.

Interrupt-driven

Introduce an interrupt mechanism. 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 operating environment information of the current process and then execute the interrupt handler to handle the interrupt. In the process of processing the interrupt, the CPU reads a word of data from the I/o controller and transfers it to the CPU register, and then writes it to the main memory. Then, the CPU restores the operating environment of the process (or other processes) waiting for I/o, and then continues execution.

Note:
①cPu will check the interrupt at the end of each instruction cycle;
②The operating environment of the process needs to be saved and restored during the interrupt processing process, which requires a certain amount of time and overhead. It can be seen that if the frequency of interrupts is too high, system performance will also be reduced.

1. The process of completing a read/write operation. 2.
Insert picture description here
The frequency of
CPU intervention. CPU intervention is required before and after each l/o operation.
The CPU can switch to another process for execution while waiting for the l/o to complete.

3. The unit of data transmission,
read/write one word at a time

4. The flow of data
Read operation (data input): I/o device → CPu memory write operation (data output): memory → CPU →> I/o device

5. Main shortcomings and main advantages
Advantages : Compared with the "direct program control mode", in the "interrupt drive mode", the I/o controller will actively report that the I/o has been completed through the interrupt signal, and the CPU no longer needs to stop. Poll. The CPU and I/o devices can work in parallel, and the CPU utilization rate has been significantly improved.
Disadvantages : Each word transfer between the /o device and the memory needs to go through the CPU. Frequent interrupt processing will consume more CPU time.

DMA method

Compared with the "interrupt-driven mode", the DMA mode (Direct Memory Access. Mainly used for 1/o control of block devices) has several improvements:
①The unit of data transfer is "block". It is no longer a word, a word transmission;
②The flow of data is from the device directly into the memory, or from the memory directly to the device. The CPU is no longer needed as a "courier"
③The intervention of the CPU is only required at the beginning and end of transmitting one or more data blocks.

Insert picture description here
Insert picture description here

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 number of bytes remaining to be read/written.
CR (Command Register, command/status register): Used to store the I/O commands sent by CPu, or the status information of the device.

1. The process of completing a read/write operation
Insert picture description here

2. The frequency of
CPU intervention The CPU intervention is only required at the beginning and end of transmitting one or more data blocks.

3. The unit of data transmission.
Read/write one or more blocks at a time** (Note: Only consecutive blocks can be read and written each time,
and these blocks must be consecutive in the memory after they are read into the memory. )**

4. Data flow (no longer need to go through cPu)
Read operation (data input): I/o device → memory
Write operation (data output): memory → I/o device

5. Main shortcomings and main advantages
Advantages : Data transmission takes "block" as the unit, and the CPU intervention frequency is further reduced. Data transmission no longer needs to pass through the CPU and then write to the memory, and the efficiency of data transmission is further increased. The parallelism of CPU and I/o devices has been improved.
Disadvantages : CPu can only read/write one or more consecutive data blocks every time an l/o ​​instruction is issued.
If you want to read/write multiple discretely stored data blocks, or write data to different memory areas, the CPU must issue multiple I/o instructions, and perform multiple interrupt processing to complete.

Channel control method

Channel: A kind of hardware, which can be understood as **"weak version of CPU"**. The channel can recognize and execute a series of channel commands

Insert picture description here
1. The process of completing a read/write operation
Insert picture description here

2. The frequency of
CPU intervention is extremely low. The channel will execute the corresponding channel program according to CPu's instructions. Only after completing the reading/writing of a set of data blocks, an interrupt signal is required to request CPU intervention.

3. Data transfer unit
Read/write a group of data blocks at a time
4. Data flow direction (under the control of the channel)
Read operation (data input): I/o device → memory
write operation (data output): memory → >I/o Equipment

5. Main disadvantages and main advantages
Disadvantages : complex implementation, special channel hardware support is required.
Advantages : CPU, channel, and l/o devices can work in parallel, and resource utilization is high.

to sum up

Insert picture description here

Guess you like

Origin blog.csdn.net/Shangxingya/article/details/113813458