1 /* Copyright Transarc Corporation 1998 - All Rights Reserved
3 * rx_kmutex.h - mutex and condition variable macros for kernel environment.
14 /* #include <kern/sched_prim.h> */
15 /* #include <sys/unix_defs.h> */
17 #define RX_ENABLE_LOCKS 1
18 #define AFS_GLOBAL_RXLOCK_KERNEL
23 * In Digital Unix (OSF/1), we use something akin to the ancient sleep/wakeup
24 * mechanism. The condition variable itself plays no role; we just use its
25 * address as a convenient unique number.
27 #define CV_INIT(cv,a,b,c)
28 #define CV_DESTROY(cv)
29 #define CV_WAIT(cv, lck) { \
30 int isGlockOwner = ISAFS_GLOCK(); \
31 if (isGlockOwner) AFS_GUNLOCK(); \
32 assert_wait((vm_offset_t)(cv), 0); \
35 if (isGlockOwner) AFS_GLOCK(); \
39 #define CV_TIMEDWAIT(cv,lck,t) { \
40 int isGlockOwner = ISAFS_GLOCK(); \
41 if (isGlockOwner) AFS_GUNLOCK(); \
42 assert_wait((vm_offset_t)(cv), 0); \
43 thread_set_timeout(t); \
46 if (isGlockOwner) AFS_GLOCK(); \
50 #define CV_SIGNAL(cv) thread_wakeup_one((vm_offset_t)(cv))
51 #define CV_BROADCAST(cv) thread_wakeup((vm_offset_t)(cv))
54 struct simplelock lock;
56 typedef int afs_kcondvar_t;
58 #define osi_rxWakeup(cv) thread_wakeup((vm_offset_t)(cv))
60 #define LOCK_INIT(a,b) \
62 usimple_lock_init(&(a)->lock); \
64 #define MUTEX_INIT(a,b,c,d) \
66 usimple_lock_init(&(a)->lock); \
68 #define MUTEX_DESTROY(a) \
70 usimple_lock_terminate(&(a)->lock); \
72 #define MUTEX_ENTER(a) \
74 usimple_lock(&(a)->lock); \
76 #define MUTEX_TRYENTER(a) \
77 usimple_lock(&(a)->lock)
78 #define MUTEX_EXIT(a) \
80 usimple_unlock(&(a)->lock); \
84 #define MUTEX_ISMINE(a) 1
86 #define MUTEX_ISMINE(a)
87 (((afs_kmutex_t *)(a))->owner == current_thread())
90 #undef osirx_AssertMine
91 extern void osirx_AssertMine(afs_kmutex_t *lockaddr, char *msg);
96 #endif /* _RX_KMUTEX_H_ */