[32] | 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>
|
---|
[679] | 14 | #include <linux/list.h>
|
---|
[32] | 15 | #include <asm/page.h>
|
---|
| 16 |
|
---|
[679] | 17 | typedef struct wait_queue_entry wait_queue_entry_t;
|
---|
| 18 |
|
---|
| 19 | typedef int (*wait_queue_func_t)(struct wait_queue_entry *wq_entry, unsigned mode, int flags, void *key);
|
---|
| 20 |
|
---|
[32] | 21 | /*
|
---|
[679] | 22 | * A single wait-queue entry structure:
|
---|
| 23 | */
|
---|
| 24 | struct wait_queue_entry {
|
---|
| 25 | unsigned int flags;
|
---|
| 26 | void *private;
|
---|
| 27 | wait_queue_func_t func;
|
---|
| 28 | struct list_head entry;
|
---|
| 29 | };
|
---|
| 30 |
|
---|
| 31 | /*
|
---|
[32] | 32 | * Temporary debugging help until all code is converted to the new
|
---|
| 33 | * waitqueue usage.
|
---|
| 34 | */
|
---|
| 35 |
|
---|
| 36 | struct __wait_queue {
|
---|
| 37 | unsigned int compiler_warning;
|
---|
| 38 | struct task_struct * task;
|
---|
| 39 | void * task_list;
|
---|
| 40 | #if WAITQUEUE_DEBUG
|
---|
| 41 | long __magic;
|
---|
| 42 | long __waker;
|
---|
| 43 | #endif
|
---|
| 44 | };
|
---|
| 45 | typedef struct __wait_queue wait_queue_t;
|
---|
| 46 |
|
---|
[679] | 47 | struct __wait_queue_head {
|
---|
| 48 | spinlock_t lock;
|
---|
| 49 | struct list_head task_list;
|
---|
| 50 | };
|
---|
| 51 |
|
---|
| 52 | struct wait_queue_head {
|
---|
| 53 | spinlock_t lock;
|
---|
| 54 | struct list_head head;
|
---|
| 55 | };
|
---|
| 56 | typedef struct wait_queue_head wait_queue_head_t;
|
---|
| 57 |
|
---|
[32] | 58 | /*
|
---|
| 59 | * 'dual' spinlock architecture. Can be switched between spinlock_t and
|
---|
| 60 | * rwlock_t locks via changing this define. Since waitqueues are quite
|
---|
| 61 | * decoupled in the new architecture, lightweight 'simple' spinlocks give
|
---|
| 62 | * us slightly better latencies and smaller waitqueue structure size.
|
---|
| 63 | */
|
---|
| 64 | #define USE_RW_WAIT_QUEUE_SPINLOCK 0
|
---|
| 65 |
|
---|
| 66 | #if USE_RW_WAIT_QUEUE_SPINLOCK
|
---|
| 67 | # define wq_lock_t rwlock_t
|
---|
| 68 | # define WAITQUEUE_RW_LOCK_UNLOCKED RW_LOCK_UNLOCKED
|
---|
| 69 |
|
---|
| 70 | # define wq_read_lock read_lock
|
---|
| 71 | # define wq_read_lock_irqsave read_lock_irqsave
|
---|
| 72 | # define wq_read_unlock_irqrestore read_unlock_irqrestore
|
---|
| 73 | # define wq_read_unlock read_unlock
|
---|
| 74 | # define wq_write_lock_irq write_lock_irq
|
---|
| 75 | # define wq_write_lock_irqsave write_lock_irqsave
|
---|
| 76 | # define wq_write_unlock_irqrestore write_unlock_irqrestore
|
---|
| 77 | # define wq_write_unlock write_unlock
|
---|
| 78 | #else
|
---|
| 79 | # define wq_lock_t spinlock_t
|
---|
| 80 | # define WAITQUEUE_RW_LOCK_UNLOCKED SPIN_LOCK_UNLOCKED
|
---|
| 81 |
|
---|
| 82 | # define wq_read_lock spin_lock
|
---|
| 83 | # define wq_read_lock_irqsave spin_lock_irqsave
|
---|
| 84 | # define wq_read_unlock spin_unlock
|
---|
| 85 | # define wq_read_unlock_irqrestore spin_unlock_irqrestore
|
---|
| 86 | # define wq_write_lock_irq spin_lock_irq
|
---|
| 87 | # define wq_write_lock_irqsave spin_lock_irqsave
|
---|
| 88 | # define wq_write_unlock_irqrestore spin_unlock_irqrestore
|
---|
| 89 | # define wq_write_unlock spin_unlock
|
---|
| 90 | #endif
|
---|
| 91 |
|
---|
| 92 | #if WAITQUEUE_DEBUG
|
---|
| 93 | # define __WAITQUEUE_DEBUG_INIT(name) \
|
---|
| 94 | , (long)&(name).__magic, 0
|
---|
| 95 | # define __WAITQUEUE_HEAD_DEBUG_INIT(name) \
|
---|
| 96 | , (long)&(name).__magic, (long)&(name).__magic
|
---|
| 97 | #else
|
---|
| 98 | # define __WAITQUEUE_DEBUG_INIT(name)
|
---|
| 99 | # define __WAITQUEUE_HEAD_DEBUG_INIT(name)
|
---|
| 100 | #endif
|
---|
| 101 |
|
---|
| 102 | #define __WAITQUEUE_INITIALIZER(name,task) \
|
---|
| 103 | { 0x1234567, NULL, NULL __WAITQUEUE_DEBUG_INIT(name)}
|
---|
| 104 | #define DECLARE_WAITQUEUE(name,task) \
|
---|
| 105 | wait_queue_t name = __WAITQUEUE_INITIALIZER(name,task)
|
---|
| 106 |
|
---|
| 107 | #define __WAIT_QUEUE_HEAD_INITIALIZER(name) \
|
---|
[679] | 108 | { WAITQUEUE_RW_LOCK_UNLOCKED, { &(name).head, &(name).head } \
|
---|
[32] | 109 | __WAITQUEUE_HEAD_DEBUG_INIT(name)}
|
---|
| 110 |
|
---|
| 111 | #define DECLARE_WAIT_QUEUE_HEAD(name) \
|
---|
| 112 | wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
|
---|
| 113 |
|
---|
| 114 | void init_waitqueue_head(wait_queue_head_t *q);
|
---|
| 115 |
|
---|
[679] | 116 | extern void init_waitqueue_entry(struct wait_queue_entry *wq_entry, struct task_struct *p);
|
---|
| 117 | extern void add_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry);
|
---|
| 118 | extern void add_wait_queue_exclusive(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry);
|
---|
| 119 | extern void remove_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry);
|
---|
[32] | 120 |
|
---|
| 121 | int waitqueue_active(wait_queue_head_t *q);
|
---|
| 122 |
|
---|
| 123 | void __add_wait_queue(wait_queue_head_t *head, wait_queue_t *new);
|
---|
| 124 |
|
---|
| 125 | /*
|
---|
| 126 | * Used for wake-one threads:
|
---|
| 127 | */
|
---|
| 128 | void __add_wait_queue_tail(wait_queue_head_t *head, wait_queue_t *new);
|
---|
| 129 | void __remove_wait_queue(wait_queue_head_t *head, wait_queue_t *old);
|
---|
[679] | 130 | void __wake_up_locked(wait_queue_head_t *q, unsigned int mode, int nr);
|
---|
[32] | 131 | #endif /* __KERNEL__ */
|
---|
[679] | 132 | #define wait_event_lock_irq(wq_head, condition, lock)
|
---|
[703] | 133 | #define wait_event(wq_head, condition)
|
---|
[679] | 134 | #define wake_up_all(x)
|
---|
[772] | 135 |
|
---|
| 136 | #define wait_event_cmd(wq_head, condition, cmd1, cmd2)
|
---|
| 137 |
|
---|
[32] | 138 | #endif
|
---|