Provided by: manpages-ja-dev_0.5.0.0.20100315-1_all bug

NAME

       pthread_cond_init,      pthread_cond_destroy,      pthread_cond_signal,
       pthread_cond_broadcast, pthread_cond_wait, pthread_cond_timedwait -

       #include <pthread.h>

       pthread_cond_t cond = PTHREAD_COND_INITIALIZER;

       int    pthread_cond_init(pthread_cond_t    *cond,    pthread_condattr_t
       *cond_attr);

       int pthread_cond_signal(pthread_cond_t *cond);

       int pthread_cond_broadcast(pthread_cond_t *cond);

       int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);

       int    pthread_cond_timedwait(pthread_cond_t   *cond,   pthread_mutex_t
       *mutex, const struct timespec *abstime);

       int pthread_cond_destroy(pthread_cond_t *cond);

       () ()

        mutex

       pthread_cond_init cond cond_attr cond_attr NULL LinuxThreads cond_attr

        pthread_cond_t PTHREAD_COND_INITIALIZER

       pthread_cond_signal cond cond cond

       pthread_cond_broadcast cond cond

       pthread_cond_wait  (  pthread_mutex_unlock  )  mutex  cond  CPU   mutex
       pthread_cond_wait pthread_cond_wait mutex ( pthread_mutex_lock )

       mutex  mutex  mutex ()

       pthread_cond_timedwait  pthread_cond_wait mutex cond cond abstime mutex
       mutex pthread_cond_timedwait ETIMEDOUT abstime time(2)  gettimeofday(2)
       0 abstime  00:00:00 GMT, January 1, 1970

       pthread_cond_destroy          pthread_cond_destroy         LinuxThreads
       pthread_cond_destroy

       pthread_cond_wait       pthread_cond_timedwait        pthread_cond_wait
       pthread_cond_timedwait mutex mutex

        pthread_cond_signal pthread_cond_broadcast

        0

       pthread_cond_init,     pthread_cond_signal,     pthread_cond_broadcast,
       pthread_cond_wait

       pthread_cond_timedwait :

              ETIMEDOUT
                      abstime

              EINTR  pthread_cond_timedwait

       pthread_cond_destroy :

              EBUSY   cond

       Xavier Leroy <Xavier.Leroy@inria.fr>

       pthread_condattr_init(3),                        pthread_mutex_lock(3),
       pthread_mutex_unlock(3), gettimeofday(2), nanosleep(2).

        x y mutex mut cond x y

              int x,y;
              pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
              pthread_cond_t cond = PTHREAD_COND_INITIALIZER;

       x y :

              pthread_mutex_lock(&mut);
              while (x <= y) {
                      pthread_cond_wait(&cond, &mut);
              }
              /* x  y  */
              pthread_mutex_unlock(&mut);

       x y x y :

              pthread_mutex_lock(&mut);
              /* x  y  */
              if (x > y) pthread_cond_broadcast(&cond);
              pthread_mutex_unlock(&mut);

            (     x    y    )    pthread_cond_signal    pthread_cond_broadcast
       pthread_cond_broadcast

       x y :

              struct timeval now;
              struct timespec timeout;
              int retcode;

              pthread_mutex_lock(&mut);
              gettimeofday(&now);
              timeout.tv_sec = now.tv_sec + 5;
              timeout.tv_nsec = now.tv_usec * 1000;
              retcode = 0;
              while (x <= y && retcode != ETIMEDOUT) {
                      retcode = pthread_cond_timedwait(&cond, &mut, &timeout);
              }
              if (retcode == ETIMEDOUT) {
                      /*  */
              } else {
                      /* x  y  */
              }
              pthread_mutex_unlock(&mut);

                                 LinuxThreads                  PTHREAD_COND(3)