Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions
wait.h File Reference
#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
 

Macros

#define WQ_FLAG_EXCLUSIVE   0x01
 
#define __WAITQUEUE_INITIALIZER(name, tsk)
 
#define DECLARE_WAITQUEUE(name, tsk)   wait_queue_t name = __WAITQUEUE_INITIALIZER(name, tsk)
 
#define __WAIT_QUEUE_HEAD_INITIALIZER(name)
 
#define DECLARE_WAIT_QUEUE_HEAD(name)   wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
 
#define __WAIT_BIT_KEY_INITIALIZER(word, bit)   { .flags = word, .bit_nr = bit, }
 
#define init_waitqueue_head(q)
 
#define DECLARE_WAIT_QUEUE_HEAD_ONSTACK(name)   DECLARE_WAIT_QUEUE_HEAD(name)
 
#define wake_up(x)   __wake_up(x, TASK_NORMAL, 1, NULL)
 
#define wake_up_nr(x, nr)   __wake_up(x, TASK_NORMAL, nr, NULL)
 
#define wake_up_all(x)   __wake_up(x, TASK_NORMAL, 0, NULL)
 
#define wake_up_locked(x)   __wake_up_locked((x), TASK_NORMAL, 1)
 
#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_nr(x, nr)   __wake_up(x, TASK_INTERRUPTIBLE, nr, 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_poll(x, m)   __wake_up(x, TASK_NORMAL, 1, (void *) (m))
 
#define wake_up_locked_poll(x, m)   __wake_up_locked_key((x), TASK_NORMAL, (void *) (m))
 
#define wake_up_interruptible_poll(x, m)   __wake_up(x, TASK_INTERRUPTIBLE, 1, (void *) (m))
 
#define wake_up_interruptible_sync_poll(x, m)   __wake_up_sync_key((x), TASK_INTERRUPTIBLE, 1, (void *) (m))
 
#define __wait_event(wq, condition)
 
#define wait_event(wq, condition)
 
#define __wait_event_timeout(wq, condition, ret)
 
#define wait_event_timeout(wq, condition, timeout)
 
#define __wait_event_interruptible(wq, condition, ret)
 
#define wait_event_interruptible(wq, condition)
 
#define __wait_event_interruptible_timeout(wq, condition, ret)
 
#define wait_event_interruptible_timeout(wq, condition, timeout)
 
#define __wait_event_interruptible_exclusive(wq, condition, ret)
 
#define wait_event_interruptible_exclusive(wq, condition)
 
#define __wait_event_interruptible_locked(wq, condition, exclusive, irq)
 
#define wait_event_interruptible_locked(wq, condition)
 
#define wait_event_interruptible_locked_irq(wq, condition)
 
#define wait_event_interruptible_exclusive_locked(wq, condition)
 
#define wait_event_interruptible_exclusive_locked_irq(wq, condition)
 
#define __wait_event_killable(wq, condition, ret)
 
#define wait_event_killable(wq, condition)
 
#define DEFINE_WAIT_FUNC(name, function)
 
#define DEFINE_WAIT(name)   DEFINE_WAIT_FUNC(name, autoremove_wake_function)
 
#define DEFINE_WAIT_BIT(name, word, bit)
 
#define init_wait(wait)
 

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
 

Functions

int default_wake_function (wait_queue_t *wait, unsigned mode, int flags, void *key)
 
void __init_waitqueue_head (wait_queue_head_t *q, const char *name, struct lock_class_key *)
 
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)
 
void remove_wait_queue (wait_queue_head_t *q, wait_queue_t *wait)
 
void __wake_up (wait_queue_head_t *q, unsigned int mode, int nr, void *key)
 
void __wake_up_locked_key (wait_queue_head_t *q, unsigned int mode, void *key)
 
void __wake_up_sync_key (wait_queue_head_t *q, unsigned int mode, int nr, void *key)
 
void __wake_up_locked (wait_queue_head_t *q, unsigned int mode, int nr)
 
void __wake_up_sync (wait_queue_head_t *q, unsigned int mode, int nr)
 
void __wake_up_bit (wait_queue_head_t *, void *, int)
 
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_bit (void *, int)
 
int out_of_line_wait_on_bit (void *, int, int(*)(void *), unsigned)
 
int out_of_line_wait_on_bit_lock (void *, int, int(*)(void *), unsigned)
 
wait_queue_head_tbit_waitqueue (void *, int)
 
void sleep_on (wait_queue_head_t *q)
 
long sleep_on_timeout (wait_queue_head_t *q, signed long timeout)
 
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 finish_wait (wait_queue_head_t *q, wait_queue_t *wait)
 
void abort_exclusive_wait (wait_queue_head_t *q, wait_queue_t *wait, unsigned int mode, void *key)
 
int autoremove_wake_function (wait_queue_t *wait, unsigned mode, int sync, void *key)
 
int wake_bit_function (wait_queue_t *wait, unsigned mode, int sync, void *key)
 

Macro Definition Documentation

#define __WAIT_BIT_KEY_INITIALIZER (   word,
  bit 
)    { .flags = word, .bit_nr = bit, }

Definition at line 60 of file wait.h.

#define __wait_event (   wq,
  condition 
)
Value:
do { \
DEFINE_WAIT(__wait); \
for (;;) { \
prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE); \
if (condition) \
break; \
schedule(); \
} \
finish_wait(&wq, &__wait); \
} while (0)

Definition at line 176 of file wait.h.

#define __wait_event_interruptible (   wq,
  condition,
  ret 
)
Value:
do { \
DEFINE_WAIT(__wait); \
for (;;) { \
prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \
if (condition) \
break; \
if (!signal_pending(current)) { \
schedule(); \
continue; \
} \
ret = -ERESTARTSYS; \
break; \
} \
finish_wait(&wq, &__wait); \
} while (0)

Definition at line 247 of file wait.h.

#define __wait_event_interruptible_exclusive (   wq,
  condition,
  ret 
)
Value:
do { \
DEFINE_WAIT(__wait); \
for (;;) { \
prepare_to_wait_exclusive(&wq, &__wait, \
if (condition) { \
finish_wait(&wq, &__wait); \
break; \
} \
if (!signal_pending(current)) { \
schedule(); \
continue; \
} \
ret = -ERESTARTSYS; \
abort_exclusive_wait(&wq, &__wait, \
break; \
} \
} while (0)

Definition at line 333 of file wait.h.

#define __wait_event_interruptible_locked (   wq,
  condition,
  exclusive,
  irq 
)
Value:
({ \
int __ret = 0; \
DEFINE_WAIT(__wait); \
if (exclusive) \
__wait.flags |= WQ_FLAG_EXCLUSIVE; \
do { \
if (likely(list_empty(&__wait.task_list))) \
__add_wait_queue_tail(&(wq), &__wait); \
set_current_state(TASK_INTERRUPTIBLE); \
if (signal_pending(current)) { \
__ret = -ERESTARTSYS; \
break; \
} \
if (irq) \
spin_unlock_irq(&(wq).lock); \
else \
spin_unlock(&(wq).lock); \
schedule(); \
if (irq) \
spin_lock_irq(&(wq).lock); \
else \
spin_lock(&(wq).lock); \
} while (!(condition)); \
__remove_wait_queue(&(wq), &__wait); \
__set_current_state(TASK_RUNNING); \
__ret; \
})

Definition at line 364 of file wait.h.

#define __wait_event_interruptible_timeout (   wq,
  condition,
  ret 
)
Value:
do { \
DEFINE_WAIT(__wait); \
for (;;) { \
prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \
if (condition) \
break; \
if (!signal_pending(current)) { \
if (!ret) \
break; \
continue; \
} \
ret = -ERESTARTSYS; \
break; \
} \
finish_wait(&wq, &__wait); \
} while (0)

Definition at line 288 of file wait.h.

#define __wait_event_killable (   wq,
  condition,
  ret 
)
Value:
do { \
DEFINE_WAIT(__wait); \
for (;;) { \
prepare_to_wait(&wq, &__wait, TASK_KILLABLE); \
if (condition) \
break; \
if (!fatal_signal_pending(current)) { \
schedule(); \
continue; \
} \
ret = -ERESTARTSYS; \
break; \
} \
finish_wait(&wq, &__wait); \
} while (0)

Definition at line 512 of file wait.h.

#define __wait_event_timeout (   wq,
  condition,
  ret 
)
Value:
do { \
DEFINE_WAIT(__wait); \
for (;;) { \
prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE); \
if (condition) \
break; \
if (!ret) \
break; \
} \
finish_wait(&wq, &__wait); \
} while (0)

Definition at line 208 of file wait.h.

#define __WAIT_QUEUE_HEAD_INITIALIZER (   name)
Value:
{ \
.lock = __SPIN_LOCK_UNLOCKED(name.lock), \
.task_list = { &(name).task_list, &(name).task_list } }

Definition at line 53 of file wait.h.

#define __WAITQUEUE_INITIALIZER (   name,
  tsk 
)
Value:
{ \
.private = tsk, \
.task_list = { NULL, NULL } }

Definition at line 45 of file wait.h.

#define DECLARE_WAIT_QUEUE_HEAD (   name)    wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name)

Definition at line 57 of file wait.h.

#define DECLARE_WAIT_QUEUE_HEAD_ONSTACK (   name)    DECLARE_WAIT_QUEUE_HEAD(name)

Definition at line 78 of file wait.h.

#define DECLARE_WAITQUEUE (   name,
  tsk 
)    wait_queue_t name = __WAITQUEUE_INITIALIZER(name, tsk)

Definition at line 50 of file wait.h.

#define DEFINE_WAIT (   name)    DEFINE_WAIT_FUNC(name, autoremove_wake_function)

Definition at line 583 of file wait.h.

#define DEFINE_WAIT_BIT (   name,
  word,
  bit 
)
Value:
struct wait_bit_queue name = { \
.wait = { \
.private = current, \
.func = wake_bit_function, \
.task_list = \
LIST_HEAD_INIT((name).wait.task_list), \
}, \
}

Definition at line 585 of file wait.h.

#define DEFINE_WAIT_FUNC (   name,
  function 
)
Value:
.private = current, \
.func = function, \
.task_list = LIST_HEAD_INIT((name).task_list), \
}

Definition at line 576 of file wait.h.

#define init_wait (   wait)
Value:
do { \
(wait)->private = current; \
INIT_LIST_HEAD(&(wait)->task_list); \
(wait)->flags = 0; \
} while (0)

Definition at line 596 of file wait.h.

#define init_waitqueue_head (   q)
Value:
do { \
static struct lock_class_key __key; \
__init_waitqueue_head((q), #q, &__key); \
} while (0)

Definition at line 65 of file wait.h.

#define wait_event (   wq,
  condition 
)
Value:
do { \
if (condition) \
break; \
__wait_event(wq, condition); \
} while (0)

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.

Definition at line 201 of file wait.h.

#define wait_event_interruptible (   wq,
  condition 
)
Value:
({ \
int __ret = 0; \
if (!(condition)) \
__wait_event_interruptible(wq, condition, __ret); \
__ret; \
})

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.

Definition at line 280 of file wait.h.

#define wait_event_interruptible_exclusive (   wq,
  condition 
)
Value:
({ \
int __ret = 0; \
if (!(condition)) \
__wait_event_interruptible_exclusive(wq, condition, __ret);\
__ret; \
})

Definition at line 355 of file wait.h.

#define wait_event_interruptible_exclusive_locked (   wq,
  condition 
)
Value:
((condition) \
? 0 : __wait_event_interruptible_locked(wq, condition, 1, 0))

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.

Definition at line 475 of file wait.h.

#define wait_event_interruptible_exclusive_locked_irq (   wq,
  condition 
)
Value:
((condition) \
? 0 : __wait_event_interruptible_locked(wq, condition, 1, 1))

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.

Definition at line 506 of file wait.h.

#define wait_event_interruptible_locked (   wq,
  condition 
)
Value:
((condition) \
? 0 : __wait_event_interruptible_locked(wq, condition, 0, 0))

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.

Definition at line 417 of file wait.h.

#define wait_event_interruptible_locked_irq (   wq,
  condition 
)
Value:
((condition) \
? 0 : __wait_event_interruptible_locked(wq, condition, 0, 1))

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.

Definition at line 444 of file wait.h.

#define wait_event_interruptible_timeout (   wq,
  condition,
  timeout 
)
Value:
({ \
long __ret = timeout; \
if (!(condition)) \
__wait_event_interruptible_timeout(wq, condition, __ret); \
__ret; \
})

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.

Definition at line 325 of file wait.h.

#define wait_event_killable (   wq,
  condition 
)
Value:
({ \
int __ret = 0; \
if (!(condition)) \
__wait_event_killable(wq, condition, __ret); \
__ret; \
})

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.

Definition at line 545 of file wait.h.

#define wait_event_timeout (   wq,
  condition,
  timeout 
)
Value:
({ \
long __ret = timeout; \
if (!(condition)) \
__wait_event_timeout(wq, condition, __ret); \
__ret; \
})

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.

Definition at line 239 of file wait.h.

#define wake_up (   x)    __wake_up(x, TASK_NORMAL, 1, NULL)

Definition at line 153 of file wait.h.

#define wake_up_all (   x)    __wake_up(x, TASK_NORMAL, 0, NULL)

Definition at line 155 of file wait.h.

#define wake_up_all_locked (   x)    __wake_up_locked((x), TASK_NORMAL, 0)

Definition at line 157 of file wait.h.

#define wake_up_interruptible (   x)    __wake_up(x, TASK_INTERRUPTIBLE, 1, NULL)

Definition at line 159 of file wait.h.

#define wake_up_interruptible_all (   x)    __wake_up(x, TASK_INTERRUPTIBLE, 0, NULL)

Definition at line 161 of file wait.h.

#define wake_up_interruptible_nr (   x,
  nr 
)    __wake_up(x, TASK_INTERRUPTIBLE, nr, NULL)

Definition at line 160 of file wait.h.

#define wake_up_interruptible_poll (   x,
  m 
)    __wake_up(x, TASK_INTERRUPTIBLE, 1, (void *) (m))

Definition at line 171 of file wait.h.

#define wake_up_interruptible_sync (   x)    __wake_up_sync((x), TASK_INTERRUPTIBLE, 1)

Definition at line 162 of file wait.h.

#define wake_up_interruptible_sync_poll (   x,
  m 
)    __wake_up_sync_key((x), TASK_INTERRUPTIBLE, 1, (void *) (m))

Definition at line 173 of file wait.h.

#define wake_up_locked (   x)    __wake_up_locked((x), TASK_NORMAL, 1)

Definition at line 156 of file wait.h.

#define wake_up_locked_poll (   x,
  m 
)    __wake_up_locked_key((x), TASK_NORMAL, (void *) (m))

Definition at line 169 of file wait.h.

#define wake_up_nr (   x,
  nr 
)    __wake_up(x, TASK_NORMAL, nr, NULL)

Definition at line 154 of file wait.h.

#define wake_up_poll (   x,
  m 
)    __wake_up(x, TASK_NORMAL, 1, (void *) (m))

Definition at line 167 of file wait.h.

#define WQ_FLAG_EXCLUSIVE   0x01

Definition at line 17 of file wait.h.

Typedef Documentation

typedef int(* wait_queue_func_t)(wait_queue_t *wait, unsigned mode, int flags, void *key)

Definition at line 12 of file wait.h.

Definition at line 37 of file wait.h.

Definition at line 11 of file wait.h.

Function Documentation

void __init_waitqueue_head ( wait_queue_head_t q,
const char name,
struct lock_class_key  
)

Definition at line 13 of file wait.c.

int __wait_on_bit ( wait_queue_head_t ,
struct wait_bit_queue ,
int(*)(void *)  ,
unsigned   
)

Definition at line 194 of file wait.c.

int __wait_on_bit_lock ( wait_queue_head_t ,
struct wait_bit_queue ,
int(*)(void *)  ,
unsigned   
)

Definition at line 220 of file wait.c.

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.

Definition at line 3088 of file core.c.

void __wake_up_bit ( wait_queue_head_t ,
void ,
int   
)

Definition at line 250 of file wait.c.

void __wake_up_locked ( wait_queue_head_t q,
unsigned int  mode,
int  nr 
)

Definition at line 3102 of file core.c.

void __wake_up_locked_key ( wait_queue_head_t q,
unsigned int  mode,
void key 
)

Definition at line 3108 of file core.c.

void __wake_up_sync ( wait_queue_head_t q,
unsigned int  mode,
int  nr 
)

Definition at line 3152 of file core.c.

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.

Definition at line 3131 of file core.c.

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.

Definition at line 148 of file wait.c.

void add_wait_queue ( wait_queue_head_t q,
wait_queue_t wait 
)

Definition at line 22 of file wait.c.

void add_wait_queue_exclusive ( wait_queue_head_t q,
wait_queue_t wait 
)

Definition at line 33 of file wait.c.

int autoremove_wake_function ( wait_queue_t wait,
unsigned  mode,
int  sync,
void key 
)

Definition at line 163 of file wait.c.

wait_queue_head_t* bit_waitqueue ( void ,
int   
)

Definition at line 281 of file wait.c.

int default_wake_function ( wait_queue_t wait,
unsigned  mode,
int  flags,
void key 
)

Definition at line 3048 of file core.c.

void finish_wait ( wait_queue_head_t q,
wait_queue_t wait 
)

finish_wait - clean up after waiting in a queue : waitqueue waited on : wait descriptor

Sets current thread back to running state and removes the wait descriptor from the given waitqueue if still queued.

Definition at line 104 of file wait.c.

void interruptible_sleep_on ( wait_queue_head_t q)

Definition at line 3416 of file core.c.

long interruptible_sleep_on_timeout ( wait_queue_head_t q,
signed long  timeout 
)
int out_of_line_wait_on_bit ( void ,
int  ,
int(*)(void *)  ,
unsigned   
)

Definition at line 209 of file wait.c.

int out_of_line_wait_on_bit_lock ( void ,
int  ,
int(*)(void *)  ,
unsigned   
)

Definition at line 240 of file wait.c.

void prepare_to_wait ( wait_queue_head_t q,
wait_queue_t wait,
int  state 
)

Definition at line 68 of file wait.c.

void prepare_to_wait_exclusive ( wait_queue_head_t q,
wait_queue_t wait,
int  state 
)

Definition at line 82 of file wait.c.

void remove_wait_queue ( wait_queue_head_t q,
wait_queue_t wait 
)

Definition at line 44 of file wait.c.

void sleep_on ( wait_queue_head_t q)

Definition at line 3429 of file core.c.

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 
)

Definition at line 173 of file wait.c.

void wake_up_bit ( void word,
int  bit 
)

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.

Definition at line 275 of file wait.c.