Lesson 5: Performing Remote Tuplespace Operations

An agent can access a remote node's tuplespace, even if the node is multiple hops away. The instructions Agilla provides to accomplish this are the remote out (rout), remote rdp (rrdp), remote inp (rinp), and remote group probe (rrdpg). All of these instructions take a tuple or template and destination location as a parameter. The top of the operand stack must be the destination location, followed by the tuple or template. The tuple or template is pushed on the stack as described in Lesson 4: Using the Local Tuplespace. The location can be pushed onto the stack using the pushloc instruction.

All of the remote tuplespace operations are best effort in that the initiating node sends a request to the destination (which may be multiple hops away), and waits for a result. If the destination node receives the request, it performs the request and sends back a result. If the result arrives, the initiating node saves the result in the initiating agent's opstack and sets the condition code (where appopriate based on the instruction), and resumes the initiating agent. If message loss occurs, the initiating agent times out and resumes executing with the condition code set to 0.

rrdpg is unique in that it operates on all one-hop neighbors by asking whether any of them have a tuple matching a particular template. This instruction determines the location of each neighbor that has a match and stores the results on the heap (rather than the stack). Heap address 0 is always the number of results (say n), and the n heap addresses following heap address 0 contain the resulting locations.

Consider the dynamic fire detector located in <agilla>/Examples/Fire Dynamic Spread/Dynamic Fire.ma:

This agent models fire that epidemically spreads throughout a network. Upon arrival at a node, it outs a tuple containing the string "fir" into the local tuple space, then blinks the red LED a certain number of times. It then chooses a random neighbor and checks whether it is on fire using a rrdp instruction. If the neighbor is not on fire, it clones to it. Either way, it loops back to blinking the red LED. This processes continues indefinately until the entire network is saturated with fire agents.

The rrdp instruction is used on line 35 of the above agent. Notice that before it, on lines 30-33, a tuple containing the string "fir" is pushed onto the stack, and that the location is pushed onto the stack by the getvar 0 instruction on line 34 (getvar 0 retrieves the variabled stored on heap address 0, which is the chosen neighbor and is set by the setvar 0 instruction on line 29).

Return values

The remote tuplespace instructions differ in their return values.

  • rout - sets conditon=1 if success, 0 if fail. Does not push anything onto the stack.
  • rinp and rrdp - sets conditon=1 if success, 0 if fail. Pushes a matching tuple onto the stack if success.
  • rrdpg - sets conditon=1 if success, 0 if fail. Saves the resulting locations on the heap as described above.

 

 

This work is supported by the ONR MURI Project CONTESSA and the NSF under grant number CCR-9970939.