previous | start | next

Barrier (3)

Should be, but isn't a POSIX solution

    1     pthread_mutex_lock(&m);
    2     if (++count == number) {
    3     
    4       pthread_cond_broadcast(&cond_var);
    5       count = 0;
    6     } else {
    7       pthread_cond_wait(&cond_var, &m);
    8     }
    9     pthread_mutex_unlock(&m);


previous | start | next