next up previous

5.2 Managing Processes

After allocating a hypercube, the next step is usually to load one or more processes onto the nodes and run them.

Every process executing on a node of a hypercube has a pid. Each RX node can execute only one process at a time, and its NX pid is 0.

The load command loads a program on the specified nodes of a hypercube. The killcube command kills one or more processes on a cube and also cleans up after a process (for example, by getting rid of pending messages). Therefore, issuing a killcube before each relcube is a good practice. load -H will load the program but not start it until the startcube command is issued. waitcube waits until one or more processes have completed.

The following example shows how to use some of the system commands mentioned above.

Example
The following program is called hello.c:

#include <cube.h>
#include <stdio.h>
main()
{
printf("Hello World! --from Node-%dn", mynode());
}

The program is then compiled and the executable is called hello. We allocate a hypercube of four nodes and load hello on all four nodes. When all the processes terminate, we kill the cube and then release it. The commands and their output look as follows. Note the sequence of execution of the printf statement by the nodes.

> getcube -t4
getcube successful: ...
> load hello
Hello World! --from Node-0
Hello World! --from Node-1
Hello World! --from Node-3
Hello World! --from Node-2
> killcube
> relcube
relcube released 1 cube