PREV UP NEXT StackThreads/MP: version 0.77 User's Guide

3.1: Creating A Thread

        ST_THREAD_CREATE(e);

e is a procedure call expression in C/C++ that does not have nested procedure calls in argument positions. On SPARC, special care must be taken when you pass structures as arguments (see Structure Passing on SPARC). Unlike a similar thread creating functions in traditional thread libraries such as Pthreads, the procedure can take any number of parameters and, more importantly, the cost of a thread creation is very small (typically something like 10 instructions in addition to a procedure call overhead). Hence, if your computation can tolerate the overhead of a procedure call, it is likely to tolerate the overhead of creating a thread as well.

The actual constraint for argument positions is slightly more relaxed; we actually permit procedures that never call StackThreads/MP primitives, most notably procedures in standard libraries (such as printf, atoi, etc.). But you can remember the above rule as a simple safety net. Here are some examples:

        ST_THREAD_CREATE(f(1, 2, 3, 4, 5));
        ST_THREAD_CREATE(f(atoi(argv[1])));

primitives. Finally,

        ST_THREAD_CREATE(f(g(x)));