[TUHS] Book: "You Are Not Expected to Understand This"

Larry McVoy lm at mcvoy.com
Sun Nov 13 11:52:59 AEST 2022

On Sun, Nov 13, 2022 at 12:12:32PM +1100, Rob Pike wrote:
> See https://github.com/plan9foundation/plan9/blob/main/sys/src/9/port/proc.c
> for instance - almost all of sched is bookkeeping and a comment about
> locks. The little burst at the bottom, starting around line 163, that does
> the work is so compact. (setlabel and gotolabel are setjmp and longjmp.)

This reminds me of code I did for Udi Manber as a grad (or undergrad)
student.  He wanted a user space threads library so I wrote one.
It's where I learned how to write swtch() where you enter as one thread
and exit as another one.  99% of the code was C that did all the stuff
you could do in C and then a small amount of assembler that did the flip.

I had heard that swtch() was hard but it really isn't that bad.
The assembler makes you learn that stuff but you need to know that stuff
anyway.  I do agree with people who say you aren't a kernel engineer if
you haven't written, or at least understood, that code.

More information about the TUHS mailing list