A Spoonful of Sewage / Bryan Cantrill
Thread scheduling algorithms. When I hear that I'm going to have to think about a thread scheduling algorithm--especially a thread scheduling algorithm that isn't quite working--I gulp nervously and tug at my collar. This essay about thread scheduling algorithms; it desribes a bumpy ride. I learned from it.
Oh, I keep looking for things to quote from this essay--but things from the middle don't make much sense unless you've read the beginning. There's some talk about debugging multi-threaded problems... Oh, just go read it. Oh, here's a bit that makes some sense:
The essence of the problem is this: for user-level locks, we normally keep track of the state associated with the lock (e.g., whether or not there's a waiter) at user level--that information is considered purely advisory by the kernel. (There are several situations in which the waiters can't be trusted, and the kernel knows not to trust it in those situations.)
To implement priority inheritance for user-level locks, however, one must become much more precise about ownership; the ownership must be tracked the same way we track ownership for kernel-level synchronization primitives. That is, when we're doing the complicated thread lock dance in turnstile_interlock(), we can't be doing loads from user-level memory to determine ownership. The nasty implication of this is that the kernel-level state tracking the ownership of the user-level lock must itself be protected by a lock, and that (in-kernel) lock must itself implement priority inheritance to avoid a potential inversion.
It also has some implicit good advice for code reviewers towards the end.
Distributed Programming with MapReduce / Jeff Dean & Sanjay Ghemawat
I skipped this chapter. Hey, give me a break. I hear about this stuff all the frickin' time.
Beautiful Concurrency / Simon Peyton-Jones
People who work with Haskell keep telling me how self-documenting the code is. They never convince me--probably because they make the mistake of showing me some Haskell code. This essay didn't convince me, either. Maybe because it showed me some Haskell code and then rushed along, thinking I'd understand it.
nTimes :: Int -> IO () -> IO () nTimes 0 do_this = return () nTimes n do_this = do { do_this; n_times (n-1) do_this }
Erlang folks also pull this kind of no-for-loops nonsense, but they don't keep telling me I should be able to read it by instinct. What does a loop have to do with IO? Does IO mean what it usually means? Do I care anymore?
Jones just wrote this essay. It's not his fault that other Haskell fans have soured me on the language. Maybe I should give this essay another chance. Nnnergh. I just don't have the willpower, not today.
Syntactic Abstraction / R. Kent Dybvig
I can't blame this one on the language. I thought I understood Scheme before I read this essay. But it turns out I don't know as much as I thought I did. Or I know the wrong dialect. Or something. Yoy. And this chapter was giving me freshman software engineering class Metacircular Evaluator flashbacks. I gave up on this chapter partway through.
Labels: book, programming, programming languages
Glad you got something out of the chapter. As you noted, the chapter presents a challenging problem -- for both reader and author -- in that one needs quite a bit of context to appreciate it. Thanks for sticking with it, and hopefully it wasn't unnecessarily arduous.
Also, very much enjoyed your candid reviews of the other chapters in "Beautiful Code". You and I share the same opinions on many chapters. (It's a relief to hear someone else criticize the "NASA" chapter which I thought -- at the risk of getting myself into trouble -- sucked.) Given that we are of like mind, you might be interested in my blog entries on the book here and here...
(I don't have an opinion one way or another about whether the NASA chapter sucked. I didn't stick with it long enough.)