Linux interrupts and exceptions Basics

  
 

Q1. What is an interruption? What is an exception? What is the difference between the two?

A:

1) Interrupt control is generated to overcome the processor inefficiency caused by the use of program query control services on the I/O interface. Its main advantage is that only The response of the processor is obtained when the I/O interface needs service, and the processor does not need to continuously query; therefore, the initial interrupt is all for the external device, called external interrupt (or hardware interrupt); Br>

2) An exception is also called an internal interrupt. It is generated to solve some random events and programming conveniences when the machine is running.

3) 256 types of interrupts are externally available. Masked Interrupt (INTR) and External Non-Maskable Interrupt (NMI), interrupt requests (IRQ) generated by all I/O devices cause maskable interrupts, and faults caused by emergency events (such as hardware faults) generate non-maskable interrupts; Br>

4) Exceptions are further divided into faults and traps. Their common feature is that neither the interrupt controller nor the mask is used (the exception is actually the terminal signal sent by the CPU).


Q2. What is an interrupt vector? How does Linux allocate interrupt vectors?

A:

1) In order for the processor to easily identify each interrupt source, 256 vector interrupts are numbered from 0 to 255, that is, an interrupt type code n is assigned. Call this 8-bit unsigned integer a vector, the interrupt vector;

2) Linux allocates 256 interrupt vectors as follows:

A. Vectors numbered 0~31 correspond to Abnormal and non-maskable interrupts;

B. Vectors numbered 32~47 (ie interrupts caused by I/O devices) are assigned to maskable interrupts;

C. Remaining, numbering Vectors of 48 to 255 are used to identify soft interrupts; Linux uses only one of them (ie 128 or 0x80 vectors) to implement system calls.


Q3. What is the interrupt descriptor table? What is a door descriptor?

A:

1) In real-address mode, the CPU uses 1KB of space starting from 0 as an interrupt vector table, and each entry in the table occupies 4 bytes. However, in the protection mode, the interrupt vector table consisting of 4 bytes of entries cannot satisfy the requirement; therefore, in the protection mode, the entries in the interrupt vector table are composed of 8 bytes, and the interrupt vector table is also called the interrupt description. Tables (IDT);

2) Each entry in the IDT is called a gate descriptor.


Q4. What types of gate descriptors are there? What are the different among its?

A: The type code in the gate descriptor occupies 3 bits, indicating the type of the gate descriptor, which is mainly divided into the following categories:

1) Interrupt gate: its type code Is 110, contains the selector and segment offset of the segment where the interrupt or exception handler is located;

2) Trap gate: its type code is 111;

3) System gate: It is specially set by the Linux kernel to allow user-mode processes to access trapdoors.

Copyright © Windows knowledge All Rights Reserved