NAME
          barrier - Suspend calling cthread until all other threads
          are complete

     LIBRARY
          C Threads Library (libcthreads.a)

     SYNOPSIS
          #include <cthread.h>

          void barrier();

     DESCRIPTION
          This call is not a barrier in the same sense as used in many
          threads packages.

          barrier() suspends the calling thread until only one thread
          remains. If it is issued from the first thread (the one
          specified in cthread_init() ), it will suspend that thread
          until all other threads have terminated. If it is issued
          from any thread but the initial thread, it will suspend that
          thread forever.  (This is because the semantics of
          cthread_init() are such that when the initial thread exits,
          cthreads will exit the whole program.  Thus for any other
          thread but the initial one, waiting to be the last thread
          running is equivalent to waiting for the end of the pro-
          gram.)

          barrier() is useful to inspect certain conditions after the
          termination of all threads, or simply to delay program exit
          until all other threads have completed.

          A typical invocation is shown below:

            void init_func() {

                .... initialize and fork threads

               /* wait until all *other* threads finish */
               barrier();
            }

            main(argc, argv)
            int     argc;
            char  **argv;
            {
               argc = cthread_parse_args(argc, argv);
               /* application arg processing and initialization */
               cthread_init(1, init_func);
            }

     SEE ALSO
          cthread_intro(3), cthread_join(3), cthread_init(3),

     AUTHOR
          Cthreads was written and maintained by many people.
          This man page written by Greg Eisenhauer.