From a2e2687e8622dfeb2c37a37930c66cde42c7b285 Mon Sep 17 00:00:00 2001 From: adash Date: Thu, 27 Aug 2009 23:13:48 +0000 Subject: [PATCH] check latency of a lock release and lock acquire --- .../SingleTM/MicroBenchmarks/lockLatency.c | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Robust/src/Benchmarks/SingleTM/MicroBenchmarks/lockLatency.c diff --git a/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/lockLatency.c b/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/lockLatency.c new file mode 100644 index 00000000..0fe6068d --- /dev/null +++ b/Robust/src/Benchmarks/SingleTM/MicroBenchmarks/lockLatency.c @@ -0,0 +1,114 @@ +#include +#include +#include +#include +#include + + +#define THREADS 2 +#define ITERATIONS 1000 +pthread_mutex_t LOCK; +//pthread_mutex_t START; +//Barrier variable +pthread_barrier_t barr; +int tottime = 0, time1, time2; + +int64_t timeInMS () //time in microsec +{ + struct timeval t; + + gettimeofday(&t, NULL); + return ( + (int64_t)t.tv_sec * 1000000 + + (int64_t)t.tv_usec + ); +} + +void * thd1 ( + void * unused + ) { + // Wait till we may fire away + //pthread_mutex_lock(&START); + //pthread_mutex_unlock(&START); + + int count = 0; + while(count