User Tools

Site Tools


/* You are not expected to understand this */

(taken from Dennis Ritchie's home page)

Every now and then on Usenet or elsewhere I run across a reference to a certain comment in the source code of the Sixth Edition Unix operating system.

I've even been given two sweatshirts that quote it.

Most probably just heard about it, but those who saw it in the flesh either had Sixth Edition Unix (ca. 1975) or read the annotated version of this system by John Lions (which was republished in 1996: ISBN 1-57298-013-7, Peer-to-Peer Communications).

It's often quoted as a slur on the quantity or quality of the comments in the Bell Labs research releases of Unix. Not an unfair observation in general, I fear, but in this case unjustified. The actual code and other commentary surrounding it were precisely this:

     * Switch to stack of the new process and set up
     * his segmentation registers.
     * If the new process paused because it was
     * swapped out, set the stack level to the last call
     * to savu(u_ssav).  This means that the return
     * which is executed immediately after the call to aretu
     * actually returns from the last routine which did
     * the savu.
     * You are not expected to understand this.
    if(rp->p_flag&SSWAP) {
        rp->p_flag =& ~SSWAP;
     * The value returned here has many subtle implications.
     * See the newproc comments.

So we tried to explain what was going on. “You are not expected to understand this” was intended as a remark in the spirit of “This won't be on the exam,” rather than as an impudent challenge.

The real problem is that we didn't understand what was going on either. The savu/retu mechanism for doing process exchange was fundamentally broken because it depended on switching to a previous stack frame and executing function return code in a different procedure from the one that saved the earlier state. This worked on the PDP-11 because its compiler always used the same context-save mechanism; with the Interdata compiler, the procedure return code differed depending on which registers were saved.

So, for Steve Johnson and me, trying to move the kernel for the first time to a new machine, this code was indeed on the exam. It took about a week of agonizing before we finally convinced each other that the mechanism was wrong and no fiddling with the compiler was useful. We redid the coroutine control-passing primitives altogether, and this code section, and the comment, passed into history.

Also see Brian Kernighan's tribute to Dennis Ritchie around the 4:20 mark.

anecdotes/not_expected_to_understand_this.txt · Last modified: 2022/07/08 09:22 by