home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Documentation / PUPS_Html / Usenet / notunderstand.txt
Encoding:
Internet Message Format  |  1998-03-08  |  4.5 KB

  1. From: lwj@cs.kun.nl (Luc Rooijakkers)
  2. Newsgroups: alt.folklore.computers
  3. Subject: Explanation of "don't understand" comment
  4. Message-ID: <3812@wn1.sci.kun.nl>
  5. Date: 24 Jul 91 10:06:02 GMT
  6. Sender: root@sci.kun.nl
  7. Organization: University of Nijmegen, The Netherlands
  8. Lines: 66
  9.  
  10. In <1991Jul22.113627.13234@sun.pcl.ac.uk> malcolmr@sun.pcl.ac.uk (Malcolm Ray)
  11. writes:
  12.  
  13. >In article <1991Jul20.133238.25882@aber.ac.uk> ccs7@aber.ac.uk (Christopher
  14. Samuel) writes:
  15. >>In article <KENW.91Jul15225254@skyler.arc.ab.ca>
  16. >>   kenw@skyler.arc.ab.ca (Ken Wallewein) doodled:
  17. >>
  18. >>> I've heard -- or read, I think -- about some code that contained the comment
  19. >>> "you aren't expected to understand this".  Seems to me it was in TCP/IP.
  20. >>> /kenw
  21. >>
  22. >>I always thought that it was in or just before the sheduler algorithm.
  23.  
  24. >It was in the swtch() function, which was indeed part of the scheduler.
  25.  
  26. [Gives edited full text of the comment]
  27.  
  28. >Well, you can see what they mean! :-)  I remember being well chuffed that
  29. >I *did* understand it, but don't expect me to now...
  30.  
  31. It was not terribly complicated, though, but you had to read the machine
  32. language also... An excerpt of my submission for the jargon file:
  33.  
  34. I looked it up in my photocopy of `UNIX(tm) Operating System Source Code,
  35. Level Six', from J. Lions from the University of New South Wales.
  36.  
  37. The full text of the comment from V6 slp.c (context-switching code) was
  38.  
  39.         If the new process paused because is was swapped out,
  40.         set the stack level to the last call to savu(u_ssav).
  41.         This means that the return which is executed immediately after
  42.         the call to aretu actually returns from the last routine which
  43.         did the savu.
  44.  
  45.         You are not expected to understand this.
  46.  
  47. The difficulty with V6 context switching was that the assembly language
  48. routines for restoring context changed the stack pointer but
  49. nevertheless returned to their calling routine, leaving it with an invalid
  50. stack frame (actually, the stack frame of the routine which did the
  51. original context save). This was changed in V7 to routines more like
  52. setjmp/longjmp. Even the authors of V6 had trouble with it, as
  53. exemplified by
  54.  
  55.            Finally, the most basic routines for multi-programming, those
  56.            that pass control from one process to another, turned out
  57.            (after causing months of nagging problems) to be incorrectly
  58.            specified and actually unimplementable correctly on the
  59.            Interdata, because they depended improperly on details of the
  60.            register-saving mechanism of the calling sequence generated
  61.            by the compiler. These primitives had to be redesigned; they
  62.            are of special interest not only because of the problems they
  63.            caused, but because they represent the only part of the
  64.            system that had to be significantly changed, as distinct from
  65.            expressed properly, to achieve portability.
  66.            
  67. (from S. C. Johnson and D. M. Ritchie, `Portability of C Programs and the
  68. UNIX System', UNIX System Readings and Applications, Bell System Technical
  69. Journal special issue on UNIX, Vol 57, No 6, July-August, also available
  70. from Prentice-Hall). This article discusses the porting of Research Unix
  71. from the PDP-11 to the Interdata 8/32 during 1977, somewhere between V6
  72. and V7.
  73.  
  74. -- 
  75. Luc Rooijakkers                                 Internet: lwj@cs.kun.nl
  76. Faculty of Mathematics and Computer Science     UUCP: uunet!cs.kun.nl!lwj
  77. University of Nijmegen, the Netherlands         tel. +3180652271
  78.  
  79.  
  80.     [ and from Dennis Ritchie himself ]
  81.  
  82. From: Dennis Ritchie <dmr@alice.att.com>
  83. Date: 2 Apr 92 09:34:24 GMT
  84. Organization: AT&T Bell Laboratories, Murray Hill NJ
  85.  
  86. People might be interested in more of the context
  87. of the famous `you are not expected to understand this' comment.
  88. (Tim Smith is wrong on the details.)  It was made somewhat in
  89. the spirit of `this won't be on the exam,' not as a contemptuous
  90. challenge.  Nevertheless, people did find it necessary
  91. to understand it, and the comment was too flippant.
  92.  
  93. And of course, the real joke was that we did not understand
  94. what what was really happening either:  the setu/retu mechanism
  95. of pre-Seventh Edition Unix was basically unworkable,
  96. because it depended inextricably on subroutine calling
  97. conventions of the PDP-11 implementation, and more fundamentally
  98. because it was not the right way to do things.   Specifically,
  99. as the comment says, `savu' arranges that a routine
  100. that subsequently calls `retu' jumps out not to
  101. a location near the `savu' (as with setjmp/longjmp),
  102. but to the routine that called the routine with the `savu.'
  103.