4 #include <lwk/spinlock.h>
10 struct list_head waitq;
13 typedef struct waitq_entry {
14 struct task_struct * task;
15 struct list_head link;
18 #define DECLARE_WAITQ(name) \
20 .lock = SPIN_LOCK_UNLOCKED, \
21 .waitq = { &(name).waitq, &(name).waitq } \
24 #define DECLARE_WAITQ_ENTRY(name, tsk) \
25 waitq_entry_t name = { \
27 .link = { &(name).link, &(name).link } \
30 extern void waitq_init(waitq_t *waitq);
31 extern void waitq_init_entry(waitq_entry_t *entry, struct task_struct *task);
32 extern bool waitq_active(waitq_t *waitq);
33 extern void waitq_add_entry(waitq_t *waitq, waitq_entry_t *entry);
34 extern void waitq_prepare_to_wait(waitq_t *waitq, waitq_entry_t *entry,
36 extern void waitq_finish_wait(waitq_t *waitq, waitq_entry_t *entry);
37 extern void waitq_wakeup(waitq_t *waitq);
40 * This puts the task to sleep until condition becomes true.
41 * This must be a macro because condition is tested repeatedly, not just
42 * when wait_event() is first called.
44 #define wait_event(waitq, condition) \
46 DECLARE_WAITQ_ENTRY(__entry, current); \
48 waitq_prepare_to_wait(&waitq, &__entry, \
49 TASKSTATE_UNINTERRUPTIBLE); \
54 waitq_finish_wait(&waitq, &__entry); \