2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * rx_kmutex.h - mutex and condition variable macros for kernel environment.
13 * Linux implementation.
14 * This are noops until such time as the kernel no longer has a global lock.
19 #include "../rx/rx_kernel.h" /* for osi_Panic() */
21 /* AFS_GLOBAL_RXLOCK_KERNEL is defined so that the busy tq code paths are
22 * used. The thread can sleep when sending packets.
24 #define AFS_GLOBAL_RXLOCK_KERNEL 1
28 #define RX_ENABLE_LOCKS 1
30 #ifndef _LINUX_CODA_FS_I
31 #define _LINUX_CODA_FS_I
32 struct coda_inode_info {};
34 #include "linux/wait.h"
35 #include "linux/sched.h"
37 typedef struct afs_kmutex {
42 typedef struct wait_queue *afs_kcondvar_t;
45 static inline int MUTEX_ISMINE(afs_kmutex_t *l)
47 return l->owner == current->pid;
51 static inline void afs_mutex_init(afs_kmutex_t *l)
56 #define MUTEX_INIT(a,b,c,d) afs_mutex_init(a)
58 #define MUTEX_DESTROY(a)
60 static inline void MUTEX_ENTER(afs_kmutex_t *l)
64 osi_Panic("mutex_enter: 0x%x held by %d", l, l->owner);
65 l->owner = current->pid;
68 /* And how to do a good tryenter? */
69 static inline int MUTEX_TRYENTER(afs_kmutex_t *l)
79 static inline void MUTEX_EXIT(afs_kmutex_t *l)
81 if (l->owner != current->pid)
82 osi_Panic("mutex_exit: 0x%x held by %d",
88 #define CV_INIT(cv,b,c,d) init_waitqueue((struct wait_queue**)(cv))
89 #define CV_DESTROY(cv)
91 /* CV_WAIT and CV_TIMEDWAIT rely on the fact that the Linux kernel has
92 * a global lock. Thus we can safely drop our locks before calling the
93 * kernel sleep services.
95 static inline CV_WAIT(afs_kcondvar_t *cv, afs_kmutex_t *l)
97 int isAFSGlocked = ISAFS_GLOCK();
99 if (isAFSGlocked) AFS_GUNLOCK();
102 interruptible_sleep_on((struct wait_queue**)cv);
105 if (isAFSGlocked) AFS_GLOCK();
110 static inline CV_TIMEDWAIT(afs_kcondvar_t *cv, afs_kmutex_t *l, int waittime)
112 int isAFSGlocked = ISAFS_GLOCK();
113 long t = waittime * HZ / 1000;
115 if (isAFSGlocked) AFS_GUNLOCK();
118 t = interruptible_sleep_on_timeout((struct wait_queue**)cv, t);
121 if (isAFSGlocked) AFS_GLOCK();
126 #define CV_SIGNAL(cv) wake_up((struct wait_queue**)cv)
127 #define CV_BROADCAST(cv) wake_up((struct wait_queue**)cv)
131 #define MUTEX_ISMINE(a)
132 #define osirx_AssertMine(addr, msg)
134 #define MUTEX_DESTROY(a)
135 #define MUTEX_ENTER(a)
136 #define MUTEX_TRYENTER(a) 1
137 #define MUTEX_EXIT(a)
138 #define MUTEX_INIT(a,b,c,d)
139 #define CV_INIT(a,b,c,d)
140 #define CV_DESTROY(a)
143 /* Since we're using the RX listener daemon, we don't need to hold off
150 #endif /* RX_KMUTEX_H_ */