5 ms·
Semaphores are basically unused in the kernel these days, abandoned in favor of mutexes. I really recommend reading kernel/locking/mutex.c. You can learn a lot
by WallWextra 12y ago
Semaphores are basically unused in the kernel these days, abandoned in favor of mutexes. I really recommend reading kernel/locking/mutex.c. You can learn a lot about the details of low-level synchronization, and it's also just a really impressive piece of ruthlessly-optimised code. Tricks like reading the lock's 'owner' field without any sort of synchronization, to decide whether to spin on the lock or to sleep.
- julenx 12y agoFor the sake of completeness: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/locking/mutex.c https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux....