alanhc
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- url: https://hackmd.io/bKX8AM18SX2JmmCQ8YwONg title: Glossary of Linux Kernel Terms lastSync: 2025-05-26T00:34:43.220Z hackmd: url: https://hackmd.io/27L57zKRQSqtDFp7rNaTEQ title: Glossary of Linux Kernel Terms lastSync: 2025-05-27T13:02:08.672Z --- ## 📌 建議補充:學習順序建議(基礎 → 進階) | 優先 | 分類 | 主題概述 | | ---- | ------------------------------------------- | ------------------------------------------------------------------ | | ⭐️ 1 | **OS 核心原理(OS Basics)** | user/kernel mode、system calls、POSIX、CPU scheduling | | ⭐️ 2 | **記憶體管理(Memory & Paging)** | page fault、mmap、TLB、huge page、NUMA、cache | | ⭐️ 3 | **排程與執行緒(Scheduler / Thread)** | CFS、runqueue、mutex、futex、spinlock、semaphore、deadlock、atomic | | ⭐️ 4 | **I/O 模型與非同步處理(I/O & Async)** | blocking vs non-blocking、epoll、io_uring、AIO、duplex | | ⭐️ 5 | **中斷與非同步任務排程(Interrupt Scheduling)** | IRQ、softirq、tasklet、workqueue、interrupt context vs process context | | ⭐️ 6 | **執行緒與程序概念(Thread / Process)** | pthread、process/thread 差異、Thread Pool、nice 值調度、critical section | | ⭐️ 7 | **IPC / 系統通訊(IPC & Shared Resources)** | pipe、socket、shared memory、mmap、rpmsg jobs(SoC) | | ⭐️ 8 | **效能分析工具(Profiling & Tracing)** | perf、strace、uftrace、ftrace、microbenchmark、deterministic | | ⭐️ 9 | **Barrier 與協作排程技巧(Barrier & Coordination)** | spin/yield barrier、do_spin、throttle、counter | | ⭐️10 | **並行與 SIMD / 硬體加速(Parallelism & SIMD)** | SIMD、SIMT、vectorization、混合核心調校(P-core/E-core) | | ⭐️11 | **開機流程(Boot & Low-level)** | bootrom、bootloader、kernel loading | | ⭐️12 | **硬體 hazard(Hardware Pipeline Hazard)** | data hazard、control hazard、pipeline stall 概念 | - **1~4 是基礎核心(必學)**:無論做效能分析、驅動開發或用戶空間程式設計,都會遇到 - **5~8 是實作與除錯強化工具包** - **9~12 為進階議題或平台特化**,適合在前幾章熟練後深入 | 學習階段 | 建議學習重點 | 工具/觀念搭配 | | ------- | ---------------------------- | --------------------------------------- | | Phase 1 | OS 核心原理、記憶體、排程 | system call trace、strace | | Phase 2 | I/O 模型、執行緒與同步 | perf/uftrace 分析實驗 | | Phase 3 | 中斷 + 非同步任務排程 | kernel log + ftrace | | Phase 4 | IPC、shared memory、rpmsg | mmap 實作、SoC 環境驗證 | | Phase 5 | SIMD、hazard、硬體效能瓶頸分析 | vectorized loop、flamegraph、cache tuning | | Phase 6 | bootloader、platform bring-up | QEMU 或 ARM dev board 練習 | ## 記憶體管理(Memory & Paging) - 記憶體頁面 - huge page:→一種比標準 4KB 更大的記憶體頁面(如 2MB 或 1GB),減少 TLB misses,提高效能。 - Transparent Huge Page:→Linux 自動將常用的頁面合併為 Huge Page,降低管理負擔。效能不保證穩定。 - mmap→將檔案或設備映射至虛擬記憶體,常用於共享記憶體、I/O 直接讀寫、模型 loading。 - Page Faults:→當記憶體頁不在 RAM 中,CPU 會觸發 Page Fault,把頁面載入。會造成 context switch,效能降低。 - TLB - TLB (Translation Lookaside Buffer):→快速查表虛擬位址與實體位址的緩存。命中率越高,程式執行越快。 - iTLB misses: Instruction TLB miss→表示 CPU 嘗試執行的程式碼位址尚未被快取。會影響效能。 - NUMA - NUMA: Non-Uniform Memory Access→不同 CPU core 存取不同 memory bank 速度不同,需注意排程與記憶體配置 - memory bank: TODO - 效能概念 - axis reordering / interleaving→記憶體存取順序重排,有助於 cache locality 或 SIMD 最佳化。 - Cache / cache miss:→CPU 快取記憶體,miss 時需從 RAM 讀取,增加延遲。 - Cache Coherence: 多核 CPU 快取一致性。 ## 排程與執行緒管理(Scheduler / Thread) - Linux 排程器 - Scheduler:→決定哪個執行緒(Thread)在何時執行的機制。 - O(1) scheduler:→早期的 Linux 排程器,複雜度 O(1),後來被 CFS 取代以提高 fairness。 - CFS (Completely Fair Scheduler)→前身 O(1) scheduler、Fairness: Linux 預設排程器,依照公平原則(virtual runtime)分配 CPU。 - EAS (Energy Aware Scheduler)→考慮能耗與 CPU 載入的排程器,用於行動裝置(big.LITTLE)等異質系統。 - EEVDF (Earliest Eligible Virtual Deadline First)→Linux 6.6 引入,考慮 latency 與 urgency,取代傳統 CFS,更公平。 - runqueue→儲存可執行執行緒的 queue,每個 CPU core 各自擁有一個。 - 同步原語 - mutex / futex→鎖定同步工具,mutex 是自己鎖自己解 futex 是 fast user-space mutex。mutex 則在 user/kernel space 都可存在。 - Deadlock→多個執行緒互相等待對方資源,形成無法繼續的狀態。 - priority inheritance mutex:→為防止 priority inversion,低優先權執行緒持鎖時會暫時提升其優先權。 - spinlock 一種簡單的鎖,使用 busy-wait 的方式等待資源可用。 - semaphore 一種同步原語,可以控制「資源數量」。 範例用途:限制同時能存取資料庫的連線數量。 - atomic operation 原子操作:不可被中斷的基本操作,常用來避免 data race。保證執行過程中不會被其他執行緒干擾。 - Critical Section: 程式處理過程中,不是和同時並行執行的地方稱作 Critical Section 關鍵區域 存取共享資源的區段。 - contention 競爭:多個 thread 同時想存取同一資源(例如鎖、cache line)時產生的衝突。 - 多工模式 - cooperative/preemptively multitasking:→前者需要主動讓出控制權;後者由排程器中斷並切換上下文。 - 協同機制 - Coroutine:→協同式多工,使用者控制的輕量執行緒,常用於 async programming。 - Thread Pool:→預先建立固定數量的執行緒以處理任務,減少動態建立開銷。 - cooperative thread pool: thread 共享同一執行資源池,彼此合作排程以避免過度競爭。 一種 **非搶佔式(cooperative)** 執行緒排程策略,所有 thread 共用一組執行資源,每個 thread 會主動讓出控制權,避免資源競爭,常見於 coroutine、event loop(如 libuv)中。 ## I/O 模型與非同步處理(I/O & Async) - 同步 vs 非同步 - I/O Blocking / Non-blocking I/O:→Blocking 會讓 thread 等待完成;Non-blocking 則立刻返回,靠輪詢或通知處理。 - Non-blocking I/O multiplexing:→多路監聽,如 select()、poll()、epoll()。適用於高並發伺服器。 - epoll:→Linux 下高效能的 I/O 多路複用 API,取代 select/poll。 - Chained Blocking:→多個等待鏈結,容易導致效率低與死鎖。 - 核心層非同步 - Asynchronous I/O (AIO):→真正由 kernel 負責完成,通知應用程式。 - io_uring:→Linux 新 I/O 框架,提供低延遲、非同步、高吞吐量的 I/O 模型。 - I/O Multiplexing:→同時等待多個 I/O 事件,常搭配 event loop 處理。 - duplex:→指雙向 I/O,可同時讀寫。 ## 效能分析與偵錯(Profiling & Tracing) - 工具 - perf:→Linux 原生的效能分析工具,可測量 CPU cycles、cache miss、branch 等。 - uftrace:→追蹤函式呼叫與時間分布(user-space trace)。 - strace:→追蹤所有系統呼叫與錯誤。常用於除錯程式與了解系統行為。 - ftrace:→內建於 Linux 的核心層 trace 工具。適合排查 kernel latency 問題。 - 效能概念 - microbenchmark:→小範圍的程式效能測試,常用於單一 API、演算法、函式比較。 - deterministic:→可重現的結果,不受排程器或資源變動影響。效能測試與分析中非常重要。 - Cache / cache miss:→CPU 快取記憶體,miss 時需從 RAM 讀取,增加延遲。 ## 執行緒與程序(Thread / Process) - API - pthread: - POSIX thread,是 C/C++ 在 Unix/Linux 下的標準多執行緒 API。支援 thread 建立、join、lock(mutex)、condition variable 等基本同步機制。 - 單位定義 - 系統通訊與共享 - IPC (Inter-Process Communication):→多個 process 間的通訊方式,如 pipe、message queue、shared memory、socket。 - Shared memory:→高效的 IPC 方法,process 直接共用記憶體區塊,常搭配 mmap()。 - Rpmsg jobs:→在 ARM/NXP/SoC 上,remote processor messaging,用於 CPU 與 co-processor 間通訊。 - 並行運算與硬體加速 - SIMD (ingle Instruction, Multiple Data)→是一種 並行運算技術,廣泛應用於現代 CPU、GPU 中,用來加速向量與矩陣運算等資料密集型任務,例如音訊/影像處理、機器學習、數值模擬、壓縮演算法等等 - SIMT(Single Instruction, Multiple Threads)→GPU 中一種擴充概念,是「每個 thread 虛擬上看似獨立,其實是 SIMD 式同步執行」。 - Vectorization:→將普通 for-loop 自動轉成 SIMD 程式碼的過程(可以由編譯器完成)。 - Tuning for hybrid cores 為 P-core/E-core 調整參數與同步邏輯 - - Thread / Process 管理與同步原語 - thread: 較輕量的執行單元,共享程序資源 - process: 執行中的程式單位,具有獨立的記憶體空間 - 管理概念 - Thread Pool:→預先建立固定數量的執行緒以處理任務,減少動態建立開銷。 - Deadlock→多個執行緒互相等待對方資源,形成無法繼續的狀態。 - **nice**(niceness): Linux/Unix 中用來調整 process 的**執行優先權**,數值越大代表「越 nice」,表示越願意讓出 CPU 時間(優先權越低)。範圍通常為 -20(最高)~19(最低)。 ## 系統通訊與共享資源(IPC) - IPC 技術 - IPC (Inter-Process Communication):→多個 process 間的通訊方式,如 pipe、message queue、shared memory、socket。 - Shared memory:→高效的 IPC 方法,process 直接共用記憶體區塊,常搭配 mmap()。 - mmap→將檔案或設備映射至虛擬記憶體,常用於共享記憶體、I/O 直接讀寫、模型 loading。 - SoC 通訊 - Rpmsg jobs:→在 ARM/NXP/SoC 上,remote processor messaging,用於 CPU 與 co-processor 間通訊。 ## 同步與 Barrier 技巧(Barrier & Coordination) - 技術 - Spin barrier 傳統的同步方式,執行緒會 busy wait(浪費 CPU) - Yield barrier 一種讓執行緒遇到 barrier 時可以 futex wait,不再佔用 CPU 的方式 - do_spin() 先短暫 spin,如果其他執行緒沒來就進 futex 等待 - Counter / throttled 計數用來追蹤 barrier 狀態;throttle 是為了避免太早進入睡眠狀態 ## 作業系統核心原理(OS Basics) - 模式與呼叫 - kernel mode: **User Mode(使用者模式)**:應用程式執行的環境,無法直接存取硬體資源,只能透過系統呼叫(system call)請求作業系統代為執行。 - user mode: **Kernel Mode(核心模式)**:作業系統核心執行的模式,擁有完整硬體控制權,可執行關鍵作業如中斷處理、排程、記憶體管理。 - system calls: 系統呼叫是使用者程式與作業系統之間的接口,允許程式存取如檔案、網路、程序管理等核心服務。 - 標準與接口 - POSIX: 一組 IEEE 制定的作業系統 API 標準,目的是讓 Unix-like 系統之間具備可攜性與相容性。 - 調度邏輯 - CPU scheduling: 決定哪一個可執行程序(或執行緒)獲得 CPU 的機制。 ## 開機與底層架構(Boot & Low-level) - 開機流程 - bootrom: 系統開機時最早執行的唯讀記憶體程式碼,負責載入 bootloader 或作業系統核心。 ## 並行計算與硬體加速(Parallelism & SIMD) - 並行概念 - SIMD (ingle Instruction, Multiple Data)→是一種 並行運算技術,廣泛應用於現代 CPU、GPU 中,用來加速向量與矩陣運算等資料密集型任務,例如音訊/影像處理、機器學習、數值模擬、壓縮演算法等等 - SIMT(Single Instruction, Multiple Threads)→GPU 中一種擴充概念,是「每個 thread 虛擬上看似獨立,其實是 SIMD 式同步執行」。 - Vectorization:→將普通 for-loop 自動轉成 SIMD 程式碼的過程(可以由編譯器完成)。 - Tuning for hybrid cores 為 P-core/E-core 調整參數與同步邏輯 ## 硬體執行風險(Hardware Hazard) - pipeline 風險 - hazard: 一種在 **指令平行化與分支預測時的風險**,主要分為: - **Control hazard**:分支指令尚未決定跳哪裡,CPU 卻已預先載入錯誤路徑 - **Data hazard**:一條指令需要前一條的執行結果,但前一條尚未完成會造成 pipeline stall 或錯誤執行結果。 ## 中斷 / 非同步任務排程(**Interrupt / Async Scheduling**) - 中斷機制 - IRQ/Interrupt: Interrupt Request 系統中斷機制,即時事件處理。 - software interrupt: tasklet, workqueue - softirq: 即 software interrupt,在 interrupt context 內執行 - Softirq/Tasklet/Workqueue: Linux 非同步任務排程方法。 - 中斷延後處理 - tasklet: - linux kernel 提供讓處理程序只須完成最重要部分即可,稍後再完成剩下的工作,這個機制稱作tasklet,只能在interrupt context執行 - 建構在 softirq 之上,動態註冊的軟體中斷,確保單一處理器核在特定時間內只能執行一個 tasklet - workqueue: - 允許中斷情形的後續處理排進wait queue的等待隊伍中 - 在 process context 內執行排入的工作,容許較長的延遲或執行可能引發休眠的操作,相較 tasklet 更有彈性,後者的操作必須為 atomic (一氣呵成) - 風格差異 - `softirq`(interrupt context) vs `workqueue`(process context) vs `tasklet`(中間層) - 核心概念 - `非同步任務排程` - `延遲執行任務` - `atomic context 限制`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    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.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully