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()
250 * wake_up_pollfree - signal that a polled waitqueue is going away
251 * @wq_head: the wait queue head
253 * In the very rare cases where a ->poll() implementation uses a waitqueue whose
256 * non-blocking polls (e.g. epoll) are notified that the queue is going away.
258 * The caller must also RCU-delay the freeing of the wait_queue_head, e.g. via
268 * can safely proceed with an RCU-delayed free. in wake_up_pollfree()
282 #define ___wait_is_interruptible(state) \ argument
283 (!__builtin_constant_p(state) || \
284 (state & (TASK_INTERRUPTIBLE | TASK_WAKEKILL)))
300 #define ___wait_event(wq_head, condition, state, exclusive, ret, cmd) \ argument
308 long __int = prepare_to_wait_event(&wq_head, &__wq_entry, state);\
313 if (___wait_is_interruptible(state) && __int) { \
329 * wait_event - sleep until a condition gets true
330 * @wq_head: the waitqueue to wait on
331 * @condition: a C expression for the event to wait for
338 * change the result of the wait condition.
353 * io_wait_event() -- like wait_event() but with io_schedule()
368 * wait_event_freezable - sleep (or freeze) until a condition gets true
369 * @wq_head: the waitqueue to wait on
370 * @condition: a C expression for the event to wait for
372 * The process is put to sleep (TASK_INTERRUPTIBLE -- so as not to contribute
377 * change the result of the wait condition.
394 * wait_event_timeout - sleep until a condition gets true or a timeout elapses
395 * @wq_head: the waitqueue to wait on
396 * @condition: a C expression for the event to wait for
404 * change the result of the wait condition.
427 * like wait_event_timeout() -- except it uses TASK_INTERRUPTIBLE to avoid
457 * wait_event_cmd - sleep until a condition gets true
458 * @wq_head: the waitqueue to wait on
459 * @condition: a C expression for the event to wait for
468 * change the result of the wait condition.
482 * wait_event_interruptible - sleep until a condition gets true
483 * @wq_head: the waitqueue to wait on
484 * @condition: a C expression for the event to wait for
491 * change the result of the wait condition.
493 * The function will return -ERESTARTSYS if it was interrupted by a
511 * wait_event_interruptible_timeout - sleep until a condition gets true or a timeout elapses
512 * @wq_head: the waitqueue to wait on
513 * @condition: a C expression for the event to wait for
521 * change the result of the wait condition.
527 * to %true before the @timeout elapsed, or -%ERESTARTSYS if it was
540 #define __wait_event_hrtimeout(wq_head, condition, timeout, state) \ argument
549 current->timer_slack_ns); \
553 __ret = ___wait_event(wq_head, condition, state, 0, 0, \
555 __ret = -ETIME; \
566 * wait_event_hrtimeout - sleep until a condition gets true or a timeout elapses
567 * @wq_head: the waitqueue to wait on
568 * @condition: a C expression for the event to wait for
576 * change the result of the wait condition.
578 * The function returns 0 if @condition became true, or -ETIME if the timeout
592 * wait_event_interruptible_hrtimeout - sleep until a condition gets true or a timeout elapses
593 * @wq: the waitqueue to wait on
594 * @condition: a C expression for the event to wait for
602 * change the result of the wait condition.
604 * The function returns 0 if @condition became true, -ERESTARTSYS if it was
605 * interrupted by a signal, or -ETIME if the timeout elapsed.
658 * wait_event_idle - wait for a condition without contributing to system load
659 * @wq_head: the waitqueue to wait on
660 * @condition: a C expression for the event to wait for
667 * change the result of the wait condition.
678 * wait_event_idle_exclusive - wait for a condition with contributing to system load
679 * @wq_head: the waitqueue to wait on
680 * @condition: a C expression for the event to wait for
686 * The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag
687 * set thus if other processes wait on the same list, when this
691 * change the result of the wait condition.
707 * wait_event_idle_timeout - sleep without load until a condition becomes true or a timeout elapses
708 * @wq_head: the waitqueue to wait on
709 * @condition: a C expression for the event to wait for
717 * change the result of the wait condition.
740 …* wait_event_idle_exclusive_timeout - sleep without load until a condition becomes true or a timeo…
741 * @wq_head: the waitqueue to wait on
742 * @condition: a C expression for the event to wait for
749 * The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag
750 * set thus if other processes wait on the same list, when this
754 * change the result of the wait condition.
792 * wait_event_interruptible_locked - 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_locked_irq - sleep until a condition gets true
820 * @wq: the waitqueue to wait on
821 * @condition: a C expression for the event to wait for
836 * change the result of the wait condition.
838 * The function will return -ERESTARTSYS if it was interrupted by a
846 * wait_event_interruptible_exclusive_locked - sleep exclusively until a condition gets true
847 * @wq: the waitqueue to wait on
848 * @condition: a C expression for the event to wait for
862 * The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag
867 * change the result of the wait condition.
869 * The function will return -ERESTARTSYS if it was interrupted by a
877 * wait_event_interruptible_exclusive_locked_irq - sleep until a condition gets true
878 * @wq: the waitqueue to wait on
879 * @condition: a C expression for the event to wait for
893 * The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag
898 * change the result of the wait condition.
900 * The function will return -ERESTARTSYS if it was interrupted by a
912 * wait_event_killable - sleep until a condition gets true
913 * @wq_head: the waitqueue to wait on
914 * @condition: a C expression for the event to wait for
921 * change the result of the wait condition.
923 * The function will return -ERESTARTSYS if it was interrupted by a
935 #define __wait_event_state(wq, condition, state) \ argument
936 ___wait_event(wq, condition, state, 0, 0, schedule())
939 * wait_event_state - sleep until a condition gets true
940 * @wq_head: the waitqueue to wait on
941 * @condition: a C expression for the event to wait for
942 * @state: state to sleep in
944 * The process is put to sleep (@state) until the @condition evaluates to true
945 * or a signal is received (when allowed by @state). The @condition is checked
949 * change the result of the wait condition.
951 * The function will return -ERESTARTSYS if it was interrupted by a signal
952 * (when allowed by @state) and 0 if @condition evaluated to true.
954 #define wait_event_state(wq_head, condition, state) \ argument
959 __ret = __wait_event_state(wq_head, condition, state); \
969 * wait_event_killable_timeout - sleep until a condition gets true or a timeout elapses
970 * @wq_head: the waitqueue to wait on
971 * @condition: a C expression for the event to wait for
979 * change the result of the wait condition.
985 * to %true before the @timeout elapsed, or -%ERESTARTSYS if it was
1009 * wait_event_lock_irq_cmd - sleep until a condition gets true. The
1013 * @wq_head: the waitqueue to wait on
1014 * @condition: a C expression for the event to wait for
1025 * change the result of the wait condition.
1039 * wait_event_lock_irq - sleep until a condition gets true. The
1043 * @wq_head: the waitqueue to wait on
1044 * @condition: a C expression for the event to wait for
1053 * change the result of the wait condition.
1074 * wait_event_interruptible_lock_irq_cmd - sleep until a condition gets true.
1077 * @wq_head: the waitqueue to wait on
1078 * @condition: a C expression for the event to wait for
1089 * change the result of the wait condition.
1095 * The macro will return -ERESTARTSYS if it was interrupted by a signal
1108 * wait_event_interruptible_lock_irq - sleep until a condition gets true.
1111 * @wq_head: the waitqueue to wait on
1112 * @condition: a C expression for the event to wait for
1121 * change the result of the wait condition.
1126 * The macro will return -ERESTARTSYS if it was interrupted by a signal
1138 #define __wait_event_lock_irq_timeout(wq_head, condition, lock, timeout, state) \ argument
1140 state, 0, timeout, \
1146 * wait_event_interruptible_lock_irq_timeout - sleep until a condition gets
1149 * @wq_head: the waitqueue to wait on
1150 * @condition: a C expression for the event to wait for
1160 * change the result of the wait condition.
1165 * The function returns 0 if the @timeout elapsed, -ERESTARTSYS if it
1193 void prepare_to_wait(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry, int state);
1194 …e_to_wait_exclusive(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry, int state);
1195 …epare_to_wait_event(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry, int state);
1210 #define init_wait(wait) \ argument
1212 (wait)->private = current; \
1213 (wait)->func = autoremove_wake_function; \
1214 INIT_LIST_HEAD(&(wait)->entry); \
1215 (wait)->flags = 0; \