summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2013-03-22 21:39:37 -0400
committerTavian Barnes <tavianator@tavianator.com>2013-03-22 21:39:37 -0400
commit62fac6e15e51422a544de01ce6cb01b0921a6706 (patch)
treecb7c5ffb4b5301221016134df73dde6f527af8e5 /libdimension
parenta9e7304eb012adbc974019fba70f01ca20a38004 (diff)
downloaddimension-62fac6e15e51422a544de01ce6cb01b0921a6706.tar.xz
Fix a race in the future benchmark.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/bench/future.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libdimension/bench/future.c b/libdimension/bench/future.c
index 815def1..5937c3c 100644
--- a/libdimension/bench/future.c
+++ b/libdimension/bench/future.c
@@ -51,7 +51,11 @@ dmnsn_bench_thread(void *ptr)
/* Benchmark the increment operation. */
sandglass_bench_fine(&sandglass, dmnsn_future_increment(future));
printf("dmnsn_future_increment(): %ld\n", sandglass.grains);
- future->progress = 0;
+
+ /* Reset the progress. */
+ dmnsn_lock_mutex(&future->mutex);
+ future->progress = 0;
+ dmnsn_unlock_mutex(&future->mutex);
/* Now run a bunch of increments concurrently. */
return dmnsn_execute_concurrently(&dmnsn_bench_future, future, nthreads);