Three possible technologies are available for I/O operations: programmable I/O, interrupt driver I/O, and direct memory access (DMA)
Programmable I/O
When the processor is executing a program and encounters an I/O-related command, it sends a command to the corresponding I/O module to execute this command. When programmable I/O operations are used, the I/O module executes the request action and sets the corresponding bit in the I/O status register. It does not further notify the processor, in particular, it does not interrupt the processor. Therefore, after executing the I/O command, the processor should regularly check the status of the I/O module to determine whether the I/O operation has been completed.
If this technology is used, the processor is responsible for extracting data from the memory for output and storing data in the memory for input. I/O software should be designed to execute commands for direct control of I/O operations by processors, including checking device status, sending read commands or writing commands and transmitting data, therefore, the instruction set includes the following types of I/O commands:
Control: Used to activate an external device and tell it what to do.
Status: used to test various status conditions related to the I/O module and its peripheral devices.
Transfer: used to read or write data between memory registers and external devices.
Disadvantage: this is a time-consuming processing, and the processor is always busy.
Interrupt driver I/O
The processor sends an I/O command to the module and then continues to do other useful work. When the I/O module is ready to exchange data with the processor, it will interrupt the execution of the processor and request the service. The processor executes data transfer as before, and then restores the previous execution process of the processor.
Disadvantage: because each word in the data, from memory to I/O module or from I/O module to memory, must be processed by a processor, this causes the interruption of the driver I/O to still take a lot of processor time.
Direct Memory Access
For the first two forms of I/O, the processor needs to actively intervene in data transmission between the memory and the I/O module, and any data transmission must be completely through the processor. Therefore, the first two I/O forms are inherently defective in two aspects:
I/O transmission speed is limited by the speed at which the processor test equipment and services are provided
The processor is busy managing I/O transfers and must execute many commands to complete I/O transfers.
When you need to move a large amount of data, you need to use a more effective technology: Direct Memory Access (DMA ). The DMA function can be completed by an independent module in the system bus or integrated into an I/O module. Either way, this technology works as follows: when the processor needs to read or write a piece of data, it generates a command for the DMA module and sends the following information:
Whether to request one read or write
Address of the involved I/O device
Memory Unit for reading or writing
Number of words to be read or written
Then the processor continues to work. The processor delegates this operation to the DMA module, which is responsible for processing. The DMA module Directly Interacts with the memory, transmits the entire data block, and transmits one word each time (16-bit system ). This process requires no processor involvement. After the transfer is complete, the DMA module sends an interrupt signal to the processor. Therefore, the processor is involved only when the transfer starts and ends.
The DMA module needs to control the bus to facilitate data transmission in the memory. Due to competition in bus usage, the DMA module needs to be waited when the processor needs to use the bus. Note that this is not an interruption, and the processor does not save the context to do other things, instead, it only suspends a bus cycle (the time when one word is transferred on the bus (a 16-bit System )). The overall impact is that the processing speed slows down when the processor needs to access the bus during DMA transmission.
The following is a flowchart of the three technologies:
Zookeeper