From 62fac6e15e51422a544de01ce6cb01b0921a6706 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 22 Mar 2013 21:39:37 -0400 Subject: Fix a race in the future benchmark. --- libdimension/bench/future.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libdimension') 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); -- cgit v1.2.3