Comparison between interrupt mode and polling Mode

Source: Internet
Author: User
Basic concepts of Interruption

Program interruption is generally referred to as interruption. It means that the CPU is interrupted by running programs due to pre-selection or various random internal or external events, it is transferred to the corresponding service program for processing. This process is called program interruption.

Ii. 80x86 microprocessor interrupt: 80x86 microprocessor interrupt types are generally divided into two categories, that is, the Soft Interrupt caused by executing certain commands and the hard interrupt caused by the interrupt request signal sent by other control circuits other than the processor.
To transfer the CPU from the main program to the interrupted service program, you must know the endpoint address of the interrupted service program, that is, the interrupt vector. There are a total of 256 interrupt vectors for a cpu pc on X.

General process of Interruption:

The main program only processes the data of devices A, B, and C when they are ready.
, C, for data exchange. When a slow peripheral device prepares its own data, the CPU runs its main program as usual. In this sense, some operations on the CPU and peripheral devices are performed in parallel, so the efficiency of the computer system is greatly improved compared with the serial program query method. For example:

The actual interrupt process is more complex, showing the detailed flowchart of the interrupt processing process. when the CPU executes the current command, if the peripheral sends an interrupt request to the CPU, when the CPU meets the response conditions, it will send an interrupt response signal, at the same time, the interruption is disabled (the "interrupt shielding" trigger sets "1"), indicating that the CPU will no longer accept the interruption of another device. At this time, the CPU will look for the device where the interrupt request source is. And save the content of the CPU's own program counter (PC. then, it will be transferred to the interrupt service program that processes the interrupt source. the CPU is storing on-site information, after the device (such as text for data. site Information will be restored. after these actions are completed, open the interrupt (the "interrupt shield" trigger sets "O") and return to the next instruction of the originally interrupted main program.

(1) Although the external interrupt request is random, the CPU can only accept the interrupt request of the device after the current command is executed, that is, when it is transferred to the Public operation, this will not affect the execution of the current command. A public operation is an operation performed by the CPU after a command is executed, such as interrupt processing, Direct Memory transfer, and command removal. The external interrupt request signal is usually stored in the interrupt source latches in the interface and connected to the CPU through the interrupt request line. When a command is executed to the end, the CPU checks the interrupt request signal. If the interrupt request signal is "1", the CPU is transferred to"
Interruption cycle ", accepting external interruptions. (2)
To correctly return to the interrupted breakpoint (PC content) of the original main program after the interrupted service program is executed, you must continue to execute the main program, and the CPU status (including the register content and some status signs) after the execution of the current command is completed are saved to the stack. These operations are called on-site storage. (3)
When the CPU responds to an interrupt and is about to execute the interrupt service program, another new interrupt source may send an interrupt request to it. To avoid confusion, there must be an interrupt blocking trigger in the interrupt management part of the CPU. It can be set to "1" (set to block) under the control of the program ), or set "0 ). The CPU can accept the interruption only when the interruption shield mark is "0. When a command is executed and the CPU receives the interrupt request and responds, it sends the interrupt response signal INTA, and sets the interrupt shield mark to "1", that is, the interrupt is disabled. In this way, the CPU can no longer accept interrupt requests from other new interrupt sources. The interrupt shielding flag is set to "0" only after the CPU executes the interrupt service program. That is, the interrupt is opened and the main program is returned. Therefore, the interrupted service program must end with two commands, namely, the interrupt command and the return command. At the same time, the hardware must ensure that the return command is executed before receiving new interrupt requests. (4)
The interrupt handling process is completed by combining hardware and software. As shown in the preceding figure, the interrupt cycle is implemented by hardware, while the interrupt service program is implemented by the machine instruction sequence. In addition to saving the site, restoring the site, opening the interruption, and returning the master program task, the latter performs services on the equipment that requires interruption so that it can exchange one word of data with the CPU, or other services.

Basic concepts of round robin

Polling I/O mode or program-controlled I/o mode allows the CPU to query each peripheral in order in a certain period of time to see if it has data input or output requirements, if yes, the corresponding input/output service is performed. If no, or I/O processing is complete, the CPU then queries the next peripheral.

Required hardware: The peripheral interface provides the status port and data port.

Software mechanism: the application must regularly query the status ports of each interface to determine whether data needs to be input or output. If necessary, data operations are performed through the data port.

Features: the CPU actively queries external devices by executing commands, and the external devices are passive.

Is a general process.

Speed of comparison between polling mode and interrupt mode

Program Control Method:

Hardware speed indicator: because the "program control mode" completely controls the peripheral interface by means of software, its hardware operation is only a common port read/write, and there is no special difference, the Speed indicators are jointly determined by the bus transmission speed and port response speed.

For this type of peripheral control, the key to speed indicators is software.

Interrupt handling method:

The atomic operation explanation of the interrupt handling method is the same as that of the program control method.

However, because the interrupt request and response mechanisms are added, the reading of the Status port becomes the reading of the interrupt number during the interrupt response process, the status port is determined by the interrupt entry address.

Essentially, there is no big difference between the interrupt handling method and the speed indicator of the program control method itself.

Reliability

Program Control Method:

Because the hardware does not support the interrupt mode, the operating system gives the CPU control to the application, as long as the application does not return the CPU control, the operating system is always unable to restore the control of the CPU (no scheduled interruption ). Applications and operating systems are both software modules, and the operating system is a core module. There is a relationship between them to control the CPU. Because of this relationship, once the "Program Control Method" of peripherals is used, the application will experience a deadlock, and the operating system will never be able to recover the control of the system. Application faults are distributed to the operating system as the core module through peripheral control. Therefore, according to the calculation of associated reliability indicators, the associated Reliability Indicators of "program control mode" are very low.

Interrupt handling method:

Due to scheduled interruption, the operating system can regain control of the CPU after the current time slice of the application ends. Application faults do not affect the operating system. Therefore, the associated Reliability Indicators of interrupt handling methods are high.

Scalability

Program Control Method:

Because all applications contain port operations, once the design of the hardware interface changes, all applications must be modified, which will increase the modification cost many times. Therefore, the program control method will make the local modification indicators of the relevant hardware modules relatively low.

Interrupt handling method:

The application does not directly operate on the port. operations on the port are performed by the interrupt service program. If the design of a hardware interface changes, you only need to modify its interrupt service program. Therefore, the interrupt processing method makes the local modification indicators of the relevant hardware modules relatively high.

Life Cycle

The "Program Control Method" (CPU query method) can meet application requirements in early computer systems. However, as the number of external devices increases and the speed varies, this method has gradually become an obstacle to system performance improvement. Its life cycle was limited to the early computer stage, because there were few external devices and they were all low-speed devices. After the appearance of eight-bit machines, this peripheral control mode (Architecture) was eliminated.

The interrupt processing method can coordinate the speed difference between the CPU and peripherals, coordinate the speed difference between various peripherals, and improve the efficiency (speed indicator) of the system ). The application and peripheral operations are basically separated, reducing the device relevance of the Program (associated Reliability Indicators, partial modification indicators ). Although some fast devices do not communicate with each other through the CPU or interrupt processing method, the interrupt processing method is still the most effective for handling slow devices or device faults. No matter how the components in the computer system change in the future, as long as there is a conflict between the slow device and the fast CPU, interrupt processing is suitable. Even if you do not use the interrupted service program, the concept of interruption will last for a long time. In a short period of time, computer systems cannot leave human interaction in all fields, and human operations must be slower than machine processing, therefore, the slow device will still exist (but this is not the only reason for the existence of the slow device ). Because of this demand, the interrupt processing method has a long life cycle.

Address: http://shaodasheng10.blog.163.com/blog/static/487310642008316102834928/

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.