On Dec 4, 2018, at 1:34 PM, Larry McVoy <lm(a)mcvoy.com> wrote:
On Wed, Dec 05, 2018 at 08:26:29AM +1100, Dave Horsfall wrote:
On Sun, 2 Dec 2018, Larry McVoy wrote:
> And
anyone who has not edited sendmail.cf (shudder!) is not a
> programmer.
As a systems guy I think if you have not written, or understood, swtch(),
you are not a systems guy.
Ahh, line 2238...
I dunno what line it is, I'm guessing that's the # for the Lions book?
I learned swtch() because I wrote a userland thread library for Udi Manber
as a grad student (yield based as I recall). I'd never really thought
about it hard, yeah, did all the CS toy OS stuff but I don't think they
made us write that. I loved writing it, I did a super minimal one that
had the bulk of the work in C, just did the save/restore in asm.
I too built a coroutine library. We used it for simulating
some real h/w we were building. The nice thing about h/w
simulation is no recursion so your threads can work with as
little as 50-100 bytes of stack, so even on a 64MB machine 100K
threads was not a problem! There is no yield() here being a
simulation core. Thread switch occurs in wait(), signal() &
busy(n) -- the last one to simulate passage of time. I built
the very initial version in 1982-83 using setjmp/longjmp! We
used it to check if our 5.6Mhz bus could support ethernet
traffic while doing other things.
Of course, this is much simpler than a unix swtch().