/* 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. */
-#include "gras_config.h"
+#include "internal_config.h"
#include <unistd.h>
#ifndef _XBT_WIN32
#ifdef HAVE_FUTEX_H
#include <linux/futex.h>
+#include <limits.h>
#endif
#include "xbt/parmap.h"
{
xbt_os_mutex_acquire(parmap->ready_mutex);
/* wait for more work */
- if (parmap->work < round) {
+ if (parmap->work != round) {
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 */
- futex_wake(&parmap->thread_counter, 1);
+ futex_wake(&parmap->thread_counter, INT_MAX);
}
}
parmap->thread_counter = 1;
__sync_add_and_fetch(&parmap->work, 1);
/* wake all workers */
- futex_wake(&parmap->work, parmap->num_workers - 1);
+ futex_wake(&parmap->work, INT_MAX);
}
/**
{
unsigned work = parmap->work;
/* wait for more work */
- if (work < round)
+ while (work != round) {
futex_wait(&parmap->work, work);
+ work = parmap->work;
+ }
}
#endif
static void xbt_parmap_busy_worker_wait(xbt_parmap_t parmap, unsigned round)
{
/* wait for more work */
- while (parmap->work < round) {
+ while (parmap->work != round) {
xbt_os_thread_yield();
}
}
#include "xbt/ex.h"
#include "xbt/xbt_os_thread.h"
#include "xbt/xbt_os_time.h"
-#include "gras_config.h" /* HAVE_FUTEX_H */
+#include "internal_config.h" /* HAVE_FUTEX_H */
XBT_TEST_SUITE("parmap", "Parallel Map");
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_parmap_unit);