Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
completion.h File Reference
#include <linux/wait.h>

Go to the source code of this file.

Data Structures

struct  completion
 

Macros

#define COMPLETION_INITIALIZER(work)   { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
 
#define COMPLETION_INITIALIZER_ONSTACK(work)   ({ init_completion(&work); work; })
 
#define DECLARE_COMPLETION(work)   struct completion work = COMPLETION_INITIALIZER(work)
 
#define DECLARE_COMPLETION_ONSTACK(work)   DECLARE_COMPLETION(work)
 
#define INIT_COMPLETION(x)   ((x).done = 0)
 

Functions

void wait_for_completion (struct completion *)
 
int wait_for_completion_interruptible (struct completion *x)
 
int wait_for_completion_killable (struct completion *x)
 
unsigned long wait_for_completion_timeout (struct completion *x, unsigned long timeout)
 
long wait_for_completion_interruptible_timeout (struct completion *x, unsigned long timeout)
 
long wait_for_completion_killable_timeout (struct completion *x, unsigned long timeout)
 
bool try_wait_for_completion (struct completion *x)
 
bool completion_done (struct completion *x)
 
void complete (struct completion *)
 
void complete_all (struct completion *)
 

Macro Definition Documentation

#define COMPLETION_INITIALIZER (   work)    { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }

Definition at line 30 of file completion.h.

#define COMPLETION_INITIALIZER_ONSTACK (   work)    ({ init_completion(&work); work; })

Definition at line 33 of file completion.h.

#define DECLARE_COMPLETION (   work)    struct completion work = COMPLETION_INITIALIZER(work)

DECLARE_COMPLETION - declare and initialize a completion structure : identifier for the completion structure

This macro declares and initializes a completion structure. Generally used for static declarations. You should use the _ONSTACK variant for automatic variables.

Definition at line 44 of file completion.h.

#define DECLARE_COMPLETION_ONSTACK (   work)    DECLARE_COMPLETION(work)

DECLARE_COMPLETION_ONSTACK - declare and initialize a completion structure : identifier for the completion structure

This macro declares and initializes a completion structure on the kernel stack.

Definition at line 63 of file completion.h.

#define INIT_COMPLETION (   x)    ((x).done = 0)

INIT_COMPLETION - reinitialize a completion structure : completion structure to be reinitialized

This macro should be used to reinitialize a completion structure so it can be reused. This is especially important after complete_all() is used.

Definition at line 101 of file completion.h.

Function Documentation

void complete ( struct completion x)

complete: - signals a single thread waiting on this completion : holds the state of this particular completion

This will wake up a single thread waiting on this completion. Threads will be awakened in the same order in which they were queued.

See also complete_all(), wait_for_completion() and related routines.

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 3170 of file core.c.

void complete_all ( struct completion x)

complete_all: - signals all threads waiting on this completion : holds the state of this particular completion

This will wake up all threads waiting on this particular completion event.

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 3190 of file core.c.

bool completion_done ( struct completion x)

completion_done - Test to see if a completion has any waiters : completion structure

Returns: 0 if there are waiters (wait_for_completion() in progress) 1 if there are no waiters.

Definition at line 3382 of file core.c.

bool try_wait_for_completion ( struct completion x)

try_wait_for_completion - try to decrement a completion without blocking : completion structure

Returns: 0 if a decrement cannot be done without blocking 1 if a decrement succeeded.

If a completion is being used as a counting completion, attempt to decrement the counter without blocking. This enables us to avoid waiting if the resource the completion is protecting is not available.

Definition at line 3359 of file core.c.

void wait_for_completion ( struct completion x)

wait_for_completion: - waits for completion of a task : holds the state of this particular completion

This waits to be signaled for completion of a specific task. It is NOT interruptible and there is no timeout.

See also similar routines (i.e. wait_for_completion_timeout()) with timeout and interrupt capability. Also see complete().

Definition at line 3247 of file core.c.

int wait_for_completion_interruptible ( struct completion x)

wait_for_completion_interruptible: - waits for completion of a task (w/intr) : holds the state of this particular completion

This waits for completion of a specific task to be signaled. It is interruptible.

The return value is -ERESTARTSYS if interrupted, 0 if completed.

Definition at line 3281 of file core.c.

long wait_for_completion_interruptible_timeout ( struct completion x,
unsigned long  timeout 
)

wait_for_completion_interruptible_timeout: - waits for completion (w/(to,intr)) : holds the state of this particular completion : timeout value in jiffies

This waits for either a completion of a specific task to be signaled or for a specified timeout to expire. It is interruptible. The timeout is in jiffies.

The return value is -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1, or number of jiffies left till timeout) if completed.

Definition at line 3302 of file core.c.

int wait_for_completion_killable ( struct completion x)

wait_for_completion_killable: - waits for completion of a task (killable) : holds the state of this particular completion

This waits to be signaled for completion of a specific task. It can be interrupted by a kill signal.

The return value is -ERESTARTSYS if interrupted, 0 if completed.

Definition at line 3318 of file core.c.

long wait_for_completion_killable_timeout ( struct completion x,
unsigned long  timeout 
)

wait_for_completion_killable_timeout: - waits for completion of a task (w/(to,killable)) : holds the state of this particular completion : timeout value in jiffies

This waits for either a completion of a specific task to be signaled or for a specified timeout to expire. It can be interrupted by a kill signal. The timeout is in jiffies.

The return value is -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1, or number of jiffies left till timeout) if completed.

Definition at line 3340 of file core.c.

unsigned long wait_for_completion_timeout ( struct completion x,
unsigned long  timeout 
)

wait_for_completion_timeout: - waits for completion of a task (w/timeout) : holds the state of this particular completion : timeout value in jiffies

This waits for either a completion of a specific task to be signaled or for a specified timeout to expire. The timeout is in jiffies. It is not interruptible.

The return value is 0 if timed out, and positive (at least 1, or number of jiffies left till timeout) if completed.

Definition at line 3266 of file core.c.