Newsgroups: comp.sys.transputer
From: butenuth@i30s23.ira.uka.de (Roger Butenuth)
Subject: Re: Calling functions "belonging" to another configured process
Keywords: transputer, addresses, function pointers
Organization: University of Karlsruhe (Germany)
Date: 5 Oct 1994 08:41:01 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Message-ID: <36toqt$dvs@nz12.rz.uni-karlsruhe.de>

In article <1994Oct4.204849.11920@mprgate.mpr.ca>,
 ashdown@mpr.ca (Scott Ashdown) writes:
|> I'm looking for a way (using INMOS C) to allow a configured process to call 
|> functions that were linked into another configured process' *.lku file. The
|> method is this:
|> 
...
|> 2) At runtime, have the second configured process send, via a channel, the
|>    addresses of the functions. Copy them into the pointers, and the other
|>    configured process should be able to call them.
|> 
...
|> -- 
|> Scott Ashdown
|> Engineer, MPR Teltech Ltd.
|> Burnaby, British Columbia, Canada.
|> ashdown@mprgate.mpr.ca

I am not sure, but I suppose if you configure the two processes, they
have both their own data area. The pointer to the start of this area
is passed on every function call as a hidden parameter before all
other parameters. You can print this pointer with the following code:

void test_function(int dummy)
 {
   struct
    {
      void *return_address;
      void *gsb;
      int  dummy;
    } *params;

   params = (void*)((char**)&dummy - 2);

   printf("start of data area: 0x%08x\n", (int)params->gsb);
 }

If the two processes work on different data areas, the called
functions can't access any global variables.

Hope that helps!

--
Roger Butenuth                                  e-mail: butenuth@ira.uka.de
Institut fuer Betriebs- und Dialogsysteme       Tel.: +49-721-608-3836
Universitaet Karlsruhe                          Fax:  +49-721-697760
D-76128 Karlsruhe

