Lines Matching +full:wait +full:- +full:state
1 /* SPDX-License-Identifier: GPL-2.0 */
5 * Linux wait queue related types and methods
12 #include <uapi/linux/wait.h>
28 * A single wait-queue entry structure:
84 wq_entry->flags = 0; in init_waitqueue_entry()
85 wq_entry->private = p; in init_waitqueue_entry()
86 wq_entry->func = default_wake_function; in init_waitqueue_entry()
92 wq_entry->flags = 0; in init_waitqueue_func_entry()
93 wq_entry->private = NULL; in init_waitqueue_func_entry()
94 wq_entry->func = func; in init_waitqueue_func_entry()
98 * waitqueue_active -- locklessly test for waiters on the queue
101 * returns true if the wait list is not empty
104 * lead to sporadic and non-obvious failure.
109 * CPU0 - waker CPU1 - waiter
112 * @cond = true; prepare_to_wait(&wq_head, &wait, state);
118 * finish_wait(&wq_head, &wait);
122 * observe an empty wait list while the waiter might not observe @cond.
129 return !list_empty(&wq_head->head); in waitqueue_active()
133 * wq_has_single_sleeper - check if there is only one sleeper
134 * @wq_head: wait queue head
142 return list_is_singular(&wq_head->head); in wq_has_single_sleeper()
146 * wq_has_sleeper - check if there are any waiting processes
147 * @wq_head: wait queue head
157 * add_wait_queue modifications to the wait queue. in wq_has_sleeper()
173 struct list_head *head = &wq_head->head; in __add_wait_queue()
176 list_for_each_entry(wq, &wq_head->head, entry) { in __add_wait_queue()
177 if (!(wq->flags & WQ_FLAG_PRIORITY)) in __add_wait_queue()
179 head = &wq->entry; in __add_wait_queue()
181 list_add(&wq_entry->entry, head); in __add_wait_queue()
185 * Used for wake-one threads:
190 wq_entry->flags |= WQ_FLAG_EXCLUSIVE; in __add_wait_queue_exclusive()
196 list_add_tail(&wq_entry->entry, &wq_head->head); in __add_wait_queue_entry_tail()
202 wq_entry->flags |= WQ_FLAG_EXCLUSIVE; in __add_wait_queue_entry_tail_exclusive()
209 list_del(&wq_entry->entry); in __remove_wait_queue()
256 #define ___wait_is_interruptible(state) \ argument
257 (!__builtin_constant_p(state) || \
258 state == TASK_INTERRUPTIBLE || state == TASK_KILLABLE) \
274 #define ___wait_event(wq_head, condition, state, exclusive, ret, cmd) \ argument
282 long __int = prepare_to_wait_event(&wq_head, &__wq_entry, state);\
287 if (___wait_is_interruptible(state) && __int) { \
303 * wait_event - sleep until a condition gets true
304 * @wq_head: the waitqueue to wait on
305 * @condition: a C expression for the event to wait for
312 * change the result of the wait condition.
327 * io_wait_event() -- like wait_event() but with io_schedule()
342 * wait_event_freezable - sleep (or freeze) until a condition gets true
343 * @wq_head: the waitqueue to wait on
344 * @condition: a C expression for the event to wait for
346 * The process is put to sleep (TASK_INTERRUPTIBLE -- so as not to contribute
351 * change the result of the wait condition.
368 * wait_event_timeout - sleep until a condition gets true or a timeout elapses
369 * @wq_head: the waitqueue to wait on
370 * @condition: a C expression for the event to wait for
378 * change the result of the wait condition.
401 * like wait_event_timeout() -- except it uses TASK_INTERRUPTIBLE to avoid
431 * wait_event_cmd - sleep until a condition gets true
432 * @wq_head: the waitqueue to wait on
433 * @condition: a C expression for the event to wait for
442 * change the result of the wait condition.
456 * wait_event_interruptible - sleep until a condition gets true
457 * @wq_head: the waitqueue to wait on
458 * @condition: a C expression for the event to wait for
465 * change the result of the wait condition.
467 * The function will return -ERESTARTSYS if it was interrupted by a
485 * wait_event_interruptible_timeout - sleep until a condition gets true or a timeout elapses
486 * @wq_head: the waitqueue to wait on
487 * @condition: a C expression for the event to wait for
495 * change the result of the wait condition.
501 * to %true before the @timeout elapsed, or -%ERESTARTSYS if it was
514 #define __wait_event_hrtimeout(wq_head, condition, timeout, state) \ argument
523 current->timer_slack_ns, \
526 __ret = ___wait_event(wq_head, condition, state, 0, 0, \
528 __ret = -ETIME; \
539 * wait_event_hrtimeout - sleep until a condition gets true or a timeout elapses
540 * @wq_head: the waitqueue to wait on
541 * @condition: a C expression for the event to wait for
549 * change the result of the wait condition.
551 * The function returns 0 if @condition became true, or -ETIME if the timeout
565 * wait_event_interruptible_hrtimeout - sleep until a condition gets true or a timeout elapses
566 * @wq: the waitqueue to wait on
567 * @condition: a C expression for the event to wait for
575 * change the result of the wait condition.
577 * The function returns 0 if @condition became true, -ERESTARTSYS if it was
578 * interrupted by a signal, or -ETIME if the timeout elapsed.
631 * wait_event_idle - wait for a condition without contributing to system load
632 * @wq_head: the waitqueue to wait on
633 * @condition: a C expression for the event to wait for
640 * change the result of the wait condition.
651 * wait_event_idle_exclusive - wait for a condition with contributing to system load
652 * @wq_head: the waitqueue to wait on
653 * @condition: a C expression for the event to wait for
659 * The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag
660 * set thus if other processes wait on the same list, when this
664 * change the result of the wait condition.
680 * wait_event_idle_timeout - sleep without load until a condition becomes true or a timeout elapses
681 * @wq_head: the waitqueue to wait on
682 * @condition: a C expression for the event to wait for
690 * change the result of the wait condition.
713 …* wait_event_idle_exclusive_timeout - sleep without load until a condition becomes true or a timeo…
714 * @wq_head: the waitqueue to wait on
715 * @condition: a C expression for the event to wait for
722 * The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag
723 * set thus if other processes wait on the same list, when this
727 * change the result of the wait condition.
765 * wait_event_interruptible_locked - sleep until a condition gets true
766 * @wq: the waitqueue to wait on
767 * @condition: a C expression for the event to wait for
782 * change the result of the wait condition.
784 * The function will return -ERESTARTSYS if it was interrupted by a
792 * wait_event_interruptible_locked_irq - sleep until a condition gets true
793 * @wq: the waitqueue to wait on
794 * @condition: a C expression for the event to wait for
809 * change the result of the wait condition.
811 * The function will return -ERESTARTSYS if it was interrupted by a
819 * wait_event_interruptible_exclusive_locked - sleep exclusively until a condition gets true
820 * @wq: the waitqueue to wait on
821 * @condition: a C expression for the event to wait for
835 * The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag
840 * change the result of the wait condition.
842 * The function will return -ERESTARTSYS if it was interrupted by a
850 * wait_event_interruptible_exclusive_locked_irq - sleep until a condition gets true
851 * @wq: the waitqueue to wait on
852 * @condition: a C expression for the event to wait for
866 * The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag
871 * change the result of the wait condition.
873 * The function will return -ERESTARTSYS if it was interrupted by a
885 * wait_event_killable - sleep until a condition gets true
886 * @wq_head: the waitqueue to wait on
887 * @condition: a C expression for the event to wait for
894 * change the result of the wait condition.
896 * The function will return -ERESTARTSYS if it was interrupted by a
914 * wait_event_killable_timeout - sleep until a condition gets true or a timeout elapses
915 * @wq_head: the waitqueue to wait on
916 * @condition: a C expression for the event to wait for
924 * change the result of the wait condition.
930 * to %true before the @timeout elapsed, or -%ERESTARTSYS if it was
954 * wait_event_lock_irq_cmd - sleep until a condition gets true. The
958 * @wq_head: the waitqueue to wait on
959 * @condition: a C expression for the event to wait for
970 * change the result of the wait condition.
984 * wait_event_lock_irq - sleep until a condition gets true. The
988 * @wq_head: the waitqueue to wait on
989 * @condition: a C expression for the event to wait for
998 * change the result of the wait condition.
1019 * wait_event_interruptible_lock_irq_cmd - sleep until a condition gets true.
1022 * @wq_head: the waitqueue to wait on
1023 * @condition: a C expression for the event to wait for
1034 * change the result of the wait condition.
1040 * The macro will return -ERESTARTSYS if it was interrupted by a signal
1053 * wait_event_interruptible_lock_irq - sleep until a condition gets true.
1056 * @wq_head: the waitqueue to wait on
1057 * @condition: a C expression for the event to wait for
1066 * change the result of the wait condition.
1071 * The macro will return -ERESTARTSYS if it was interrupted by a signal
1083 #define __wait_event_lock_irq_timeout(wq_head, condition, lock, timeout, state) \ argument
1085 state, 0, timeout, \
1091 * wait_event_interruptible_lock_irq_timeout - sleep until a condition gets
1094 * @wq_head: the waitqueue to wait on
1095 * @condition: a C expression for the event to wait for
1105 * change the result of the wait condition.
1110 * The function returns 0 if the @timeout elapsed, -ERESTARTSYS if it
1138 void prepare_to_wait(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry, int state);
1139 …e_to_wait_exclusive(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry, int state);
1140 …epare_to_wait_event(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry, int state);
1155 #define init_wait(wait) \ argument
1157 (wait)->private = current; \
1158 (wait)->func = autoremove_wake_function; \
1159 INIT_LIST_HEAD(&(wait)->entry); \
1160 (wait)->flags = 0; \