From: adash Date: Thu, 27 Aug 2009 23:13:48 +0000 (+0000) Subject: check latency of a lock release and lock acquire X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a2e2687e8622dfeb2c37a37930c66cde42c7b285;p=IRC.git check latency of a lock release and lock acquire --- 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