previous | start | next

Barrier Posix Solution

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


previous | start | next