xbt_os_cond_wait(parmap->ready_cond, parmap->ready_mutex);
}
xbt_os_mutex_release(parmap->ready_mutex);
xbt_os_cond_wait(parmap->ready_cond, parmap->ready_mutex);
}
xbt_os_mutex_release(parmap->ready_mutex);
unsigned count = __sync_add_and_fetch(&parmap->thread_counter, 1);
if (count == parmap->num_workers) {
/* all workers have finished, wake the controller */
unsigned count = __sync_add_and_fetch(&parmap->thread_counter, 1);
if (count == parmap->num_workers) {
/* all workers have finished, wake the controller */
parmap->thread_counter = 1;
__sync_add_and_fetch(&parmap->work, 1);
/* wake all workers */
parmap->thread_counter = 1;
__sync_add_and_fetch(&parmap->work, 1);
/* wake all workers */