Copyright (慣C) 2019 宅色夫
中斷處理相信是人們不陌生的主題,甚至在中學生的計算機概論教材都出現這字眼,但在 Linux (或任何有規模的作業系統核心) 裡頭,中斷處理背後涉及的硬體特性、多種周邊 I/O、中斷控制器 (如是否支援 nested)、相關的排程和任務調度、延遲和即時處理等等,仍舊讓工程人員頭痛,特別將多核處理器、虛擬化技術,和為了實踐資訊安全而進行的隔離執行納入考量之後。
在本講座中,我們會從硬體特性著手,簡述 Intel 和 Arm 架構的中斷處理機制,再回頭看 Linux 核心的 softirq, tasklet, workqueue 用來實現中斷處理,並討論 request_threaded_irq / request_irq (這和引入 PREEMPT_RT 有高度關聯) 的用法,之後則針對多核處理器的架構去思考 Linux 核心的中斷處理做了哪些變革,搭配虛擬化和 Arm TrustZone 及 Intel SGX 的支援納入後,又有什麼需要深度分析的技術議題。
/* <include/linux/interrupt.h> */
struct softirq_action {
void (*action)(struct softirq_action *);
};
A kernel thread to process deferred softIRQs (per CPU)
/* kernel/softirq.c */
static void run_ksoftirqd(unsigned int cpu) {
local_irq_disable();
if (local_softirq_pending()) {
__do_softirq();
rcu_note_context_switch(cpu);
local_irq_enable();
cond_resched();
return;
}
local_irq_enable();
}
tasklet_schedule( struct tasklet_struct *t)
tasklet_hi_schedule( struct tasklet_struct *t)
tasklet_disable()
/ tasklet_kill()
tasklet_enable()
bh
) 呢?降低 interrupt latency,將工作切割為以下:
v4.15
需要做點調整: 將 char/char_example.c
的 #include <asm/uaccess.h>
換為 #include <linux/uaccess.h>
(為了 copy_to_user()
)char/
, misc/
, sysfs/bin_attr/
Clock signals.
(a)
For level-triggered circuits. (b) For positive-edge triggering.(c)
For negative-edge triggering.
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing