home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / transput / 1191 < prev    next >
Encoding:
Text File  |  1992-11-14  |  3.7 KB  |  90 lines

  1. Newsgroups: comp.sys.transputer
  2. Path: sparky!uunet!mcsun!sun4nl!dutrun!dutrun2!dutncp8!rob
  3. From: rob@pact.nl (Rob Kurver)
  4. Subject: Re: IS Occam3 recursive?
  5. Message-ID: <rob.721663317@dutncp8>
  6. Sender: news@dutrun2.tudelft.nl (UseNet News System)
  7. Nntp-Posting-Host: dutncp8.tn.tudelft.nl
  8. Organization: PACT, Delft, The Netherlands
  9. References: <1992Nov11.033835.21118@netcom.com> <BxnGAH.3t9@sci.kun.nl>
  10. Date: Fri, 13 Nov 1992 14:01:57 GMT
  11. Lines: 77
  12.  
  13. In <BxnGAH.3t9@sci.kun.nl> Marco Kesseler <marcok@cs.kun.nl> writes:
  14.  
  15.  
  16. >In article <1992Nov12.094835.8563@wraxall.inmos.co.uk> Geoff Barrett,
  17. >geoffb@inmos.co.uk writes:
  18.  
  19. >>More seriously, it does illustrate an important property of occam
  20. >>processes, namely that their workspace requirements can be determined
  21. >>statically.  If you can't do this, then the implementation of parallel
  22. >>processes becomes much more difficult. In current implementations of
  23. >>occam, it is possible to allocate a fixed amount of workspace for each
  24. >>parallel process.  If you allow recursive processes you cannot
  25. >>determine statically how much workspace each process will need.  This
  26. >>means that you have to know what to do with stack overflow when the
  27. >>obvious place to extend it has been allocated to something else
  28. >>already.
  29.  
  30. >Sofar, I agree.
  31.  
  32. Me too.  The obvious thing to do is to allocate a new chunk of memory
  33. to use for the stack.  There's nothing very hard about this - many
  34. compiler systems have done it for years, even before transputers
  35. existed, and many transputer compiler systems support this as well.
  36.  
  37. >>If you think you have a solution to this, and it does not
  38. >>have an adverse affect on the context switch time, then I will be
  39. >>interested to hear it.
  40.  
  41. >I am confused. What do you mean when you talk about a 'context
  42. >switch'? It is clear that recursion implies additional overheads
  43. >at runtime during function calls. That it affects the time to
  44. >timeslice processes is totally new to me. Perhaps I am missing
  45. >a point here.
  46.  
  47. Stack checking and extension in the function prologue introduces
  48. a certain overhead (typically some 5 to 10 percent with a straight-
  49. forward implementation).  It does not introduce any context switch
  50. overhead.  In time-critical code it makes sense to optimize the
  51. stack use to ensure no stack extension is done (or even checked
  52. for) in the 10% of your code that uses 90% of your cycles.  In this
  53. way it is really quite easy to have arbitrary recursion where you
  54. need it, at a negligible overhead.
  55.  
  56. Again, this is not very exciting or new, and is, IMHO, a rather
  57. basic requirement for ANY professional transputer compiler
  58. (especially C compilers, of course).  The existance of multiple
  59. threads does not make this problem any harder, and does not
  60. excuse the compiler system from supporting this.
  61.  
  62. Recursion is a very powerful programming tool, and is very clean
  63. and `mathematically correct'.  The fact that it introduces variable-
  64. size stacks is a tad inconvenient, but no excuse to remove the
  65. feature from a modern programming language.  IMHO, of course.
  66.  
  67. >>In general, it is more important for an
  68. >>embedded application to be sure of enough space in which to run.  After
  69. >>all, you don't want to run out of memory just as you reach a critical
  70. >>section of control code.
  71.  
  72. >Yes, but knowing how much stack space the embedded application needs
  73. >is no reason to rule out the possibility to use recursion in some
  74. >language:
  75. >If you don't need it, don't use it.
  76.  
  77. Exactly!
  78.  
  79. >Marco Kesseler
  80. >Faculty of Mathematics and Computer Science
  81. >University of Nijmegen
  82.  
  83. Rob Kurver
  84. PACT Parallel Architecture and Compiler Technology
  85. --
  86.      PACT                   Rob Kurver
  87.     Foulkeslaan 87         rob@pact.nl
  88.    2625 RB Delft     ph: +31 15 616864 
  89.   The Netherlands   fax: +31 15 610032
  90.