From: aap@papnet.eu (Angelo Papenhoff)
Subject: [TUHS] Article on 'not meant to understand this'
Date: Mon, 16 Jan 2017 12:26:16 +0100 [thread overview]
Message-ID: <20170116112616.GA40162@indra.papnet.eu> (raw)
In-Reply-To: <alpine.DEB.2.11.1701161116110.7102@grey.csi.cam.ac.uk>
On 16/01/17, Tony Finch wrote:
> Warren Toomey <wkt at tuhs.org> wrote:
>
> > http://thenewstack.io/not-expected-understand-explainer/
>
> Rob Pike observed on Twitter:
>
> https://twitter.com/rob_pike/status/820777895689732096
>
> > The article misses an important fact: A few years later we understood it
> > well and could do it much simpler.
>
> https://twitter.com/rob_pike/status/820777988924981254
>
> > We are always learning, and that comment was as much a note to the
> > author as to the reader. Now, stack switching is almost trivial.
>
> https://twitter.com/rob_pike/status/820778110253613056
>
> > A similar thing happened a generation earlier figuring out subroutine
> > (function) calls. Whole books were written. Now it's an instruction.
The author also actually missed the part that we're not supposed to
understand. I'll just paste what I posted on hackernews:
I don't think it's the context switching in general that we're not
expected to understand, since it's pretty much the same in v7 but the
comment is gone. Dmr actually explained the problem on his website
(https://www.bell-labs.com/usr/dmr/www/odd.html). savu is used to save
the current call stack, retu is used to switch to a saved call stack.
The problem is that the function which did the savu was not necessarily
the same as the function that does the retu, so after retu the function
could have the call stack of a different function. As dmr explained,
this worked with the PDP-11 compiler but not with the interdata
compiler. In V7 the stack switching was moved into separate functions,
save and resume. save retured 0 and resume returned 1 so that an if
statement could be used to check if the return from save was actually
that of resume after the stack switch (the same trick as that of fork).
This way the code that was to be executed after a stack switch was in
the same function and stack frame as the one that did the save (as
opposed to swtch).
Note that Lions doesn't explain this either, he assumed that the
difficulty was with with u_rsav and u_ssav, but those are still in v7
with the comment gone (he probably wasn't that wrong though, it really
is confusing, but it's just not what the comment refers to)
aap
next prev parent reply other threads:[~2017-01-16 11:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-16 1:44 Warren Toomey
2017-01-16 3:15 ` Larry McVoy
2017-01-16 10:11 ` Brantley Coile
2017-01-16 17:49 ` Marc Rochkind
2017-01-16 11:19 ` Tony Finch
2017-01-16 11:26 ` Angelo Papenhoff [this message]
2017-01-16 15:35 ` Random832
2017-01-16 17:16 Noel Chiappa
2017-01-16 19:10 Steve Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170116112616.GA40162@indra.papnet.eu \
--to=aap@papnet.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).