目的: 檢驗學員對並行和多執行緒程式設計的認知
1
考慮我們嘗試建構 lock-free 的 MPMC broadcast queue、依循 Publish–subscribe 模式,程式碼可見 broadcast,其中 pool.[ch]
是 lock-free memory pool。
編譯方式:
$ gcc -Wall -O2 -D_GNU_SOURCE \
-o stress \
stress.c \
broadcast.c \
pool.c \
-lpthread
參考執行輸出:
Test: 1pub0sub
Pub Thread 0 | n_msgs: 100000 n_drops: 0 | 169 ns/msg
Test: 2pub0sub
Pub Thread 0 | n_msgs: 100000 n_drops: 0 | 519 ns/msg
Pub Thread 1 | n_msgs: 100000 n_drops: 0 | 416 ns/msg
Test: 4pub0sub
Pub Thread 0 | n_msgs: 100000 n_drops: 0 | 945 ns/msg
Pub Thread 1 | n_msgs: 100000 n_drops: 0 | 965 ns/msg
Pub Thread 2 | n_msgs: 100000 n_drops: 0 | 952 ns/msg
Pub Thread 3 | n_msgs: 100000 n_drops: 0 | 967 ns/msg
Test: 4pub0sub
Pub Thread 0 | n_msgs: 100000 n_drops: 0 | 2800 ns/msg
Pub Thread 1 | n_msgs: 100000 n_drops: 0 | 3015 ns/msg
Pub Thread 2 | n_msgs: 100000 n_drops: 0 | 3065 ns/msg
Pub Thread 3 | n_msgs: 100000 n_drops: 0 | 3060 ns/msg
Pub Thread 4 | n_msgs: 100000 n_drops: 0 | 3062 ns/msg
Pub Thread 5 | n_msgs: 100000 n_drops: 0 | 3033 ns/msg
Pub Thread 6 | n_msgs: 100000 n_drops: 0 | 3021 ns/msg
Pub Thread 7 | n_msgs: 100000 n_drops: 0 | 3043 ns/msg
AAAA, BBBB, CCCC, DDDD, EEEE, FFFF 皆為變數名稱
指令集是 CPU 指令所組成的集合,可極縮至一指令 (OISC) 並達成圖靈完備,已用於同態加密晶片、可堆疊 FPGA 多核處理器,及經微碼擴充到 RISC-V 且通過形式化驗證的實作。NISC 與 ZISC 分別靠編譯器靜態排程與硬體向量比對取代指令解碼,換得低功耗與高吞吐;近期研究亦將單指令 FLEQ 硬編碼於迴圈 Transformer,顯示深度模型可直接充任通用運算主體。極簡控制邏輯正成為雲端隱私運算與專用加速器的技術選項。
Jun 5, 2025本文探討 spinlock 本身的效能和可擴展能力 (scalability) 議題
Jun 4, 2025本講座則是專注於作業系統領域,同時,"Microkernel" 也不全然指其 "micro" 微小之意,而且是探討相對於傳統 Monolithic kernel 的 Microkernel
Jun 3, 2025解說錄影: Part 1 / Part 2 / Part 3 / Part 4 / Part 5/ Part 6 / Part 7
May 30, 2025or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up