NAME

shared_cv -- POSIX condition variables that are shared among multiple processes

SYNOPSIS

   #include <afblib/shared_cv.h>

   bool shared_cv_create(shared_cv* cv);
   bool shared_cv_free(shared_cv* cv);

   bool shared_cv_wait(shared_cv* cv, shared_mutex* mutex);
   bool shared_cv_notify_one(shared_cv* cv);
   bool shared_cv_notify_all(shared_cv* cv);

DESCRIPTION

A shared condition variable is one that can be used in a memory segment that is shared among multiple processes. By default, POSIX condition variables must not be shared among multiple processes. Instead the special attribute PTHREAD_PROCESS_SHARED has to be set to support this setup.

shared_cv_create and shared_cv_free must be called by one process only, usually the process that configures the shared memory segment. The other processes must not invoke any of the other operations as long as the condition variable has not been created properly with shared_cv_create and the condition variable must no longer be used once it has been free'd using shared_cv_free.

The mutex variable that is passed to shared_cv_wait must be likewise a shared one, created by shared_mutex_create.

shared_cv_notify_one notifies one waiting process, if any, while shared_cv_notify_all notifies all waiting processes.

AUTHOR

Andreas F. Borchert