1 | /* $Id: wait.h,v 1.1.1.1 2003/07/02 13:57:02 eleph Exp $ */
|
---|
2 |
|
---|
3 | #ifndef _LINUX_WAIT_H
|
---|
4 | #define _LINUX_WAIT_H
|
---|
5 |
|
---|
6 | #define WNOHANG 0x00000001
|
---|
7 | #define WUNTRACED 0x00000002
|
---|
8 |
|
---|
9 | #define __WCLONE 0x80000000
|
---|
10 |
|
---|
11 | #ifdef __KERNEL__
|
---|
12 |
|
---|
13 | #include <linux/spinlock.h>
|
---|
14 |
|
---|
15 | #include <asm/page.h>
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * Temporary debugging help until all code is converted to the new
|
---|
19 | * waitqueue usage.
|
---|
20 | */
|
---|
21 |
|
---|
22 | struct __wait_queue {
|
---|
23 | unsigned int compiler_warning;
|
---|
24 | struct task_struct * task;
|
---|
25 | void * task_list;
|
---|
26 | #if WAITQUEUE_DEBUG
|
---|
27 | long __magic;
|
---|
28 | long __waker;
|
---|
29 | #endif
|
---|
30 | };
|
---|
31 | typedef struct __wait_queue wait_queue_t;
|
---|
32 |
|
---|
33 | /*
|
---|
34 | * 'dual' spinlock architecture. Can be switched between spinlock_t and
|
---|
35 | * rwlock_t locks via changing this define. Since waitqueues are quite
|
---|
36 | * decoupled in the new architecture, lightweight 'simple' spinlocks give
|
---|
37 | * us slightly better latencies and smaller waitqueue structure size.
|
---|
38 | */
|
---|
39 | #define USE_RW_WAIT_QUEUE_SPINLOCK 0
|
---|
40 |
|
---|
41 | #if USE_RW_WAIT_QUEUE_SPINLOCK
|
---|
42 | # define wq_lock_t rwlock_t
|
---|
43 | # define WAITQUEUE_RW_LOCK_UNLOCKED RW_LOCK_UNLOCKED
|
---|
44 |
|
---|
45 | # define wq_read_lock read_lock
|
---|
46 | # define wq_read_lock_irqsave read_lock_irqsave
|
---|
47 | # define wq_read_unlock_irqrestore read_unlock_irqrestore
|
---|
48 | # define wq_read_unlock read_unlock
|
---|
49 | # define wq_write_lock_irq write_lock_irq
|
---|
50 | # define wq_write_lock_irqsave write_lock_irqsave
|
---|
51 | # define wq_write_unlock_irqrestore write_unlock_irqrestore
|
---|
52 | # define wq_write_unlock write_unlock
|
---|
53 | #else
|
---|
54 | # define wq_lock_t spinlock_t
|
---|
55 | # define WAITQUEUE_RW_LOCK_UNLOCKED SPIN_LOCK_UNLOCKED
|
---|
56 |
|
---|
57 | # define wq_read_lock spin_lock
|
---|
58 | # define wq_read_lock_irqsave spin_lock_irqsave
|
---|
59 | # define wq_read_unlock spin_unlock
|
---|
60 | # define wq_read_unlock_irqrestore spin_unlock_irqrestore
|
---|
61 | # define wq_write_lock_irq spin_lock_irq
|
---|
62 | # define wq_write_lock_irqsave spin_lock_irqsave
|
---|
63 | # define wq_write_unlock_irqrestore spin_unlock_irqrestore
|
---|
64 | # define wq_write_unlock spin_unlock
|
---|
65 | #endif
|
---|
66 |
|
---|
67 | struct __wait_queue_head {
|
---|
68 | void * lock;
|
---|
69 | void * task_list;
|
---|
70 | #if WAITQUEUE_DEBUG
|
---|
71 | long __magic;
|
---|
72 | long __creator;
|
---|
73 | #endif
|
---|
74 | };
|
---|
75 | typedef struct __wait_queue_head wait_queue_head_t;
|
---|
76 |
|
---|
77 | #if WAITQUEUE_DEBUG
|
---|
78 | # define __WAITQUEUE_DEBUG_INIT(name) \
|
---|
79 | , (long)&(name).__magic, 0
|
---|
80 | # define __WAITQUEUE_HEAD_DEBUG_INIT(name) \
|
---|
81 | , (long)&(name).__magic, (long)&(name).__magic
|
---|
82 | #else
|
---|
83 | # define __WAITQUEUE_DEBUG_INIT(name)
|
---|
84 | # define __WAITQUEUE_HEAD_DEBUG_INIT(name)
|
---|
85 | #endif
|
---|
86 |
|
---|
87 | #define __WAITQUEUE_INITIALIZER(name,task) \
|
---|
88 | { 0x1234567, NULL, NULL __WAITQUEUE_DEBUG_INIT(name)}
|
---|
89 | #define DECLARE_WAITQUEUE(name,task) \
|
---|
90 | wait_queue_t name = __WAITQUEUE_INITIALIZER(name,task)
|
---|
91 |
|
---|
92 | #define __WAIT_QUEUE_HEAD_INITIALIZER(name) \
|
---|
93 | { WAITQUEUE_RW_LOCK_UNLOCKED, { &(name).task_list, &(name).task_list } \
|
---|
94 | __WAITQUEUE_HEAD_DEBUG_INIT(name)}
|
---|
95 |
|
---|
96 | #define DECLARE_WAIT_QUEUE_HEAD(name) \
|
---|
97 | wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
|
---|
98 |
|
---|
99 | void init_waitqueue_head(wait_queue_head_t *q);
|
---|
100 |
|
---|
101 | void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p);
|
---|
102 |
|
---|
103 | int waitqueue_active(wait_queue_head_t *q);
|
---|
104 |
|
---|
105 | void __add_wait_queue(wait_queue_head_t *head, wait_queue_t *new);
|
---|
106 |
|
---|
107 | /*
|
---|
108 | * Used for wake-one threads:
|
---|
109 | */
|
---|
110 | void __add_wait_queue_tail(wait_queue_head_t *head, wait_queue_t *new);
|
---|
111 | void __remove_wait_queue(wait_queue_head_t *head, wait_queue_t *old);
|
---|
112 |
|
---|
113 | #endif /* __KERNEL__ */
|
---|
114 |
|
---|
115 | #endif
|
---|