previous | start | next

Barrier (2)

Also not a solution:

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


previous | start | next