About the Example Distributed Program

DIPC applications consist of some stand-alone programs which execute in different computers. The example shown in Listing 1 consists of two parts. One part sends the string “Hello, Distributed Programming” to the other part, which in turn displays it to the user. The programs use a message to do so. Shared memories or semaphores are not needed for this simple example. Though the sources are in C, it should be noted that DIPC is language neutral and can be used in any programming environment that allows access to the operating system's system calls.

The first part, hello1.c, creates a message structure (called a message queue) using the msgget system call and the IPC_CREAT flag, and then waits to receive a message. The other part, hello2.c, also uses msgget to find the same message queue and then send the string as a message. Hello1 displays the message to the user and then destroys the message queue. The header file hello.h is used by both parts, and enables them to use the same definitions. To run the test, make hello1 and hello2, then start Hello1 first. Hello2 should be started after this, because it will have to access a message queue created by Hello1.

The only thing that makes this program distributed is that both Hello1 and Hello2 use the IPC_DIPC flag in the msgget system call. These programs can be compiled and run on systems with no DIPC support. On kernels with DIPC support, you can either run them on the same computer or on different computers on the same DIPC cluster. In short, these programs can be used anywhere with no modifications.