Linux Kernel
3.7.1
|
#include <linux/list.h>
#include <linux/stddef.h>
#include <linux/spinlock.h>
#include <asm/current.h>
#include <uapi/linux/wait.h>
Go to the source code of this file.
Data Structures | |
struct | __wait_queue |
struct | wait_bit_key |
struct | wait_bit_queue |
struct | __wait_queue_head |
Typedefs | |
typedef struct __wait_queue | wait_queue_t |
typedef int(* | wait_queue_func_t )(wait_queue_t *wait, unsigned mode, int flags, void *key) |
typedef struct __wait_queue_head | wait_queue_head_t |
#define __wait_event | ( | wq, | |
condition | |||
) |
#define __wait_event_interruptible | ( | wq, | |
condition, | |||
ret | |||
) |
#define __wait_event_interruptible_exclusive | ( | wq, | |
condition, | |||
ret | |||
) |
#define __wait_event_interruptible_locked | ( | wq, | |
condition, | |||
exclusive, | |||
irq | |||
) |
#define __wait_event_interruptible_timeout | ( | wq, | |
condition, | |||
ret | |||
) |
#define __wait_event_killable | ( | wq, | |
condition, | |||
ret | |||
) |
#define __wait_event_timeout | ( | wq, | |
condition, | |||
ret | |||
) |
#define __WAIT_QUEUE_HEAD_INITIALIZER | ( | name | ) |
#define __WAITQUEUE_INITIALIZER | ( | name, | |
tsk | |||
) |
#define DECLARE_WAIT_QUEUE_HEAD | ( | name | ) | wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name) |
#define DECLARE_WAIT_QUEUE_HEAD_ONSTACK | ( | name | ) | DECLARE_WAIT_QUEUE_HEAD(name) |
#define DECLARE_WAITQUEUE | ( | name, | |
tsk | |||
) | wait_queue_t name = __WAITQUEUE_INITIALIZER(name, tsk) |
#define DEFINE_WAIT | ( | name | ) | DEFINE_WAIT_FUNC(name, autoremove_wake_function) |
#define init_wait | ( | wait | ) |
#define init_waitqueue_head | ( | q | ) |
#define wait_event | ( | wq, | |
condition | |||
) |
wait_event - sleep until a condition gets true : the waitqueue to wait on : a C expression for the event to wait for
The process is put to sleep (TASK_UNINTERRUPTIBLE) until the evaluates to true. The is checked each time the waitqueue is woken up.
wake_up() has to be called after changing any variable that could change the result of the wait condition.
#define wait_event_interruptible | ( | wq, | |
condition | |||
) |
wait_event_interruptible - sleep until a condition gets true : the waitqueue to wait on : a C expression for the event to wait for
The process is put to sleep (TASK_INTERRUPTIBLE) until the evaluates to true or a signal is received. The is checked each time the waitqueue is woken up.
wake_up() has to be called after changing any variable that could change the result of the wait condition.
The function will return -ERESTARTSYS if it was interrupted by a signal and 0 if evaluated to true.
#define wait_event_interruptible_exclusive | ( | wq, | |
condition | |||
) |
#define wait_event_interruptible_exclusive_locked | ( | wq, | |
condition | |||
) |
wait_event_interruptible_exclusive_locked - sleep exclusively until a condition gets true : the waitqueue to wait on : a C expression for the event to wait for
The process is put to sleep (TASK_INTERRUPTIBLE) until the evaluates to true or a signal is received. The is checked each time the waitqueue is woken up.
It must be called with wq.lock being held. This spinlock is unlocked while sleeping but testing is done while lock is held and when this macro exits the lock is held.
The lock is locked/unlocked using spin_lock()/spin_unlock() functions which must match the way they are locked/unlocked outside of this macro.
The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag set thus when other process waits process on the list if this process is awaken further processes are not considered.
wake_up_locked() has to be called after changing any variable that could change the result of the wait condition.
The function will return -ERESTARTSYS if it was interrupted by a signal and 0 if evaluated to true.
#define wait_event_interruptible_exclusive_locked_irq | ( | wq, | |
condition | |||
) |
wait_event_interruptible_exclusive_locked_irq - sleep until a condition gets true : the waitqueue to wait on : a C expression for the event to wait for
The process is put to sleep (TASK_INTERRUPTIBLE) until the evaluates to true or a signal is received. The is checked each time the waitqueue is woken up.
It must be called with wq.lock being held. This spinlock is unlocked while sleeping but testing is done while lock is held and when this macro exits the lock is held.
The lock is locked/unlocked using spin_lock_irq()/spin_unlock_irq() functions which must match the way they are locked/unlocked outside of this macro.
The process is put on the wait queue with an WQ_FLAG_EXCLUSIVE flag set thus when other process waits process on the list if this process is awaken further processes are not considered.
wake_up_locked() has to be called after changing any variable that could change the result of the wait condition.
The function will return -ERESTARTSYS if it was interrupted by a signal and 0 if evaluated to true.
#define wait_event_interruptible_locked | ( | wq, | |
condition | |||
) |
wait_event_interruptible_locked - sleep until a condition gets true : the waitqueue to wait on : a C expression for the event to wait for
The process is put to sleep (TASK_INTERRUPTIBLE) until the evaluates to true or a signal is received. The is checked each time the waitqueue is woken up.
It must be called with wq.lock being held. This spinlock is unlocked while sleeping but testing is done while lock is held and when this macro exits the lock is held.
The lock is locked/unlocked using spin_lock()/spin_unlock() functions which must match the way they are locked/unlocked outside of this macro.
wake_up_locked() has to be called after changing any variable that could change the result of the wait condition.
The function will return -ERESTARTSYS if it was interrupted by a signal and 0 if evaluated to true.
#define wait_event_interruptible_locked_irq | ( | wq, | |
condition | |||
) |
wait_event_interruptible_locked_irq - sleep until a condition gets true : the waitqueue to wait on : a C expression for the event to wait for
The process is put to sleep (TASK_INTERRUPTIBLE) until the evaluates to true or a signal is received. The is checked each time the waitqueue is woken up.
It must be called with wq.lock being held. This spinlock is unlocked while sleeping but testing is done while lock is held and when this macro exits the lock is held.
The lock is locked/unlocked using spin_lock_irq()/spin_unlock_irq() functions which must match the way they are locked/unlocked outside of this macro.
wake_up_locked() has to be called after changing any variable that could change the result of the wait condition.
The function will return -ERESTARTSYS if it was interrupted by a signal and 0 if evaluated to true.
#define wait_event_interruptible_timeout | ( | wq, | |
condition, | |||
timeout | |||
) |
wait_event_interruptible_timeout - sleep until a condition gets true or a timeout elapses : the waitqueue to wait on : a C expression for the event to wait for : timeout, in jiffies
The process is put to sleep (TASK_INTERRUPTIBLE) until the evaluates to true or a signal is received. The is checked each time the waitqueue is woken up.
wake_up() has to be called after changing any variable that could change the result of the wait condition.
The function returns 0 if the elapsed, -ERESTARTSYS if it was interrupted by a signal, and the remaining jiffies otherwise if the condition evaluated to true before the timeout elapsed.
#define wait_event_killable | ( | wq, | |
condition | |||
) |
wait_event_killable - sleep until a condition gets true : the waitqueue to wait on : a C expression for the event to wait for
The process is put to sleep (TASK_KILLABLE) until the evaluates to true or a signal is received. The is checked each time the waitqueue is woken up.
wake_up() has to be called after changing any variable that could change the result of the wait condition.
The function will return -ERESTARTSYS if it was interrupted by a signal and 0 if evaluated to true.
#define wait_event_timeout | ( | wq, | |
condition, | |||
timeout | |||
) |
wait_event_timeout - sleep until a condition gets true or a timeout elapses : the waitqueue to wait on : a C expression for the event to wait for : timeout, in jiffies
The process is put to sleep (TASK_UNINTERRUPTIBLE) until the evaluates to true. The is checked each time the waitqueue is woken up.
wake_up() has to be called after changing any variable that could change the result of the wait condition.
The function returns 0 if the elapsed, and the remaining jiffies if the condition evaluated to true before the timeout elapsed.
#define wake_up_all_locked | ( | x | ) | __wake_up_locked((x), TASK_NORMAL, 0) |
#define wake_up_interruptible | ( | x | ) | __wake_up(x, TASK_INTERRUPTIBLE, 1, NULL) |
#define wake_up_interruptible_all | ( | x | ) | __wake_up(x, TASK_INTERRUPTIBLE, 0, NULL) |
#define wake_up_interruptible_sync | ( | x | ) | __wake_up_sync((x), TASK_INTERRUPTIBLE, 1) |
#define wake_up_interruptible_sync_poll | ( | x, | |
m | |||
) | __wake_up_sync_key((x), TASK_INTERRUPTIBLE, 1, (void *) (m)) |
#define wake_up_locked | ( | x | ) | __wake_up_locked((x), TASK_NORMAL, 1) |
#define wake_up_locked_poll | ( | x, | |
m | |||
) | __wake_up_locked_key((x), TASK_NORMAL, (void *) (m)) |
typedef struct __wait_queue_head wait_queue_head_t |
typedef struct __wait_queue wait_queue_t |
void __init_waitqueue_head | ( | wait_queue_head_t * | q, |
const char * | name, | ||
struct lock_class_key * | |||
) |
int __wait_on_bit | ( | wait_queue_head_t * | , |
struct wait_bit_queue * | , | ||
int(*)(void *) | , | ||
unsigned | |||
) |
int __wait_on_bit_lock | ( | wait_queue_head_t * | , |
struct wait_bit_queue * | , | ||
int(*)(void *) | , | ||
unsigned | |||
) |
void __wake_up | ( | wait_queue_head_t * | q, |
unsigned int | mode, | ||
int | nr_exclusive, | ||
void * | key | ||
) |
__wake_up - wake up threads blocked on a waitqueue. : the waitqueue : which threads : how many wake-one or wake-many threads to wake up : is directly passed to the wakeup function
It may be assumed that this function implies a write memory barrier before changing the task state if and only if any tasks are woken up.
void __wake_up_locked | ( | wait_queue_head_t * | q, |
unsigned int | mode, | ||
int | nr | ||
) |
void __wake_up_locked_key | ( | wait_queue_head_t * | q, |
unsigned int | mode, | ||
void * | key | ||
) |
void __wake_up_sync | ( | wait_queue_head_t * | q, |
unsigned int | mode, | ||
int | nr | ||
) |
void __wake_up_sync_key | ( | wait_queue_head_t * | q, |
unsigned int | mode, | ||
int | nr_exclusive, | ||
void * | key | ||
) |
__wake_up_sync_key - wake up threads blocked on a waitqueue. : the waitqueue : which threads : how many wake-one or wake-many threads to wake up : opaque value to be passed to wakeup targets
The sync wakeup differs that the waker knows that it will schedule away soon, so while the target thread will be woken up, it will not be migrated to another CPU - ie. the two threads are 'synchronized' with each other. This can prevent needless bouncing between CPUs.
On UP it can prevent extra preemption.
It may be assumed that this function implies a write memory barrier before changing the task state if and only if any tasks are woken up.
void abort_exclusive_wait | ( | wait_queue_head_t * | q, |
wait_queue_t * | wait, | ||
unsigned int | mode, | ||
void * | key | ||
) |
abort_exclusive_wait - abort exclusive waiting in a queue : waitqueue waited on : wait descriptor : runstate of the waiter to be woken : key to identify a wait bit queue or NULL
Sets current thread back to running state and removes the wait descriptor from the given waitqueue if still queued.
Wakes up the next waiter if the caller is concurrently woken up through the queue.
This prevents waiter starvation where an exclusive waiter aborts and is woken up concurrently and no one wakes up the next waiter.
void add_wait_queue | ( | wait_queue_head_t * | q, |
wait_queue_t * | wait | ||
) |
void add_wait_queue_exclusive | ( | wait_queue_head_t * | q, |
wait_queue_t * | wait | ||
) |
int autoremove_wake_function | ( | wait_queue_t * | wait, |
unsigned | mode, | ||
int | sync, | ||
void * | key | ||
) |
wait_queue_head_t* bit_waitqueue | ( | void * | , |
int | |||
) |
int default_wake_function | ( | wait_queue_t * | wait, |
unsigned | mode, | ||
int | flags, | ||
void * | key | ||
) |
void finish_wait | ( | wait_queue_head_t * | q, |
wait_queue_t * | wait | ||
) |
void interruptible_sleep_on | ( | wait_queue_head_t * | q | ) |
long interruptible_sleep_on_timeout | ( | wait_queue_head_t * | q, |
signed long | timeout | ||
) |
void prepare_to_wait | ( | wait_queue_head_t * | q, |
wait_queue_t * | wait, | ||
int | state | ||
) |
void prepare_to_wait_exclusive | ( | wait_queue_head_t * | q, |
wait_queue_t * | wait, | ||
int | state | ||
) |
void remove_wait_queue | ( | wait_queue_head_t * | q, |
wait_queue_t * | wait | ||
) |
void sleep_on | ( | wait_queue_head_t * | q | ) |
long sleep_on_timeout | ( | wait_queue_head_t * | q, |
signed long | timeout | ||
) |
int wake_bit_function | ( | wait_queue_t * | wait, |
unsigned | mode, | ||
int | sync, | ||
void * | key | ||
) |
wake_up_bit - wake up a waiter on a bit : the word being waited on, a kernel virtual address : the bit of the word being waited on
There is a standard hashed waitqueue table for generic use. This is the part of the hashtable's accessor API that wakes up waiters on a bit. For instance, if one were to have waiters on a bitflag, one would call wake_up_bit() after clearing the bit.
In order for this to function properly, as it uses waitqueue_active() internally, some kind of memory barrier must be done prior to calling this. Typically, this will be smp_mb__after_clear_bit(), but in some cases where bitflags are manipulated non-atomically under a lock, one may need to use a less regular barrier, such fs/inode.c's smp_mb(), because spin_unlock() does not guarantee a memory barrier.