aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/benchmarks/larson/larson.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/benchmarks/larson/larson.cc b/src/benchmarks/larson/larson.cc
index be8038f..3da7a12 100644
--- a/src/benchmarks/larson/larson.cc
+++ b/src/benchmarks/larson/larson.cc
@@ -172,6 +172,8 @@ typedef struct thr_data {
int cThreads ;
unsigned long cBytesAlloced ;
+ pthread_barrier_t *barrier;
+
volatile int finished ;
struct lran2_st rgen ;
@@ -436,6 +438,9 @@ void runthreads(long sleep_cnt, int min_threads, int max_threads, int chperthrea
nperthread = chperthread ;
stopflag = FALSE ;
+
+ pthread_barrier_t barrier;
+ pthread_barrier_init(&barrier, NULL, num_threads + 1);
for(i=0; i< num_threads; i++){
de_area[i].threadno = i+1 ;
@@ -450,6 +455,7 @@ void runthreads(long sleep_cnt, int min_threads, int max_threads, int chperthrea
de_area[i].cAllocs = 0 ;
de_area[i].cFrees = 0 ;
de_area[i].cThreads = 0 ;
+ de_area[i].barrier = &barrier ;
de_area[i].finished = FALSE ;
lran2_init(&de_area[i].rgen, de_area[i].seed) ;
@@ -461,6 +467,8 @@ void runthreads(long sleep_cnt, int min_threads, int max_threads, int chperthrea
}
+ pthread_barrier_wait(&barrier);
+
QueryPerformanceCounter( &start_cnt) ;
// printf ("Sleeping for %ld seconds.\n", sleep_cnt);
@@ -553,6 +561,8 @@ static void * exercise_heap( void *pinput)
pdea->cThreads++ ;
range = pdea->max_size - pdea->min_size ;
+ pthread_barrier_wait(pdea->barrier);
+
/* allocate NumBlocks chunks of random size */
for( cblks=0; cblks<pdea->NumBlocks; cblks++){
victim = lran2(&pdea->rgen)%pdea->asize ;