From 9b742cfd317249c7e0cf7af45ab2fce0ee5c3dba Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 9 Dec 2009 09:39:43 +0100 Subject: [PATCH] Add USE_LOCKMGR_PRIORITY switch to enable new priority management --- bacula/src/lib/lockmgr.c | 11 ++++------- bacula/src/lib/lockmgr.h | 21 ++++++++++++--------- bacula/src/version.h | 4 ++++ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/bacula/src/lib/lockmgr.c b/bacula/src/lib/lockmgr.c index 9315c4fb10..5abf2a71d3 100644 --- a/bacula/src/lib/lockmgr.c +++ b/bacula/src/lib/lockmgr.c @@ -910,10 +910,7 @@ void dbg_print_lock(FILE *fp) #include "lockmgr.h" #define BTHREAD_MUTEX_NO_PRIORITY {PTHREAD_MUTEX_INITIALIZER, 0} -#define BTHREAD_MUTEX_PRIORITY_1 {PTHREAD_MUTEX_INITIALIZER, 1} -#define BTHREAD_MUTEX_PRIORITY_2 {PTHREAD_MUTEX_INITIALIZER, 2} -#define BTHREAD_MUTEX_PRIORITY_3 {PTHREAD_MUTEX_INITIALIZER, 3} -#define BTHREAD_MUTEX_PRIORITY_4 {PTHREAD_MUTEX_INITIALIZER, 4} +#define BTHREAD_MUTEX_PRIORITY(p) {PTHREAD_MUTEX_INITIALIZER, p} #undef P #undef V #define P(x) bthread_mutex_lock_p(&(x), __FILE__, __LINE__) @@ -926,9 +923,9 @@ bthread_mutex_t mutex3 = BTHREAD_MUTEX_NO_PRIORITY; bthread_mutex_t mutex4 = BTHREAD_MUTEX_NO_PRIORITY; bthread_mutex_t mutex5 = BTHREAD_MUTEX_NO_PRIORITY; bthread_mutex_t mutex6 = BTHREAD_MUTEX_NO_PRIORITY; -bthread_mutex_t mutex_p1 = BTHREAD_MUTEX_PRIORITY_1; -bthread_mutex_t mutex_p2 = BTHREAD_MUTEX_PRIORITY_2; -bthread_mutex_t mutex_p3 = BTHREAD_MUTEX_PRIORITY_3; +bthread_mutex_t mutex_p1 = BTHREAD_MUTEX_PRIORITY(1); +bthread_mutex_t mutex_p2 = BTHREAD_MUTEX_PRIORITY(2); +bthread_mutex_t mutex_p3 = BTHREAD_MUTEX_PRIORITY(3); static const char *my_prog; void *self_lock(void *temp) diff --git a/bacula/src/lib/lockmgr.h b/bacula/src/lib/lockmgr.h index afce8bd180..d84bcd7ee0 100644 --- a/bacula/src/lib/lockmgr.h +++ b/bacula/src/lib/lockmgr.h @@ -150,22 +150,25 @@ int lmgr_thread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg); -/* - * Define _LOCKMGR_COMPLIANT to use real pthread functions - */ - -#define BTHREAD_MUTEX_PRIORITY(p) {PTHREAD_MUTEX_INITIALIZER, p} #define BTHREAD_MUTEX_NO_PRIORITY {PTHREAD_MUTEX_INITIALIZER, 0} -#define BTHREAD_MUTEX_PRIORITY_1 {PTHREAD_MUTEX_INITIALIZER, 1} -#define BTHREAD_MUTEX_PRIORITY_2 {PTHREAD_MUTEX_INITIALIZER, 2} -#define BTHREAD_MUTEX_PRIORITY_3 {PTHREAD_MUTEX_INITIALIZER, 3} -#define BTHREAD_MUTEX_PRIORITY_4 {PTHREAD_MUTEX_INITIALIZER, 4} #define BTHREAD_MUTEX_INITIALIZER BTHREAD_MUTEX_NO_PRIORITY + +/* Define USE_LOCKMGR_PRIORITY to detect mutex wrong order */ +#ifdef USE_LOCKMGR_PRIORITY +# define BTHREAD_MUTEX_PRIORITY(p) {PTHREAD_MUTEX_INITIALIZER, p} +#else +# define BTHREAD_MUTEX_PRIORITY(p) BTHREAD_MUTEX_NO_PRIORITY +#endif + #define bthread_mutex_lock(x) bthread_mutex_lock_p(x, __FILE__, __LINE__) #define bthread_mutex_unlock(x) bthread_mutex_unlock_p(x, __FILE__, __LINE__) #define bthread_cond_wait(x,y) bthread_cond_wait_p(x,y, __FILE__, __LINE__) #define bthread_cond_timedwait(x,y,z) bthread_cond_timedwait_p(x,y,z, __FILE__, __LINE__) +/* + * Define _LOCKMGR_COMPLIANT to use real pthread functions + */ + #ifdef _LOCKMGR_COMPLIANT # define P(x) lmgr_p(&(x)) # define V(x) lmgr_v(&(x)) diff --git a/bacula/src/version.h b/bacula/src/version.h index 83df4ff07e..7ec359d2a3 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -66,6 +66,10 @@ # ifndef _USE_LOCKMGR # define _USE_LOCKMGR # endif +/* + * Enable priority management with the lock manager + */ +//# define USE_LOCKMGR_PRIORITY #endif #if !HAVE_LINUX_OS -- 2.39.5