Previous: Dereferencing Global Pointers Up: Global Pointers Next: Casting Global Pointers
{ C *global gpC; gpC->a_function(); }
to invoke the function a_function() on the object referenced by gpC. This mechanism of function invocation through a global pointer is known as a remote procedure call, or RPC.
Each RPC creates a separate thread of control on the remote processor object. Thus, several RPCs can execute concurrently. atomic and sync should be used to avoid the dangerous sharing of mutables that might result.
The semantics of function call are preserved by an RPC. That is, the
function call statement does not terminate until the function has
terminated on the remote processor object. The flow of control in an
RPC is illustrated in Figure .
If the function has a return value, it is returned to the processor object that made the call. Thus, we can write the following:
{ C *global gpC; int x = gpC->a_function_returning_int()+10; }
CC++ has a mechanism for controlling how the arguments and
return values of functions called remotely are transfered between
processor objects. This mechanism is described in
Chapter .
Again, a global pointer does not have to reference an address in another processor object. If the address referenced is on the processor object from which the function is invoked, the effect is the same as a function invocation through a local pointer.
Functions that are called remotely may not have arguments that are
local pointers, references, or arrays. This is because these types
cannot be copied from one processor object to another. This topic is
also covered in Chapter . For the same reason,
remote functions may not return local pointers, references, or arrays.
Violating either restriction will result in a compile-time error.