linux2021
- 問題情況鬆散、有一段歷史根源
__sync
: deprecated 過時還可以用
can use transfer mode to suspend user mode extension
obsolete 過時不會用
TODO
ASK
atomic
and __sync
__sync
的實作在某些硬體上根本沒有,官方也推薦新的程式碼該用別的These functions are implemented in terms of the ‘__atomic’ builtins (see __atomic Builtins). They should not be used for new code which should use the ‘__atomic’ builtins instead.
cstring cstr_cat(cstr_buffer sb, const char *str)
原先測試沒辦法進入到 hash 操作
最後,每個對字串操作的都包起來。
參照計數是電腦程式語言中的一種記憶體管理技術,是指將資源(可以是物件、記憶體或磁碟空間等等)的被參照次數儲存起來,當被參照次數變為零時就將其釋放的過程。使用參照計數技術可以實現自動資源管理的目的。同時參照計數還可以指使用參照計數技術回收未使用資源的垃圾回收演算法。
當建立一個物件的實例並在堆上申請記憶體時,物件的參照計數就為1,在其他物件中需要持有這個物件時,就需要把該物件的參照計數加1,需要釋放一個物件時,就將該物件的參照計數減1,直至物件的參照計數為0,物件的記憶體會被立刻釋放。
Reference counts are also useful information to use as input to other runtime optimizations.
For example,systems that depend heavily on immutable objects such as many functional programming languages can suffer an efficiency penalty due to frequent copies. However, if the compiler (or runtime system) knows that a particular object has only one reference (as most do in many systems), and that the reference is lost at the same time that a similar new object is created (as in the string append statement str ← str + "a"), it can replace the operation with a mutation on the original object.
sleep()
reader and writer
xs_cow_lazy_copy
wikipedia - Copy-on-write
The string class provided by the C++ standard library was specifically designed to allow copy-on-write implementations in the initial C98 standard,[5] but not in the newer C11 standard:[6]
wikipedia - 寫入時複製
C++
標準程式庫中的std::string
類,在C++98/C++03
標準中是允許寫時複製策略。但在C++11
標準中為了提高並列性取消了這一策略。GCC
從版本 5 開始,std::string
不再採用COW
策略。
TODO
NOTE
此標題與其它標題不同,僅整理。
其它標題為當下筆記
list_for_each_entry_safe
, container_of
等包裝過得 API__attribute__((aligned(sizeof(long))));
的 bits 應用TODO
舉例解說的微處理器架構用 x86, x86_64, arm, aarch64, risc-v 等架構為主,你可以忽略 Alpha
主要相關對象為
『 Linux 核心設計 (Spring 2021) 課程進度表暨線上資源 』
『 CS:APP - international Edition - Second Edition 』
locality of reference
恐龍書的舉例
延伸閱讀
Page