Operating system IO mode

1. Program query method
   The program query mode is a direct control mode of the program, which is the simplest way to exchange information between the host computer and the peripheral device. The input and output are completely completed by the CPU executing the program. Once a peripheral is selected and started, the host will poll some status bits of the peripheral to see if it is ready? If the peripheral is not ready, the host will poll again; if the peripheral is ready, an I/O operation is performed. This method is simple to control, but the peripherals and the host cannot work at the same time, and the peripherals cannot work at the same time, and the system efficiency is very low. Therefore, it is only suitable for a small number of peripherals and real-time requirements for I/O processing. Not so high, the CPU has a relatively single operation task and is not very busy.
 
2. Program interruption method
       After the host starts the peripheral, it does not need to wait for the query, but continues to execute the original program. When the peripheral is ready for input and output, it sends an interrupt request to the host. After the host receives the request, it temporarily suspends the originally executed program and transfers to Execute the interrupt service routine to process the external request, and return to the original program to continue execution after the interrupt processing is completed. Obviously, program interruption is not only applicable to the input and output operations of external devices, but also to the processing of random events that occur in the outside world. Completing a program interrupt also requires many auxiliary operations, which are mainly suitable for medium and low-speed peripherals.
 
3. Direct memory access (DMA) method
  The DMA method is to open up a direct data path between the main memory and the peripherals, and it can carry out information transfer between the main memory and the peripherals without CPU intervention. peripheral needs. The DMA method can only perform simple data transfer operations. At the beginning and end of the data block transfer, the CPU and the interrupt system need to be pre-processed and post-processed.
 
When a device interface tries to send data (usually in large batches) directly to another device over the bus, it will first send a DMA request signal to the CPU. Through a special interface circuit of DMA, the DMA controller (DMAC), the peripheral makes a bus request to the CPU to take over the control of the bus. After the CPU receives the signal, after the current bus cycle ends, it will press the DMA signal. The priority and the order in which DMA requests are made respond to DMA signals. When the CPU responds to a DMA request to a device interface, it will give up bus control. Therefore, under the management of the DMA controller, the peripherals and the memory exchange data directly without CPU intervention. After the data transfer is completed, the device interface will send the DMA end signal to the CPU to return the bus control.
 
The basic operations to implement DMA transfer are as follows:
 
(1) The peripheral can issue a DMA request to the CPU through the DMA controller:
 
(2) The CPU responds to the DMA request, the system changes to the DMA working mode, and transfers the bus control to the DMA controller;
 
(3) The DMA controller sends the memory address and determines the length of the data block to be transmitted;
 
(4) Perform DMA transfer;
 
(5) The DMA operation ends, and the bus control is returned to the CPU.
 
4. I/O channel control mode
 
      The I/O channel control method is a further development of the DMA method. There are channel control components in the system, and each channel is connected to several peripherals. When the host performs I/O operations, it only needs to start the relevant channel, and the channel will execute the channel program. , so as to complete the I/O operation. A channel is a processor with special functions, which can independently execute channel programs, generate corresponding control signals, and realize unified management of peripherals and data transfer between peripherals and main memory. But it's not a completely separate processor. It can only start, stop or change its working state under the command of the CPU's I/O instructions, and it is a dedicated processor subordinate to the CPU.
 
The input and output process of a channel is all handled by the channel itself according to the channel program, no matter how much information is exchanged, and only disturbs the CPU twice (when starting and stopping). Therefore, the host, peripherals, and channels can work in parallel, and one channel can control multiple devices of different types. At present, most of the small and microcomputers use the program query method, the program interrupt method and the DMA method; the large and medium-sized computers mostly use the channel method.
 
Channel working process:
①Use the access control instruction in the user program to enter the management program, and the CPU organizes a channel program through the management program and starts the channel. ②The channel executes the channel program organized by the CPU for it, and completes the specified data input and output work. ③ After the channel program ends, send an interrupt request to the CPU. After the CPU responds to the interrupt request, it enters the operating system for the second time and calls the management program to process the interrupt request. In this way, each time the input and output work is completed, the CPU only needs to call the management program twice, which greatly reduces the disturbance to the user program.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325293766&siteId=291194637