@@ -28,12 +28,12 @@ What is an interrupt?
28
28
29
29
An interrupt is an event that alters the normal execution flow of a
30
30
program and can be generated by hardware devices or even by the CPU
31
- itself. When in interrupt occurs the current flow of execution is
31
+ itself. When an interrupt occurs the current flow of execution is
32
32
suspended and interrupt handler runs. After the interrupt handler runs
33
33
the previous execution flow is resumed.
34
34
35
35
Interrupts can be grouped into two categories based on the source of
36
- the interrupt. They can also be grouped in two other categories based
36
+ the interrupt. They can also be grouped into two other categories based
37
37
on the ability to postpone or temporarily disable the interrupt:
38
38
39
39
.. slide :: Interrupts
@@ -48,13 +48,13 @@ on the ability to postpone or temporarily disable the interrupt:
48
48
49
49
* can be ignored
50
50
51
- * signalled via INT pin
51
+ * signaled via INT pin
52
52
53
53
* **non-maskable **
54
54
55
55
* cannot be ignored
56
56
57
- * signalled via NMI pin
57
+ * signaled via NMI pin
58
58
59
59
Synchronous interrupts, usually named exceptions, handle conditions detected by the
60
60
processor itself in the course of executing an instruction. Divide by zero or
@@ -67,7 +67,7 @@ that a packet has arrived.
67
67
Most interrupts are maskable, which means we can temporarily postpone
68
68
running the interrupt handler when we disable the interrupt until the
69
69
time the interrupt is re-enabled. However, there are a few critical
70
- interrupts that can not be disabled / postponed.
70
+ interrupts that can not be disabled/ postponed.
71
71
72
72
Exceptions
73
73
----------
@@ -90,7 +90,7 @@ There are two sources for exceptions:
90
90
91
91
- **int n **
92
92
93
- Processor detected exceptions are raised when an abornmal condition is
93
+ Processor detected exceptions are raised when an abnormal condition is
94
94
detected while executing an instruction.
95
95
96
96
A fault is a type of exception that is reported before the execution of the
@@ -100,7 +100,7 @@ the program can re-execute the faulty instruction. (e.g page fault).
100
100
101
101
A trap is a type of exception that is reported after the execution of the
102
102
instruction in which the exception was detected. The saved EIP is the address
103
- of the instruction after the instuction that caused the trap. (e.g debug trap).
103
+ of the instruction after the instruction that caused the trap. (e.g debug trap).
104
104
105
105
Quiz: interrupt terminology
106
106
---------------------------
@@ -109,7 +109,7 @@ Quiz: interrupt terminology
109
109
:inline-contents: True
110
110
:level: 2
111
111
112
- For each of the following term on the left select all the terms
112
+ For each of the following terms on the left select all the terms
113
113
from right that best describe them.
114
114
115
115
.. hlist ::
@@ -159,7 +159,7 @@ Programmable Interrupt Controller
159
159
| | | |
160
160
+-----------+ +------------+
161
161
162
- A device supporting interrupts has an output pin used for signalling an Interrupt ReQuest. IRQ
162
+ A device supporting interrupts has an output pin used for signaling an Interrupt ReQuest. IRQ
163
163
pins are connected to a device named Programmable Interrupt Controller (PIC) which is connected
164
164
to CPU's INTR pin.
165
165
@@ -178,10 +178,10 @@ the current interrupt.
178
178
179
179
.. note ::
180
180
181
- Once the interrupt is acknowledge by the CPU the interrupt
181
+ Once the interrupt is acknowledged by the CPU the interrupt
182
182
controller can request another interrupt, regardless if the CPU
183
183
finished handled the previous interrupt or not. Thus, depending on
184
- how the OS controlls the CPU it is possible to have nested
184
+ how the OS controls the CPU it is possible to have nested
185
185
interrupts.
186
186
187
187
The interrupt controller allows each IRQ line to be individually
@@ -352,7 +352,7 @@ Quiz: hardware concepts
352
352
Interrupt handling on the x86 architecture
353
353
==========================================
354
354
355
- This section will examine how interupts are handled by the CPU on the
355
+ This section will examine how interrupts are handled by the CPU on the
356
356
x86 architecture.
357
357
358
358
Interrupt Descriptor Table
@@ -375,7 +375,7 @@ An IDT has the following characteristics:
375
375
* processor locates IDT by the means of IDTR
376
376
377
377
Below we can find Linux IRQ vector layout. The first 32 entries are reserved
378
- for exceptions, vector 128 is used for sycall interface and the rest are
378
+ for exceptions, vector 128 is used for syscall interface and the rest are
379
379
used mostly for hardware interrupts handlers.
380
380
381
381
.. slide :: Linux IRQ vector layout
@@ -417,16 +417,16 @@ used mostly for hardware interrupts handlers.
417
417
418
418
On x86 an IDT entry has 8 bytes and it is named gate. There can be 3 types of gates:
419
419
420
- * interrupt gate, holds the address of an interupt or exception handler.
420
+ * interrupt gate, holds the address of an interrupt or exception handler.
421
421
Jumping to the handler disables maskable interrupts (IF flag is cleared).
422
- * trap gates, similar with an interrupt gate but it does not disable maskable
423
- interrupts while jumping to interupt /exception handler.
422
+ * trap gates, similar to an interrupt gate but it does not disable maskable
423
+ interrupts while jumping to interrupt /exception handler.
424
424
* task gates (not used in Linux)
425
425
426
- Lets have a look at several fields of an IDT entry:
426
+ Let's have a look at several fields of an IDT entry:
427
427
428
428
* segment selector, index into GDT/LDT to find the start of the code segment where
429
- the interupt handlers resides
429
+ the interrupt handlers reside
430
430
* offset, offset inside the code segment
431
431
* T, represents the type of gate
432
432
* DPL, minimum privilege required for using the segments content.
@@ -459,7 +459,7 @@ In order to find the interrupt handler address we first need to find the start
459
459
address of the code segment where interrupt handler resides. For this we
460
460
use the segment selector to index into GDT/LDT where we can find the corresponding
461
461
segment descriptor. This will provide the start address kept in the 'base' field.
462
- Using base address and the offset we can now go at the start of the interrupt handler.
462
+ Using base address and the offset we can now go to the start of the interrupt handler.
463
463
464
464
465
465
.. slide :: Interrupt handler address
@@ -498,7 +498,7 @@ Using base address and the offset we can now go at the start of the interrupt ha
498
498
Stack of interrupt handler
499
499
--------------------------
500
500
501
- Similar with control transfer to a normal function, a control transfer
501
+ Similar to control transfer to a normal function, a control transfer
502
502
to an interrupt or exception handler uses the stack to store the
503
503
information needed for returning to the interrupted code.
504
504
@@ -552,7 +552,7 @@ Handling an interrupt request
552
552
-----------------------------
553
553
554
554
After an interrupt request has been generated the processor runs a sequence of
555
- events that eventually ends up with running the kernel interrupt handler:
555
+ events that eventually end up with running the kernel interrupt handler:
556
556
557
557
558
558
.. slide :: Handling an interrupt request
@@ -573,9 +573,9 @@ events that eventually ends up with running the kernel interrupt handler:
573
573
Returning from an interrupt handler
574
574
-----------------------------------
575
575
576
- Most architectures offers special instructions to clean- up the stack and resume
576
+ Most architectures offer special instructions to clean up the stack and resume
577
577
the execution after the interrupt handler has been executed. On x86 IRET is used
578
- to return from an interrupt handler. IRET is similar with RET except that IRET
578
+ to return from an interrupt handler. IRET is similar to RET except that IRET
579
579
increments ESP by extra four bytes (because of the flags on stack) and moves the
580
580
saved flags into EFLAGS register.
581
581
@@ -585,7 +585,7 @@ To resume the execution after an interrupt the following sequence is used (x86):
585
585
:inline-contents: True
586
586
:level: 2
587
587
588
- * pop the eror code (in case of an abort)
588
+ * pop the error code (in case of an abort)
589
589
* call IRET
590
590
591
591
* pops values from the stack and restore the following register: CS, EIP, EFLAGS
@@ -645,8 +645,8 @@ actions will also be performed (e.g. acknowledge the interrupt at the interrupt
645
645
controller level). Local processor interrupts are disabled for the duration of
646
646
this phase and continue to be disabled in the next phase.
647
647
648
- In the second phase all of the device drivers handler associated with this
649
- interrupt will be executed. At the end of this phase the interrupt controller's
648
+ In the second phase, all of the device driver's handlers associated with this
649
+ interrupt will be executed. At the end of this phase, the interrupt controller's
650
650
"end of interrupt" method is called to allow the interrupt controller to
651
651
reassert this interrupt. The local processor interrupts are enabled at this
652
652
point.
@@ -657,12 +657,12 @@ point.
657
657
devices and in this case it is said that the interrupt is
658
658
shared. Usually, when using shared interrupts it is the
659
659
responsibility of the device driver to determine if the interrupt
660
- is target to it's device or not.
660
+ is target to its device or not.
661
661
662
662
Finally, in the last phase of interrupt handling interrupt context deferrable
663
663
actions will be run. These are also sometimes known as "bottom half" of the
664
664
interrupt (the upper half being the part of the interrupt handling that runs
665
- with interrupts disabled). At this point interrupts are enabled on the local
665
+ with interrupts disabled). At this point, interrupts are enabled on the local
666
666
processor.
667
667
668
668
.. slide :: Interrupt handling in Linux
@@ -697,7 +697,7 @@ ago in order to avoid increasingly complex solutions to stack
697
697
overflows issues - allow just one level of nesting, allow multiple
698
698
levels of nesting up to a certain kernel stack depth, etc.
699
699
700
- However it is still possible to have nesting between exceptions and
700
+ However, it is still possible to have nesting between exceptions and
701
701
interrupts but the rules are fairly restrictive:
702
702
703
703
.. slide :: IRQ and exception nesting in Linux
@@ -771,7 +771,7 @@ interface and the network card buffer is full).
771
771
772
772
Deferrable actions have APIs to: **initialize ** an instance, **activate ** or
773
773
**schedule ** the action and **mask/disable ** and **unmask/enable ** the execution
774
- of the callback function. The later is used for synchronization purposes between
774
+ of the callback function. The latter is used for synchronization purposes between
775
775
the callback function and other contexts.
776
776
777
777
Typically the device driver will initialize the deferrable action
@@ -783,18 +783,18 @@ structure during the device instance initialization and will activate
783
783
:level: 2
784
784
785
785
786
- * Schedule callback functions to run a later time
786
+ * Schedule callback functions to run at a later time
787
787
788
788
* Interrupt context deferrable actions
789
789
790
790
* Process context deferrable actions
791
791
792
- * APIs for initialization, scheduling and masking
792
+ * APIs for initialization, scheduling, and masking
793
793
794
794
Soft IRQs
795
795
---------
796
796
797
- Soft IRQs is the term used for the low level mechanism that implements deferring
797
+ Soft IRQs is the term used for the low- level mechanism that implements deferring
798
798
work from interrupt handlers but that still runs in interrupt context.
799
799
800
800
.. slide :: Soft IRQs
0 commit comments