Traditional Culture Encyclopedia - Traditional culture - What is the interrupt instruction in linux system?
What is the interrupt instruction in linux system?
The Linux kernel needs to manage all the hardware devices connected to the computer, which is undoubtedly its job. If you want to manage these devices, you must communicate with them first. Generally speaking, there are two schemes to achieve this function:
Polling allows the kernel to periodically query the status of the device and then make corresponding processing; Interrupt allows hardware to send signals to the kernel when needed (change the kernel initiative to hardware initiative).
The first scheme will make the kernel do a lot of useless work, because polling will always be repeated periodically, consuming a lot of CPU time, so the efficiency is extremely low, so the second scheme is generally adopted.
For the understanding of interruption, let's first look at a common example in life: QQ. The first situation: you are working, and then your friend suddenly sends you a window jitter, interrupting your ongoing work. sequence
Two situations: Of course, you sometimes check QQ every five minutes.
See if any friends are looking for you, although it's a waste of your time. Here, a window jitter can be equivalent to hardware interrupt, while you are equivalent to CPU, and your job is CPU.
This is in the process of implementation. And regular query is equivalent to CPU polling. As can be seen here, as a communication mode between CPU and hardware, interrupt is an active mode of hardware, which is more active than polling (CPU).
Active) is more effective, because we can't always check the friend list bored every few minutes.
cpu
There is a lot of work to deal with, not to mention doing a lot of useless work. Of course, this is just the general situation. Okay, one more question. Every hardware device is interrupted, so how to distinguish different hardware? Different designs
How do you know which interrupt is from the hard disk and which is from the network card? It's simple. Isn't every QQ number different? Similarly, each hardware device on the system will be assigned one.
IRQ number, through this unique IRQ number, Zhang San and Li Si can be distinguished.
From a physical point of view, an interrupt is generated by a hardware device and sent directly to an interrupt controller (e.g.
8259A), and then the interrupt controller sends corresponding signals to the processor. Once the processor detects the signal, it will interrupt the work currently being processed and handle the interrupt instead. Since then,
The processor informs the operating system that an interrupt has been generated. In this way, OS
This interrupt can be handled appropriately. Different devices correspond to different interrupts, and each interrupt has a unique number identification. These values are often referred to as interrupt request lines.
- Previous article:History of Huizhou Merchants
- Next article:The performance of a hen husband who loves his wife.
- Related articles
- The Origin and Folklore of Dragon Boat Festival
- The difference between the display and touch screen
- What does it mean when Tibetans build stone piles?
- Classification of Buddha statues
- Are there any special products in Henan that can be given away?
- Is there anything particular about three bows?
- The allusion to the overlapping of hair on the left side of the head
- How about Hebei Wuzhou Kaiyuan Environmental Protection New Materials Co., Ltd.?
- An empirical model for teachers to change their ideas
- What's so particular about tattooed carp? Please give me some advice.