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

  1. From: seismo!munnari!yabbie.rmit.oz!rcodi@sally.utexas.edu (Ian Donaldson)
  2. Date: Tue, 4 Nov 86 09:05:35ligt 
  3.  
  4. > From: pyramid!nsc!hplabs!hpda!hpisoa1!davel (Dave Lennert)
  5. > Date: Wed, 29 Oct 86 10:07:47 -0800
  6.  
  7. I spoke about HUP's sent when an _exit is done, not realising at the time
  8. that it is only done by a sesion-group leader, and only to
  9. the same process-group, obviously (it is now) excluding those
  10. processes running in background.
  11.  
  12. > This key feature is preserved in the POSIX specification.  Perhaps I
  13. > don't understand your statement.
  14.  
  15. I withdraw the statement.
  16.  
  17. In the same article, I wrote: 
  18.  
  19. > > vhangup() will provide clean terminals on a bsd system,
  20. > > and we have improved vhangup further to not just turn off READ/WRITE bits,
  21. > > but to actually redirect the file references to /dev/null (which has
  22. > > the advantage of also dropping DTR reliably). 
  23. > vhangup() is indeed desirable.  It is not required in POSIX because it is 
  24. > not supported on System V and, indeed, breaks System V compatiblity.
  25.  
  26. I forgot to add the other advantage of my vhangup(), in that
  27. any read's by processes from the terminal return EOF rather than
  28. a read-error, and any writes go to the bit-bucket, rather than
  29. producing a write-error.  This is very desirable in stuations where
  30. you have started something in foreground (eg: make, without redirecting I/O) and
  31. you want it to -complete- in background, rather than crash because
  32. it cannot write diagnostics or output...
  33. Of course, you cannot -see- the output, but that is another topic
  34. (along the lines of login-suspension - see ravings in net.unix-wizards
  35. about 6 months ago).
  36.  
  37. Some programs of course would need to be trained to not repeatedly
  38. read beyond EOF assuming somebody is hitting ^D, otherwise they
  39. will do-so forever.  Berkeley 4.2bsd Csh and Mail already have been
  40. trained, and exit if a certain large number of consecutive EOF's are read.
  41. There are probably others.
  42. We have not felt need to modify any more programs, though there is the stray
  43. program that just sits there all day, once a fortnight perhaps.
  44. Readnews seems to be an often offendor (2.10.3).
  45.  
  46. I also wrote:
  47.  
  48. > > Infinite-loop processes don't cause problems with system-response because
  49. > > they are automatically niced (something that is long-needed in UNIX 
  50. > > systems).
  51. > Note that this is NOT desirable on, e.g., realtime systems where that
  52. > long running process may be critical.  I'm also getting tired of having
  53. > my rwhod reniced automatically.
  54. >     Dave Lennert                ucbvax!hpda!davel               [UUCP]
  55.  
  56. Granted, it probably -isn't- desirable at some sites, or perhaps even
  57. some particular users at certain sites, but it is necessary for
  58. any site that has lots of cpu-intensive tasks mixed in with lots
  59. of heavily interactive (eg: vi) sessions.
  60.  
  61. The auto-nicing that I have seen in 4.2 (not sure who added it) whereby
  62. a process gets niced by 1 every 40 cpu seconds until the nice reaches +15
  63. is NOT the sort of thing I am talking about.  The obvious problem with
  64. this algorithm is that it makes no distinctions on what it nices -
  65. it nices compiles (ok, good), but it also nices vi (bad), and eventually
  66. nices the shell (worse, as everything you start inherits the nice
  67. from the shell).  It also makes no distinction on -who- it nices;
  68. except that root is never niced (neither are other users, provided
  69. they are running at elevated priority).  This means that all non-root owned
  70. daemons get niced also.
  71.  
  72. I experimentally implemented a smarter, but still very simple auto-nicing
  73. algorithm that works well here nearly all of the time:  it is an
  74. extension of the one above, except that interactive processes are
  75. identified very simply by the fact that they do tty input (sounds logical).
  76.  
  77. A process is only niced if it consumes N cpu seconds since last doing
  78. some tty input (we have N set small, to 5 cpu seconds). 
  79. This means that an interactive shell is rarely ever
  80. niced, and vi always has a good response time regardless of what
  81. else is going on in the system (unless you're doing complicated
  82. length string searches or the like).  Another "quick hack" allowed
  83. all uid's less-than a certain number (say 2) to be immue to
  84. auto-nicing - this got around the daemon problem, altough very
  85. unelegantly.
  86.  
  87. The kernel mods were trivial, amounting to less than a screenful
  88. of code all-up.  In a nutshell it was one mod to clock.c 
  89. (kern_clock.c for 4bsd), to increment the nice if the conditions
  90. warrant it; and another mod to ttyread() to reset the nice
  91. and the accumulated cpu time since the last ttyread().
  92.  
  93. I have watched people breath discontent over the net with vi's response time, 
  94. and all the hack's that they've tried (including a suid root pre-elevate-nice 
  95. command).  Vi is only mentioned because it is common to almost all
  96. systems.  The problem is much deeper than just vi.
  97.  
  98. Any system that treats non-interactive jobs the same as interactive jobs
  99. is sure to have a rotten response-time.  Interactive jobs are not
  100. jobs that are just "associated" with a terminal either.  People
  101. expecting to do half-hour compiles from the terminal soon learn
  102. that there is no advantage in doing-so, and it is better to come back
  103. later and free up the terminal for somebody else to use (productively).
  104.  
  105. > Note that this is NOT desirable on, e.g., realtime systems where that
  106. > long running process may be critical.  
  107.  
  108. Perhaps, but then my version of auto-nice may solve most of such
  109. problems anyway.  If the program on the real-time system communicates
  110. with other than tty's in an "interactive" fashion, then this could be 
  111. incorporated into the algorithm quite easily.  Lots of things could be 
  112. incorporated into the algorithm - such as a per-user nice-rate and
  113. nice-limit.
  114.  
  115. People will never learn - just telling them to "nice" their jobs
  116. rarely works.  They either forget to, or just don't do it on principle.
  117.  
  118. SVR2 has no way of renicing a job other than restarting it
  119. (counter-productive), and telling somebody to change their nice on the
  120. humungous compile they just started after they've left and gone home is
  121. also often very difficult (read impossible), leaving a very slow
  122. system.
  123.  
  124. Vi and similar programs on our systems nearly always have a
  125. good response time - the times that they don't would most probably
  126. be attributed to excess paging and swapping activity and filesystem I/O.
  127.  
  128. > I'm also getting tired of having
  129. > my rwhod reniced automatically.
  130.  
  131. Maybe it wouldn't be with the algoritm I mentioned (I've never used
  132. rwhod so I can't answer that).
  133.  
  134. At least auto-nicing of some variety I have mentioned should
  135. be provided as a standard -option-.  Those who don't like it
  136. can turn it off, but I'll bet your boots that they will be
  137. in a minority once they've tried it.  Not having the option
  138. at all is not very nice (excuse the pun :-).
  139.  
  140. Ian Donaldson
  141.  
  142. Volume-Number: Volume 8, Number 37
  143.  
  144.