Actor-based framework for SunSPOTs
By David Askirk on May 08, 2009
For my master thesis did I made an Actor-based framework for SunSPOTs.
The actor model for programming is getting more and more common. The model can be used to program both distributed programs and to program more than one core in multi core systems.
Languages which use the actor model is Erlang and Scala the most populars ones. Scala do even run on the JVM. Erlang is made of Ericsson in Sweden and have been used in telephones systems since 1984.
There do not exists an actor framework for the SunSPOT, so I sat out to make one.
The SunSPOT provide a SquawkVM, which support the CLDC and MIDlet. When sending messages using the built-in radio communication on the SunSPOT it is not possible to get an acknowlegde of the message sent. Therefore a communication layer is made, which is added to make sure that every message is received at the end, if the host exists, else an error is returned to the user.
To make it easy for the user to use the framework, is the interface reduced to only nine functions.
To make load balancing is the load calculated and send out to the others SunSPOTs using broadcasts. This was not possible to do. Somehow did the broadcast messages not received, so this part was set on hold.
The actors of the system is implemented using a Thread. The actor class is an abstract class which the user must extend to use the functions given in the actor. The actor acts as an entrance to the MCP. The user must implement the run method of the actor, to get the actor do some work. Each actor have an unique id used in communication.
The MCP (Master Control Program) is a class which holds function to create other actors, and handling messages. The actor ask the MCP to create an actor, local or non-local. The actor then ask the non-local MCP to create the actor, and returns the id to the calling actor.
There are different kind of messages in the system, which is send to different parts of the program.
But read more and see the dirty code in my thesis.