lock.h
Go to the documentation of this file.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
00038 #ifndef __lock_h
00039 #define __lock_h
00040
00041 #include "../../dprint.h"
00042 #include "../../locking.h"
00043
00044
00045
00046 #ifdef GEN_LOCK_T_PREFERED
00047 #define ser_lock_t gen_lock_t
00048 #else
00049
00050
00051 typedef struct {
00052 gen_lock_set_t* semaphore_set;
00053 int semaphore_index;
00054 } ser_lock_t;
00055 #endif
00056
00057
00058 enum timer_groups {
00059 TG_FR,
00060 TG_WT,
00061 TG_DEL,
00062 TG_RT,
00063 TG_NR
00064 };
00065
00066
00067
00068
00069 #include "h_table.h"
00070 #include "timer.h"
00071
00072 #define IPC_PERMISSIONS 0666
00073
00074
00075 int lock_initialize(void);
00076 void lock_cleanup(void);
00077
00078 #ifdef DBG_LOCK
00079 #define lock(_s) _lock( (_s), __FILE__, __FUNCTION__, __LINE__ )
00080 #define unlock(_s) _unlock( (_s), __FILE__, __FUNCTION__, __LINE__ )
00081 #else
00082 #define lock(_s) _lock( (_s) )
00083 #define unlock(_s) _unlock( (_s) )
00084 #endif
00085
00086
00087 int init_cell_lock( struct cell *cell );
00088 int init_entry_lock( struct s_table* ht, struct entry *entry );
00089
00090
00091
00092
00093 #ifdef DBG_LOCK
00094 static inline void _lock( ser_lock_t* s , char *file, char *function, unsigned int line )
00095 #else
00096 static inline void _lock( ser_lock_t* s )
00097 #endif
00098 {
00099 #ifdef DBG_LOCK
00100 LM_DBG("lock : entered from %s , %s(%d)\n", function, file, line );
00101 #endif
00102 #ifdef GEN_LOCK_T_PREFERED
00103 lock_get(s);
00104 #else
00105 lock_set_get(s->semaphore_set, s->semaphore_index);
00106 #endif
00107 }
00108
00109
00110
00111 #ifdef DBG_LOCK
00112 static inline void _unlock( ser_lock_t* s, char *file, char *function,
00113 unsigned int line )
00114 #else
00115 static inline void _unlock( ser_lock_t* s )
00116 #endif
00117 {
00118 #ifdef DBG_LOCK
00119 LM_DBG("unlock : entered from %s, %s:%d\n", file, function, line );
00120 #endif
00121 #ifdef GEN_LOCK_T_PREFERED
00122 lock_release(s);
00123 #else
00124 lock_set_release( s->semaphore_set, s->semaphore_index );
00125 #endif
00126 }
00127
00128 int init_timerlist_lock( enum lists timerlist_id);
00129
00130
00131 #endif
00132