1 . Initialization and Completion

The program utilizing Converse begins executing at main , like any other C program. The initialization process is somewhat complicated by the fact that hardware vendors don't agree about which processors should execute main . On some machines, every processor executes main . On others, only one processor executes main . All processors which don't execute main are asleep when the program begins. The function ConverseInit is used to start the Converse system, and to wake up the sleeping processors.

typedef void (*CmiStartFn)(int argc, char **argv);
void ConverseInit(int argc, char *argv[], CmiStartFn fn, int usched, int initret)
This function starts up the Converse system. It can execute in one of the modes described below.

Normal Mode: schedmode=0, initret=0

When the user runs a program, some of the processors automatically invoke main , while others remain asleep. All processors which automatically invoked main must call ConverseInit. This initializes the entire Converse system. Converse then initiates, on all processors, the execution of the user-supplied start-function fn(argc, argv) . When this function returns, Converse automatically calls CsdScheduler , a function that polls for messages and executes their handlers (see chapter 2). Once CsdScheduler exits on all processors, the Converse system shuts down, and the user's program terminates. Note that in this case, ConverseInit never returns. The user is not allowed to poll for messages manually.

User-calls-scheduler Mode: schedmode=1, initret=0

If the user wants to poll for messages and other events manually, this mode is used to initialize Converse . In normal mode, it is assumed that the user-supplied start-function fn(argc, argv) is just for initialization, and that the remainder of the lifespan of the program is spent in the (automatically-invoked) function CsdScheduler , polling for messages. In user-calls-scheduler mode, however, it is assumed that the user-supplied start-function will perform the entire computation , including polling for messages. Thus, ConverseInit will not automatically call CsdScheduler for you. When the user-supplied start-function ends, Converse shuts down. This mode is not supported on the sim version. This mode can be combined with ConverseInit-returns mode below.

ConverseInit-returns Mode: schedmode=1, initret=1

This option is used when you want ConverseInit to return. All processors which automatically invoked main must call ConverseInit. This initializes the entire Converse System. On all processors which did not automatically invoke main , Converse initiates the user-supplied initialization function fn(argc, argv) . Meanwhile, on those processors which did automatically invoke main , ConverseInit returns. Shutdown is initiated when the processors that did automatically invoke main call ConverseExit, and when the other processors return from fn . In this mode, all polling for messages must be done manually (probably using CsdScheduler explicitly). This option is not supported by the sim version.

void ConverseExit(void)
This function is only used in ConverseInit-returns mode, described above.

void CmiAbort(char *msg)
This function can be used portably to abnormally terminate a Converse program. Before termination, it prints a message supplied as msg .

void CmiAssert(int expr)
This macro terminates the Converse program after printing an informative message if expr evaluates to 0. It can be used in place of assert . In order to turn off CmiAssert , one should define $CMK\_OPTIMIZE$ as 1.