I'm reading this link to learn about futex of Linux. Here is something that I don't understand.I don't quite understand why "acquires the lock without involving the kernel".I'm always thinking that the atomic instruction, such as test-and-set, always involves the kernel.So why does the first time of acquiring the lock won't involve the kernel? More specifically, the atomic instruction must or may involve the kernel? 解决方案 An atomic test and set instruction is just an ordinary instruction executed by user code as normal. It doesn't involve the kernel.Futexes provide an efficient way to perform a lock and unlock operation without involving the kernel in the fast paths. However, if a process needs to be put to sleep (to wait to acquire the lock) or woken (because it couldn't acquire the lock but now can), then the kernel has to be involved to perform the scheduling operations. 这篇关于原子指令是否涉及内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!