Things UNIX can do atomically — Crowley Code!
This is a catalog of things UNIX-like/POSIX-compliant operating systems can do atomically, making them useful as building blocks for thread-safe and multi-process-safe programs without mutexes or read/write locks. The list is by no means exhaustive and I expect it to be updated frequently for the foreseeable future. The philosophy here is to let the kernel do as much work as possible. At my most pessimistic, I trust the kernel developers more than a trust myself. More practically, it’s stupid to spend CPU time locking around an operation that’s already atomic. Added 2010-01-07. The operations below are best left to local filesystems. More than a few people have written in crying foul if any of these techniques are used on an NFS mount. True. When there are multiple kernels involved, the kernel can’t very well take care of all the locking for us. Added 2010-01-06. Something I should add to my repertoire? Race condition? Let me know at r@rcrowley.org or @rcrowley and I’ll fix i
Things UNIX can do atomically — Crowley Code! Crowley Code! (Take 12) Syndicate! Things UNIX can do atomically 2010/01/06 This is a catalog of things UNIX-like/POSIX-compliant operating systems can do atomically, making them useful as building blocks for thread-safe and multi-process-safe programs without mutexes or read/write locks. The list is by no means exhaustive and I expect it to be updated frequently for the foreseeable future. The philosophy here is to let the kernel do as much work as possible. At my most pessimistic, I trust the kernel developers more than a trust myself. More
saved by
related reading
- Command Line Interface Guidelinesclig.dev
- Unreliable Guide To Locking — The Linux Kernel documentationdocs.kernel.org
- Intro - Putting the "You" in CPUcpu.land
- A Concurrency Cost Hierarchytravisdowns.github.io
- Linux kernel memory barriers — The Linux Kernel documentationdocs.kernel.org
- GitHub - jlevy/the-art-of-command-line: Master the command line, in one pagegithub.com
- What is RCU, Fundamentally? [LWN.net]lwn.net
- Spinlocks Considered Harmfulmatklad.github.io
- Measuring Mutexes, Spinlocks and how Bad the Linux Scheduler Really is | Probably Danceprobablydance.com
- Inter-process communication in Linux: Shared storage | Opensource.comopensource.com
- Writing an OS in Rustos.phil-opp.com
- The "Basics" | Putting the "You" in CPUcpu.land