Operating systems also need to be massively concurrent. Not only is your OS scheduling all userspace processes and threads, but a kernel has many threads of its own, as well as interrupt handlers to interact with your hardware. You want to minimize time spent waiting around, because again, you’re robbing your users any time you do.
Put these two goals together and you’ll find many strange and magical methods for locklessly sharing data between threads. Let’s talk about one of those. Let’s talk about RCU.
…
Suppose we don’t wait around in our update function to free the old data. Our code is correct so long as that happens eventually, right? What if we “deferred” that?
…
…wait, did we just build a generational garbage collector? Of immutable data structures, no less?
This isn’t some thought experiment—RCU is very real, and very useful. Linux uses it tens of thousands of times. It’s provided in Facebook’s Folly C++ library. And in Rust it goes by crossbeam-epoch and underpins one of the most popular concurrency libraries.
…
I’m not suggesting that all software would benefit from garbage collection. Some certainly won’t. But it’s almost 2024, and any mention of GC—especially in my milieu of systems programmers—still drowns in false dichotomies and FUD.
From the article:
…
…
…