/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
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 */
XBT_TEST_SUITE("parmap", "Parallel Map");
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_parmap_unit);
XBT_TEST_SUITE("parmap", "Parallel Map");
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_parmap_unit);