S_WAIT_BARRIER(3P)

NAME
s_init_barrier, s_wait_barrier - initialize barrier, wait at barrier

SYNOPSIS
C syntax:

#include <parallel/parallel.h>
s_init_barrier (bp, nprocs);
sbarrier_t *bp;
int nprocs;

S_INIT_BARRIER (bp, nprocs);

s_wait_barrier (bp);
sbarrier_t *bp;

S_WAIT_BARRIER (bp);

Pascal syntax

procedure s_init_barrier (var barrier : longint; nprocs : longint);
cexternal;
procedure s_wait_barrier (var barrier : longint);
cexternal;

FORTRAN syntax

integer*4 barrier, nprocs
subroutine s_init_barrier (barrier, nprocs)
subroutine s_wait_barrier (barrier)

DESCRIPTION
S_init_barrier initializes a barrier as a rendezvous point for exactly nprocs processes. This barrier can be used subsequently with s_wait_barrier .

In C, a barrier is a shared data structure of type sbarrier_t as shown in the following declaration statement:

	shared sbarrier_t barrier;

In Pascal, a barrier is a global integer variable. In FORTRAN, a barrier is an INTEGER*4 variable. A FORTRAN barrier must be placed in shared memory either by declaring it in a common block and using the loader -F option or by using the FORTRAN -mp option, which places all variables into shared memory.

s_wait_barrier delays the process in a busy wait until exactly nprocs processes have called s_wait_barrier. At that point, all processes exit the busy wait simultaneously. The barrier must have been previously initialized using s_init_barrier .

Results are undefined if more than nprocs processes call s_wait_barrier. A barrier can be used any number of times without being re-initialized. A barrier should not be re-initialized while processes are waiting at the barrier.

S_INIT_BARRIER and S_WAIT_BARRIER are C-preprocessor macros. (These macros are actually compiled out of line on Balance systems, but they are available for code compatibility.) These macros are found in the header file /usr/include/parallel/parallel.h. When compiled in line, the macros are faster than the normal function calls, but they can add to the code size. See the source code in <parallel/parallel.h> for more information on the macros.

SEE ALSO
intro(3P), shmalloc(3P), Guide to Parallel Programming

BUGS
s_init_barrier and s_wait_barrier are declared as integer functions, but do not in fact return a value.