Lines Matching refs:sv
62 static inline void sv_lock(sv_t *sv) { in sv_lock() argument
63 spin_lock(&sv->sv_lock); in sv_lock()
66 static inline void sv_unlock(sv_t *sv) { in sv_unlock() argument
67 spin_unlock(&sv->sv_lock); in sv_unlock()
84 static inline void sv_set_mon_type(sv_t *sv, int type) { in sv_set_mon_type() argument
87 sv->sv_mon_unlock_func = in sv_set_mon_type()
91 sv->sv_mon_unlock_func = in sv_set_mon_type()
93 if(sv->sv_flags & SV_INTS) { in sv_set_mon_type()
99 if(sv->sv_flags & SV_BHS) { in sv_set_mon_type()
116 sv->sv_mon_unlock_func = c->sv_mon_unlock_func; in sv_set_mon_type()
117 sv->sv_mon_lock = c->sv_mon_lock; in sv_set_mon_type()
124 "(flags 0x%x)\n", type, type, sv->sv_flags); in sv_set_mon_type()
128 sv->sv_flags |= type; in sv_set_mon_type()
131 static inline void sv_set_ord(sv_t *sv, int ord) { in sv_set_ord() argument
141 sv->sv_flags |= ord; in sv_set_ord()
144 void sv_init(sv_t *sv, sv_mon_lock_t *lock, int flags) in sv_init() argument
150 sv->sv_flags = (flags & ~(SV_ORDER_MASK | SV_MON_MASK)); in sv_init()
152 if((sv->sv_flags & (SV_INTS | SV_BHS)) == (SV_INTS | SV_BHS)) { in sv_init()
157 sv_set_ord(sv, ord); in sv_init()
158 sv_set_mon_type(sv, type); in sv_init()
162 sv->sv_mon_lock = lock; in sv_init()
164 spin_lock_init(&sv->sv_lock); in sv_init()
165 init_waitqueue_head(&sv->sv_waiters); in sv_init()
177 signed long sv_wait(sv_t *sv, int sv_wait_flags, unsigned long timeout) in sv_wait() argument
188 if(sv->sv_flags & SV_INTS) { in sv_wait()
203 sv_lock(sv); in sv_wait()
205 sv->sv_mon_unlock_func(sv->sv_mon_lock); in sv_wait()
213 wq_write_lock_irqsave(&sv->sv_waiters.lock, flags); in sv_wait()
219 switch(sv->sv_flags & SV_ORDER_MASK) { in sv_wait()
221 __add_wait_queue_tail(&sv->sv_waiters, &wait); in sv_wait()
224 __add_wait_queue(&sv->sv_waiters, &wait); in sv_wait()
228 (void *)sv, sv->sv_flags); in sv_wait()
231 wq_write_unlock_irqrestore(&sv->sv_waiters.lock, flags); in sv_wait()
238 spin_unlock(&sv->sv_lock); in sv_wait()
240 if(sv->sv_flags & SV_INTS) in sv_wait()
242 else if(sv->sv_flags & SV_BHS) in sv_wait()
256 remove_wait_queue(&sv->sv_waiters, &wait); in sv_wait()
272 void sv_signal(sv_t *sv) in sv_signal() argument
280 if(sv->sv_flags & SV_INTS) { in sv_signal()
289 sv_lock(sv); in sv_signal()
290 wake_up(&sv->sv_waiters); in sv_signal()
291 sv_unlock(sv); in sv_signal()
294 void sv_broadcast(sv_t *sv) in sv_broadcast() argument
297 if(sv->sv_flags & SV_INTS) { in sv_broadcast()
306 sv_lock(sv); in sv_broadcast()
307 wake_up_all(&sv->sv_waiters); in sv_broadcast()
308 sv_unlock(sv); in sv_broadcast()
311 void sv_destroy(sv_t *sv) in sv_destroy() argument
313 if(!spin_trylock(&sv->sv_lock)) { in sv_destroy()
314 printk(KERN_ERR "sv_destroy: someone else has sv 0x%p locked!\n", (void *)sv); in sv_destroy()
328 sv_t sv; variable
342 sv_spin_wait(&sv, arg); in sv_test_1_w()
358 sv_signal(&sv); in sv_test_1_s()
372 sv_t *sv = (sv_t *)arg; in sv_test_2_w() local
377 sv_sema_wait(sv, &monitor); in sv_test_2_w()
386 sv_t *sv = (sv_t *)arg; in sv_test_2_s_1() local
391 sv_signal(sv); in sv_test_2_s_1()
396 sv_signal(sv); in sv_test_2_s_1()
397 sv_broadcast(sv); in sv_test_2_s_1()
398 sv_signal(sv); in sv_test_2_s_1()
399 sv_broadcast(sv); in sv_test_2_s_1()
410 sv_t *sv = (sv_t *)arg; in sv_test_2_s() local
415 sv_signal(sv); in sv_test_2_s()
420 sv_broadcast(sv); in sv_test_2_s()
433 static void big_test(sv_t *sv) in big_test() argument
441 kernel_thread(sv_test_2_w, sv, 0); in big_test()
446 kernel_thread(sv_test_2_s_1, sv, 0); in big_test()
454 kernel_thread(sv_test_2_w, sv, 0); in big_test()
459 kernel_thread(sv_test_2_s, sv, 0); in big_test()
520 sv_init(&sv, &s, SV_MON_SPIN); in sv_test()
529 sv_destroy(&sv); in sv_test()
535 sv_init(&sv, &monitor, SV_MON_SEMA); in sv_test()
536 big_test(&sv); in sv_test()
537 sv_destroy(&sv); in sv_test()