home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.transputer
- Path: sparky!uunet!mcsun!sun4nl!dutrun!dutrun2!dutncp8!rob
- From: rob@pact.nl (Rob Kurver)
- Subject: Re: Recursion in occam
- Message-ID: <rob.722177288@dutncp8>
- Sender: news@dutrun2.tudelft.nl (UseNet News System)
- Nntp-Posting-Host: dutncp8.tn.tudelft.nl
- Organization: PACT, Delft, The Netherlands
- References: <142@autro1.UUCP>
- Date: Thu, 19 Nov 1992 12:48:08 GMT
- Lines: 67
-
- In <142@autro1.UUCP> teig@autro1.UUCP (Oyvind Teig) writes:
-
- >Recursion of occam-2 or -3
-
- >I have seen enough of stack overflow errors to appreciate the lack
- >of recursion in occam.
-
- Recursion + stack-checking -> no stack overflow.
-
- >Rob Kurver writes:
- >> It is very well possible to introduce stack checking code during linking,
- >> when a call-graph of the program can be used to determine if and when
- >> it is possible. This would result in ZERO overhead for a program written
- >> without recursion, and minimum overhead for recursive programs. We
- >> are currently working on this feature in PACT Parallel C.
-
- >Ok, but you still have not removed the stack overflow!
-
- When I say "stack checking" I mean "stack checking plus expansion if
- necessary". By checking the stack and expanding it if necessary, you
- remove the stack overflow. The linker can build a call-graph for the
- entire program, so it knows which functions call which other functions.
- This allows it to detect recursion. All non-recursive branches need
- only have enough stack allocated once, at the start of the branch (i.e.
- at process or program creation). The recursive branches, if any, need
- to have stack checking (+ expansion) code introduced in the loop
- (unless you just want to restrict the depth at linktime, of course).
-
- This way, there's no overhead if you don't use recursion, and there is
- a small overhead if you do use recursion. You don't have stack
- overflows in any case.
-
- >This comes close to the discussion of exception-handling: how do
- >you solve that in Pact-C, and what would you recommend when stack overflow
- >is encountered?
-
- Upon stack overflow, the stack is extended by allocating a new block of
- memory from the heap. If this is not possible (out of memory), you get
- a fatal error message and your program aborts.
-
- >If occam had been written from the philosophy that "if you don't need it,
- >don't use it", it definitively would have not been occam.
-
- I guess it would not have been Occam-2, no. It might have had data
- structures :-).
-
- >Is it possible to do multi-language design with the Inmos D7205 occam
- >toolset and your Pact C-compiler, like it is with the Inmos C-toolset?
-
- Yes. You can link Occam (TCOFF) modules with PACT Parallel C modules.
-
- >For me as an occam-user, your parallel C (:-) is of little interest because
- >C is not interesting, if it were, I would not have used occam (recursive
- >definition: interesting but little useful(%-|)
-
- I C :-). A lot of people do find C interesting, though.
-
- >0yvind Teig
- >Autronica, Trondheim, Norway
-
- Rob
-
- --
- PACT Rob Kurver
- Foulkeslaan 87 rob@pact.nl
- 2625 RB Delft ph: +31 15 616864
- The Netherlands fax: +31 15 610032
-