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
xxxxxxxxxx
2024q1 Homework6 (integration)
contributed by < williamlin0518 >
實驗環境
閱讀 linux 核心模組教材
Linux 核心模組運作原理
Showing hello module doesn't have a valid signature
Trace linux kernel insmod
sudo strace insmod fibdrv.ko
Library and Dependency Loading
when user-space program executed, requires libraries to perform its functions
openat()
,read()
,fstat()
,mmap()
: open library files, check their properties, map them into memory,MODULE_LICENSE
specifies the licensing terms under which the kernel module is distributed.
Symbol Table
Linux kernel maintains a symbol table, where all exported symbols from the kernel and loaded modules are registered.
Module File Handling
openat()
: opens thefibdrv.ko
file for reading.newfstatat()
: onfirming that the file is accessible and properly formatted.Kernel Module Loading
finit_module()
: load the kernel module into the Linux kernel. The call takes a file descriptor pointing to the module file,kernel module 前置作業
自我檢查清單
實體電腦運行 GNU/Linux
閱讀〈Linux 核心模組運作原理〉並對照 Linux 核心原始程式碼 (v6.1+),解釋
insmod
後,Linux 核心模組的符號 (symbol) 如何被 Linux 核心找到 (使用 List API)、MODULE_LICENSE
巨集指定的授權條款又對核心有什麼影響 (GPL 與否對於可用的符號列表有關),以及藉由 strace 追蹤 Linux 核心的掛載,涉及哪些系統呼叫和子系統?閱讀《The Linux Kernel Module Programming Guide》(LKMPG) 並解釋 simrupt 程式碼裡頭的 mutex lock 的使用方式,並探討能否改寫為 lock-free;
探討 Timsort, Pattern Defeating Quicksort (pdqsort) 及 Linux 核心 lib/sort.c 在排序過程中的平均比較次數,並提供對應的數學證明;
研讀 CMWQ (Concurrency Managed Workqueue) 文件,對照 simrupt 專案的執行表現,留意到 worker-pools 類型可指定 "Bound" 來分配及限制特定 worker 執行於指定的 CPU,Linux 核心如何做到?CMWQ 關聯的 worker thread 又如何與 CPU 排程器互動?
解釋
xoroshiro128+
的原理 (對照〈Scrambled Linear Pseudorandom Number Generators〉論文),並利用 ksort 提供的xoro
核心模組,比較 Linux 核心內建的/dev/random
及/dev/urandom
的速度,說明xoroshiro128+
是否有速度的優勢?其弱點又是什麼?解釋 ksort 如何運用 CMWQ 達到並行的排序;