home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / transput / 1181 < prev    next >
Encoding:
Internet Message Format  |  1992-11-12  |  2.0 KB

  1. Path: sparky!uunet!inmos!wraxall.inmos.co.uk!butcombe!geoffb
  2. Newsgroups: comp.sys.transputer
  3. From: geoffb@inmos.co.uk (Geoff Barrett)
  4. Subject: Re: IS Occam3 recursive?
  5. Message-ID: <1992Nov12.094835.8563@wraxall.inmos.co.uk>
  6. X-Newsreader: Tin 1.1 PL5
  7. References: <1992Nov11.033835.21118@netcom.com>
  8. Date: Thu, 12 Nov 92 09:48:34 GMT
  9. Lines: 49
  10.  
  11. Tim Walker (tsw@netcom.com) wrote:
  12. :  Does anyone know if Occam3 will be recursive? This is a big drawback
  13. : in Occam2 when trying to implement things like parallel searchs.
  14. :  -- Tim Walker  (tsw@netcom.com)
  15.  
  16. The short answer is `no'.
  17.  
  18. There is, however, a way to get fixed depth recursion.  Suppose the
  19. definition you want to achieve is:
  20.  
  21.   PROC foo (formals)
  22.     body  --  contains call to foo
  23.   :
  24.  
  25. Then you can achieve recursion to depth n by repeating the code thus:
  26.  
  27.   PROC foo (formals)
  28.     STOP
  29.   :
  30.   PROC foo (formals)
  31.     body  --  contains call to foo
  32.   :
  33.   ...  repeat n-2 times
  34.   PROC foo (formals)
  35.     body  --  contains call to foo
  36.   :
  37.  
  38. This might be regarded as a dirty hack.
  39.  
  40. More seriously, it does illustrate an important property of occam
  41. processes, namely that their workspace requirements can be determined
  42. statically.  If you can't do this, then the implementation of parallel
  43. processes becomes much more difficult.  In current implementations of
  44. occam, it is possible to allocate a fixed amount of workspace for each
  45. parallel process.  If you allow recursive processes you cannot
  46. determine statically how much workspace each process will need.  This
  47. means that you have to know what to do with stack overflow when the
  48. obvious place to extend it has been allocated to something else
  49. already.  If you think you have a solution to this, and it does not
  50. have an adverse affect on the context switch time, then I will be
  51. interested to hear it.  In general, it is more important for an
  52. embedded application to be sure of enough space in which to run.  After
  53. all, you don't want to run out of memory just as you reach a critical
  54. section of control code.
  55.  
  56. Geoff Barrett
  57. INMOS Limited
  58.