home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / mod.std.unix.v7 / text0029.txt < prev    next >
Encoding:
Internet Message Format  |  1987-06-30  |  12.6 KB

  1. From: pyramid!utzoo!henry@sally.utexas.edu  (Henry Spencer)
  2. Date: Sat, 4 Oct 86 03:03:30 PDT
  3.  
  4. After some activity back when the Unix standard was with /usr/group, I've
  5. "gone dormant" on standardization work through lack of time.  I haven't
  6. even seen most of the P1003 stuff.  However, I understand that there is
  7. a proposal to incorporate Berklix-like "job control" into P1003.  Given
  8. the interest in getting some new topics into mod.std.unix, I'm submitting
  9. the following.  It's a slightly touched-up version of a paper Ian Darwin
  10. and I submitted to the /usr/group standards effort, arguing strongly that
  11. neither 4BSD "job control" nor SysV "shell layers" should be incorporated
  12. into a standard.  Since I haven't seen the detailed P1003 proposal, it's
  13. possible that some of this is out of date, but on the whole I think it's
  14. of interest nonetheless.
  15.  
  16.                 Henry Spencer @ U of Toronto Zoology
  17.                 {allegra,ihnp4,decvax,pyramid}!utzoo!henry
  18.  
  19. [ Perhaps whoever has the original online copy of the current P1003
  20. proposal could submit it?  That would probably be worthwhile even if
  21. it had to be broken into several articles for space reasons.  -mod ]
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.              Comments on Terminal I/O, Specifically `Job Control'
  32.  
  33.  
  34.                                 Henry Spencer
  35.  
  36.                             University of Toronto
  37.                                  utzoo!henry
  38.  
  39.  
  40.                                   Ian Darwin
  41.  
  42.                             University of Toronto
  43.                                  utcsstat!ian
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. `Job Control', What It's Really About
  52.  
  53.      There is no longer any argument that it is desirable  to  permit  orderly
  54. user  interaction  with multiple processes.  Unfortunately, a whole generation
  55. of Unix users has had their view of this concept warped by the dreadful way it
  56. was  implemented  by Berkeley.  And AT&T, in its recent attempt to address the
  57. problem, has taken the easy way out instead of doing it right.
  58.  
  59.      The basic concept involved here is multiplexing,  not  `job  control'  or
  60. process  suspension.   The ideal is something like the environment on the Bell
  61. Labs Blit, where multiple processes run simultaneously  in  multiple  windows,
  62. and  the user can switch his attention and his interaction from one to another
  63. at will.  There is a popular misconception that doing this *requires*  a  Blit
  64. or a similar highly-intelligent terminal; this is simply not true.
  65.  
  66.      Window-based multiplexed interaction is harder to do when the terminal is
  67. dumb,  but  even  the Blit is not actually writing things into several windows
  68. *simultaneously*:  it just looks that way because of the high-speed multiplex-
  69. ing  involved.   There  is no intrinsic reason why this multiplexing cannot be
  70. done at the other end of the communications line when the terminal is  incapa-
  71. ble of doing it.
  72.  
  73.      The multiplexing can be done in the kernel (albeit at  considerable  cost
  74. in  added kernel complexity) or in a user process (given suitable interprocess
  75. communication).  In either case, the fundamental structure is quite simple:  a
  76. central  `manager'  coordinates  terminal  i/o to and from `client' processes,
  77. each of which has total control of its own "virtual terminal".  The  manager's
  78. job  is  simulating  multiple  virtual terminals on a single real terminal, by
  79. routing input to the appropriate process and placing output in the appropriate
  80. area of the screen.
  81.  
  82.  
  83.  
  84.  
  85.  
  86.                                     - 2 -
  87.  
  88.  
  89.  
  90.      The basic characteristics of such a multiplexing  system  are  that  each
  91. process  has  what  looks (to it) like a private terminal, and that all i/o to
  92. and from the user is centrally supervised.  This  is  precisely  analogous  to
  93. file i/o under Unix:  simultaneous independent activity by multiple processes,
  94. coordinated by a central manager which multiplexes physical resources so as to
  95. prevent interference.  The benefits are similar:  individual processes neither
  96. know nor care about the multiplexing, and useful high-level  abstractions  can
  97. be implemented in one central place.
  98.  
  99. Job Control and Layers:  Half-Baked Approaches
  100.  
  101.      The existing schemes, Berkeley `job control' and  AT&T  `layers',  unfor-
  102. tunately  are  clumsy  and  incomplete  attempts  at  implementing multiplexed
  103. interaction.  Neither one  makes  any  provision  for  simultaneous  on-screen
  104. activities  by  more  than one process, except for the `cop-out' of permitting
  105. multiple processes to intermix their output at random.  But there  are  deeper
  106. problems.
  107.  
  108.      Both schemes require that *every* *program* which is going to participate
  109. in  multiplexed  interaction  must contain code to allow for this possibility!
  110. User programs must be prepared to redraw  the  screen  on  request,  with  the
  111. requests  coming  from  the kernel in the Berkeley scheme and from the user in
  112. the System V.2 scheme.  This is an abomination.
  113.  
  114.      Not only does this demand specialized code in every user program, but  it
  115. entirely  denies  multiplexed  interaction  to the bulk of Unix programs.  The
  116. concept of `redraw the screen' is meaningful  only  for  interactive  programs
  117. with  full-screen  interfaces.   The result of, say, an *egrep*, once replaced
  118. on-screen by (say) the editing buffer of a *vi*,  is  gone  for  good.   Since
  119. *egrep*  is  not an interactive program, it is no longer around to be asked to
  120. redraw its output.
  121.  
  122.      The heart of the problem is that neither job control  nor  layers  imple-
  123. ments  the  crucial half of a window system:  centralized management of screen
  124. updates.  It has long been accepted that multiple processes cannot  safely  do
  125. updates  to disks without centralized management and consistency control.  The
  126. same obviously applies to terminal i/o:  orderly simultaneous interaction with
  127. multiple  processes  requires centralized supervision of the interaction.  The
  128. existing schemes supervise input but not output.
  129.  
  130.      It is obvious *why* this deficiency exists:  supervising  output  is  the
  131. hard part.  The idea of switching input from one program to another is reason-
  132. ably straightforward.  Differences in input handling,  such  as  `cooked'  vs.
  133. `raw'  modes,  are relatively minor problems, since the user can be conversing
  134. with at most one process at a time.  But a CRT terminal  permits  output  from
  135. multiple  processes  to  be  displayed simultaneously, and coordinating screen
  136. updates isn't trivial.  Furthermore, there is no agreement on the precise user
  137. interface  that  should  be presented for output -- consider, for example, the
  138. religious debates over overlapping vs. non-overlapping  windows  --  and  this
  139. discourages  attempts  to  provide  a single and relatively inflexible central
  140. solution.  The immense variation in CRT-terminal control  sequences  puts  the
  141. icing on the cake.
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.                                     - 3 -
  149.  
  150.  
  151.  
  152.      Nevertheless, these problems *can* be solved.  There are at least  three,
  153. and  probably several more, complete window systems in experimental use.  Some
  154. of them have performance problems, and most of them are outside the kernel and
  155. hence have interprocess-communication problems, but they do work.
  156.  
  157. Standardizing Multiplexed Interaction:  A Recommendation
  158.  
  159.      As mentioned above, several experimental window  systems  already  exist.
  160. (This is quite apart from the `real' window systems on bitmapped workstations,
  161. which are also relevant.) Experience with these and other  implementations  of
  162. the  same  concept will yield a wealth of knowledge on how best to handle this
  163. function.  It is important that this experimentation, and the adoption of  the
  164. results  that come out of it, not be stifled by further `official endorsement'
  165. of incomplete and badly-designed existing schemes.
  166.  
  167.      The best approach for P1003 to take on this matter would  be  to  reserve
  168. some  characters,  and some flag bits, for implementations of multiplexed user
  169. interfaces, but not to specify any such  interface  at  this  time.   Such  an
  170. attempt  to  specify the interface would be premature, especially when the two
  171. approaches under consideration are  already  known  to  be  grossly-incomplete
  172. botches.
  173.  
  174.      *Neither Berkeley `job control' nor AT&T `layers' is an  adequate  imple-
  175. mentation  of  a  multiplexed user interface*.  *Neither one should be cast in
  176. concrete as a standard at this time*.
  177.  
  178. A Retraction
  179.  
  180.      Our previous recommendation was that, if multiplexed  interaction  *must*
  181. be  standardized,  AT&T `layers' would be a better place to start.  The layers
  182. system, unlike Berkeley job control, does do input  multiplexing  more-or-less
  183. correctly,  and  hence  is essentially upward-compatible with true window sys-
  184. tems.  It has several desirable characteristics:  independent  tty  state  for
  185. each  layer,  suspension/resumption  invisible  to  the  processes,  a central
  186. manager process which is *not* imbedded in a shell, and an implementation that
  187. does not have ramifications everywhere.
  188.  
  189.      Nevertheless, as discussed above, it doesn't do the  hard  part:   output
  190. multiplexing.   It  also  has  some  annoying  implementation  limits,  which,
  191. although they wouldn't necessarily have to propagate into  a  standard,  might
  192. well  propagate  into  most  early implementations.  Its major problem is that
  193. it's not clear how to extend  it  to  centralized  output  management  without
  194. imbedding said management inside the kernel.
  195.  
  196.      We therefore retract our recommendation for  standardizing  layers  as  a
  197. second choice.  The proper course is to standardize nothing, at least until we
  198. understand the user-interface issues and the implementation problems better.
  199.  
  200. Specifics
  201.  
  202.      A decision not to standardize a multiplexed-interaction  scheme  notwith-
  203. standing,  there  are a few useful minor things that can be standardized.  The
  204. *termio* structure probably should have a reserved character or two  (or  room
  205. for  same)  and  a few reserved bits (or room for same) to permit kernel-based
  206.  
  207.  
  208.  
  209.  
  210.                                     - 4 -
  211.  
  212.  
  213.  
  214. implementations of multiplexing.
  215.  
  216.      In particular, almost any multiplexing scheme using ordinary ASCII termi-
  217. nals  will need a special character to attract the attention of the multiplex-
  218. ing software.  Without this, it's very difficult  to  do  things  like  moving
  219. between windows.  Reserving space for such a character might be useful; recom-
  220. mending a default choice for the character would be very valuable, as it would
  221. forestall unnecessary differences between implementations.  Control-Z would be
  222. plausible.
  223.  
  224.      Implementing supervision of multiplexed interaction in user processes  is
  225. difficult  in  many  existing Unix implementations, minimal implementations of
  226. the existing P1003 standard among them.  The basic problem is that normal user
  227. processes  are  definitely aware that their output is going to a terminal, the
  228. device-independence of Unix  i/o  notwithstanding.   Screen-oriented  programs
  229. doing *ioctl*s are the biggest problem.  A less obvious glitch is that *stdio*
  230. adjusts its buffering strategy depending on whether output is to a terminal or
  231. not;  this  is  a major nuisance with some existing window systems.  Something
  232. like the `pseudo-tty' concept would be very useful:   an  entity  which  looks
  233. like  a  terminal from one side, but whose behavior is under user-process con-
  234. trol from the other side.  Some existing systems do implement such things, but
  235. the lack of standardization largely prevents use of them in portable programs.
  236.  
  237. Suspending Processes:  A Non-Issue
  238.  
  239.      Several people have objected to AT&T layers, and similar  approaches,  on
  240. the grounds that `...but 4BSD lets me suspend misbehaving processes...'.  This
  241. is silly; a process-suspension  facility  can  be  very  simple  if  it  isn't
  242. required to double as a multiplexing system.
  243.  
  244.      If it is thought desirable to standardize process  suspension,  we  would
  245. suggest the following.  Some magic character (control-Y?), when typed as input
  246. to a tty/window, suspends all processes  attached  to  that  tty/window.   The
  247. suspension can be, and should be, utterly invisible to the processes involved.
  248. This avoids the sticky problem of how to notify the  processes  without  doing
  249. incompatible things to the *signal* mechanism.  The suspension probably should
  250. have a permission requirement analogous to that of signals:  if the  effective
  251. userids  of  the user and the process don't match, the suspension doesn't hap-
  252. pen.  This is necessary to prevent major  security  breaches  like  suspending
  253. *passwd*(1) in the middle of an update to the password file.
  254.  
  255.      Note that this suspension facility isn't very useful in  the  absence  of
  256. multiplexed  interaction  --  you  can't  *do* anything to a suspended process
  257. without access to another (real or virtual) terminal -- but the  two  concepts
  258. are nevertheless quite independent.  There is no need to confuse them.
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272. Volume-Number: Volume 7, Number 30
  273.  
  274.