00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "defs.h"
00038
00039
00040 #ifndef __lock_h
00041 #define __lock_h
00042
00043 #include "../../dprint.h"
00044 #include "../../locking.h"
00045
00046
00047
00048 #ifdef GEN_LOCK_T_PREFERED
00049 #define ser_lock_t gen_lock_t
00050 #else
00051
00052
00053 typedef struct {
00054 gen_lock_set_t* semaphore_set;
00055 int semaphore_index;
00056 } ser_lock_t;
00057 #endif
00058
00059
00060
00061 #include "h_table.h"
00062
00063
00064
00065 int lock_initialize(void);
00066 void lock_cleanup(void);
00067
00068 #ifdef DBG_LOCK
00069 #define lock(_s) _lock( (_s), __FILE__, __FUNCTION__, __LINE__ )
00070 #define unlock(_s) _unlock( (_s), __FILE__, __FUNCTION__, __LINE__ )
00071 #else
00072 #define lock(_s) _lock( (_s) )
00073 #define unlock(_s) _unlock( (_s) )
00074 #endif
00075
00076
00077 int init_cell_lock( struct cell *cell );
00078 int init_entry_lock( struct s_table* ht, struct entry *entry );
00079
00080
00081 int release_cell_lock( struct cell *cell );
00082 int release_entry_lock( struct entry *entry );
00083
00084
00085
00086
00087 #ifdef DBG_LOCK
00088 static inline void _lock( ser_lock_t* s , char *file, char *function,
00089 unsigned int line )
00090 #else
00091 static inline void _lock( ser_lock_t* s )
00092 #endif
00093 {
00094 #ifdef DBG_LOCK
00095 DBG("DEBUG: lock : entered from %s , %s(%d)\n", function, file, line );
00096 #endif
00097 #ifdef GEN_LOCK_T_PREFERED
00098 lock_get(s);
00099 #else
00100 lock_set_get(s->semaphore_set, s->semaphore_index);
00101 #endif
00102 }
00103
00104
00105
00106 #ifdef DBG_LOCK
00107 static inline void _unlock( ser_lock_t* s, char *file, char *function,
00108 unsigned int line )
00109 #else
00110 static inline void _unlock( ser_lock_t* s )
00111 #endif
00112 {
00113 #ifdef DBG_LOCK
00114 DBG("DEBUG: unlock : entered from %s, %s:%d\n", file, function, line );
00115 #endif
00116 #ifdef GEN_LOCK_T_PREFERED
00117 lock_release(s);
00118 #else
00119 lock_set_release( s->semaphore_set, s->semaphore_index );
00120 #endif
00121 }
00122
00123
00124
00125 #endif
00126