I find it fascinating how, just a few years after the difficulty of stack switching required a commented challenge in the Unix source, we were using setjmp and longjmp to do this with no fuss at all. Once the problem is solved, the solution can simplify dramatically.

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.)

Insight.

-rob


On Sun, Nov 13, 2022 at 11:26 AM Kenneth Goodwin <kennethgoodwin56@gmail.com> wrote:
Maybe it is just me, but I don't recognize any of the contributors listed either at the bottom 

On Sat, Nov 12, 2022, 7:20 PM Dave Horsfall <dave@horsfall.org> wrote:
I spotted this when glancing through a book catalogue; well, with a title
like that how could I miss it?

Subtitled "How 26 Lines of Code Changed the World", edited by Torie Bosch
and illustrated by Kelly Chudler (can't say that I've heard of them).

Summary:

``Programming is behind so much of life today, and this book draws together
  a group of distinguished thinkers and technologists to reveal the
  stories and people behind the computer coding that shapes our
  world.  From how university's [sic] databases were set up to
  recognise only two genders to the first computer worm and the
  first pop-up ad, the diverse topics reveal the consequences of
  historical decisions and their long-lasting, profound implications.
  Pb $34.99''

Lines of code, eh? :-)

Abbey's Bookshop: www.abbeys.com.au

Disclaimer: I have no connection with them, but I'll likely buy it.

-- Dave