From 5749f1d8fe80cbb84d66a265bcf9bafe159985ab Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Tue, 6 Nov 2007 10:41:14 +0000 Subject: Rename source files in an ot_ fashion --- ot_mutex.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 ot_mutex.c (limited to 'ot_mutex.c') diff --git a/ot_mutex.c b/ot_mutex.c new file mode 100644 index 0000000..5c14e45 --- /dev/null +++ b/ot_mutex.c @@ -0,0 +1,77 @@ +/* This software was written by Dirk Engling + It is considered beerware. Prost. Skol. Cheers or whatever. */ + +#include +#include + +#include "trackerlogic.h" +#include "mutex.h" + +static int bucket_locklist[ OT_MAX_THREADS ]; +static int bucket_locklist_count = 0; +static pthread_mutex_t bucket_mutex; +static pthread_cond_t bucket_being_unlocked; + +static int bucket_check( int bucket ) { + /* C should come with auto-i ;) */ + int i; + + /* No more space to acquire lock to bucket -- should not happen */ + if( bucket_locklist_count == OT_MAX_THREADS ) { + fprintf( stderr, "More lock requests than mutexes. Consult source code.\n" ); + return -1; + } + + /* See, if bucket is already locked */ + for( i=0; i