Basics of Linux Programming-what is I/O

Source: Internet
Author: User

I/O is an abbreviation for input/output, i.e. input and output Port . Each device will have a dedicated I/O address to handle its own input and output information. the connection between the CPU and the external device , the memory and the data exchange need to be realized through the interface device, the former is called the I/O interface , and the latter is called the memory interface. Memory is usually in the synchronization of the CPU operation, the interface circuit is relatively simple, and I/O device variety, and its corresponding interface circuit is also different, so it is customary to say that the interface is only referring to the I/O interface .

1 Interface ClassificationEdit

The function of the I/O interface is responsible for implementing CPU system bus the I/O circuit and Peripheral Equipment in connection with the complexity of circuits and devices, the I/O interface hardware is divided into two main categories:

(1) I/O interface Chip

Most of these chips are IC , through the CPU input different commands and parameters, and control the relevant I/O circuit and simple peripherals for the corresponding operation, common interface chip such as timer counter, interrupt controller, DMA Controller, Parallel Interfaces and so on.

(2) I/O Interface control card

by a number of IC As a part of a logical group, or directly with the CPU Motherboard , or a Plugins plugged in system bus the slot.

according to the interface of the connection objects to divide, but also can be divided into Serial Interface , Parallel Interfaces , Keyboard Interface and disk interfaces, and so on.

2 Interface FunctionEdit

because the computer's Peripheral Equipment a wide variety, almost all using electromechanical transmission equipment, therefore, CPU The following issues exist when exchanging data with an I/O device:

Speed mismatch: I/O devices work much slower than CPUs, and because of their different types, the speed difference between them is also very large, for example, the transmission speed of the hard disk will be much faster than the printer.

timing mismatch: each I/O device has its own timing control circuitry that transmits data at its own speed and cannot be CPU the timing of the acquisition is unified.

Information format mismatch: Different I/O device storage and Processing Information formats, for example, can be divided into Serial and the Parallel two species, can also be divided into Binary format, ASCII encoding and the BCD encoding and so on.

information type mismatch: different I/O devices use different types of signals, some are digital signals, and some are Analog Signal , so the processing methods used are also different.

For these reasons, the data exchange between the CPU and the peripheral must be done through an interface, usually with the following functions:

(1) Set the data storage, buffering logic to accommodate the speed difference between the CPU and the peripheral, the interface is usually by some Register Device or RAM chip, if the chip is large enough to achieve the transmission of bulk data;

(2) The ability to convert information formats, such as Serial and the Parallel the conversion;

(3) ability to coordinate CPU and peripherals both in the type of information and level the difference, such as level shifting Drive , digital mode, or Analog-to- digital converters and so on;

(4) Coordination of timing differences;

(5) Address decoding and device selection function;

(6) Set interrupt and DMA control logic to ensure that the interrupt and DMA allow the case to produce interrupts and DMA request the signal and complete after receiving the interrupt and the DMA response Interrupt Handling and the DMA transmission.

3 control modeEdit

CPU through the interface to Peripherals There are several ways to control this:

(1) Program Query method

this way, CPU The I/O instruction asks for the current state of the specified peripheral, and if the peripheral is ready, the input or output of the data, otherwise the CPU waits and loops the query.

The advantage of this way is simple structure, only need a small number of hardware circuit, the disadvantage is because the CPU speed is much higher than the peripheral, so usually in a waiting state, low efficiency

(2) Interrupt Handling Way

in this way, CPU instead of passively waiting, you can execute other programs, and once the peripherals are ready for data exchange, a service request can be made to the CPU , CPU If the response should be requested, the execution of the current program is temporarily stopped, the service program corresponding to the request is executed, and the original interrupted program is completed before proceeding.

Interrupt Handling The advantages of the method are obvious, it is not only for CPU It eliminates the time spent querying peripheral status and waiting for peripherals to be ready, improves CPU productivity, and satisfies the real-time requirements of peripherals. However, each I/O device needs to be assigned an interrupt request number and an appropriate Interrupt service Program , and an interrupt controller (I/O interface chip) is required to manage interrupt requests made by I/O devices, such as setting Interrupt Masking , interrupt request prioritization, and so on.

in addition, Interrupt Handling The disadvantage of the way is that each transmission of a character to interrupt, start the interrupt controller, but also to retain and restore the site so that the original program execution, the cost of a large amount of work, so that if a large number of data exchange, the performance of the system will be very low.

(3) DMA ( Direct Memory Access ) Transfer Mode

one of the most obvious features of DMA is that it is not used Software instead, a dedicated controller is used to control the exchange of data between the memory and peripherals, without CPU intervention, which greatly improves CPU productivity.

in the DMA Data Transfer before, the DMA controller will request the bus control to the CPU, if the CPU allows the control to surrender, therefore, in the data exchange, the bus control is controlled by the DMA controller, at the end of the transmission , DMA Controller return the bus control to CPU .



This article from "LINUXQT Jinan high-tech Zone" blog, please be sure to keep this source http://qtlinux.blog.51cto.com/3052744/1579883

Basics of Linux Programming-what is I/O

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.