Tracy Camp

Distributed BACI: A Toolkit for Distributed Applications

Steven Burdette: The University of Alabama
Tracy Camp: Colorado School of Mines
Bill Bynum: The College of William and Mary

Introduction: What is Distributed BACI?
C-- Compiler Syntax
Using Distributed BACI
Obtain a Copy of Distributed BACI

Introduction: What is Distributed BACI?

BACI stands for the Ben-Ari Concurrent Interpreter. The distributed Ben-Ari Concurrent Interpreter (distributed BACI) extends the existing Ben-Ari Concurrent Interpreter interface to allow for distributed algorithm development. Visit the BACI home page for a discussion of the basics of BACI. This page adds the relevant distributed BACI details. Specifically, distributed BACI adds to BACI the ability to send, receive, and broadcast messages between any number of distributed "hosts," or distributed BACI programs. This ability allows the user to develop distributed algorithms easily, without having to worry about the underlying network calls. Such a simple method of implementation allows the user to easily:

The distributed BACI program code for an algorithm is almost an exact replica of the algorithm's pseudocode. Thus, a user is able to focus on his/her distributed algorithm, instead of the technical difficulties to implement the algorithm. Distributed BACI is useful to those that are involved in education and/or research of distributed systems.

C-- Compiler Syntax

BACI programs have either a ".cm" (C-- syntax) or ".pm" (Pascal syntax) extension. BACI's C-- compiler constructs are a subset of C++ compiler constructs. In other words, C-- follows C/C++ syntax. (See the BACI C-- Compiler Syntax for details.) Distrbuted BACI adds three commands to the BACI C-- syntax: send, receive, and broadcast.

The send command has the format:

send(message, destination);

where message is the string or integer that is sent, and destination is a number associated with the destination host.

The broadcast command has the format


where message is the string or integer that is sent to all of the other hosts. In a broadcast, a copy of the message is sent to all hosts in the distributed system; thus, there is no need to specify a destination host.

The receive command has two formats:

int receive(message); or int receive(message, sender);

where message is a string or integer value, sender is the number associated with the host that sent the message, and the return value is either STRING_MSG or INT_MSG. In a receive statement, the message parameter is always received as a string. If the return value is STRING_MSG, then the user is able to immediately use the message as a string. However, if the return value is INT_MSG, then a typecast ( int(message) ) must be used in order to convert the message to its corresponding integer value. The user does not have to check for STRING_MSG or INT_MSG if he/she already knows the type of the message received. The two receive commands are identical in purpose, except that the second allows the user to learn which host sent the message.

Using Distributed BACI

A distributed BACI source file must have a .cm suffix. To execute a program in distributed BACI, there are four steps:

  1. Create a hosts.baci file. The hosts.baci file contains all of the hosts in the distributed system, along with each host's corresponding port number. Thus, a distributed BACI host knows where to go to contact the other distributed BACI hosts. This file gives the user the ability to change the port numbers as needed, and gives the user control over where the distributed hosts are in the system. The distributed hosts can all be on the same machine, or spread among many different machines. Consider the following hosts.baci example: 1250 1251 1250

    The numbers associated with hosts in distributed BACI begin with 0, so the hosts defined above are host[0] (, port 1250), host[1] (, port 1251), and host[2] ( If a user wants to send the message "Hello" to host[0], the following syntax is valid: send ("Hello world", 0);

  2. Create a ".cm" file(s) using the distributed BACI C-- syntax. One ".cm" file must reside on each of the hosts defined in the hosts.baci file.

  3. Compile the ".cm" file to obtain a PCODE file (.pco) on each of the hosts defined in the hosts.baci file.

  4. Usage: dbacc [optional_flags] source_filename
    Optional_flags: -h show this help
    -c make a .pob object file for subsequent linking

  5. Interpret a PCODE file (.pco) to execute the program on each of the hosts defined in the hosts.baci file.

    1. Usage dbainterp [optional_flags] pcode_filename host_number
        -d enter the debugger, single step, set breakpoints
        -e show the activation record (AR) on entry to each process
        -x show the AR on exit from each process
        -t announce process termination
        -h show this help
        -p show PCODE instructions as they are executed
      The host_number parameter of the bainterp statement corresponds to the host that is running. For example, if you ran three distributed BACI hosts corresponding to the above hosts.baci file, you would do the following:
      1. Compile all three programs on the respective domain.
      2. Open 3 terminal sessions on the respective domains to execute each instance of distributed BACI.
      3. In the first terminal session, execute bainterp programName 0
        In the second terminal session, execute bainterp programName 1
        In the third terminal sesison, execute bainterp programName 2

Obtain a Copy of Distributed BACI

The distributed BACI system has been developed in the Linux environment. We are in the process of porting distributed BACI to other Unix environments; we will add them to this list as we have success. If you use a different hardware platform, and if you can give us access to your hardware, we will try to install the distributed BACI system for your machine type. We can be reached at "bynum AT cs DOT wm DOT edu" or "tcamp AT mines DOT edu".