Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

Event Management

Thread synchronization support. More...

Functions

int NutEventWait (HANDLE *qhp, u_long ms)
 Wait for an event in a specified queue. More...

void NutEventPostAsync (HANDLE *qhp)
 Asynchronously post an event to a specified queue. More...

void NutEventPost (HANDLE *qhp)
 Post an event to a specified queue. More...

void NutEventBroadcastAsync (HANDLE *qhp)
 Asynchronously broadcast an event to a specified queue. More...

void NutEventBroadcast (HANDLE *qhp)
 Broadcast an event to a specified queue. More...


Detailed Description

Thread synchronization support.

Threads may wait for events from other threads or interrupts or may post or broadcast events to other threads.

Waiting threads line up in priority ordered queues, so more than one thread may wait for the same event.

Events are posted to a waiting queue, moving the thread from waiting (sleeping) state to ready-to-run state. A running thread may also broadcast an event to a specified queue, waking up all threads on that queue.

Usually a woken up thread takes over the CPU, if it's priority is equal or higher than the currently running thread. However, events can be posted asynchronously, in which case the posting thread continues to run. Interrupt routines must always post events asynchronously.

A waiting queue is a simple linked list of waiting threads.

Version:
2.0.4
Author:
Harald Kipp, egnite Software GmbH

Function Documentation

void NutEventBroadcast ( HANDLE * qhp )
 

Broadcast an event to a specified queue.

Wake up all threads waiting on this queue. If the priority of any waiting thread is higher or equal than the current thread's priority, then the current thread is stopped and CPU control is passed to the woken up thread with the highest priority.

Note:
Interrupts are automatically enabled when this function returns.
Parameters:
qhp   Identifies the queue an event is broadcasted to.

void NutEventBroadcastAsync ( HANDLE * qhp )
 

Asynchronously broadcast an event to a specified queue.

Wake up all threads waiting on this queue. But even if the priority of any woken thread is higher than the current thread's priority, the current one continues running.

Note:
It is save to call this function from within an interrupt handler. In any case interrupts should be disabled when calling this function.
Parameters:
qhp   Identifies the queue an event is broadcasted to.

void NutEventPost ( HANDLE * qhp )
 

Post an event to a specified queue.

Wake up the thread with the highest priority waiting on this queue. If the priority of the waiting thread is higher or equal than the current thread's priority, then the current thread is stopped and CPU control is passed to the waiting thread.

Note:
Interrupts are automatically enabled when this function returns.
Parameters:
qhp   Identifies the queue an event is posted to.

void NutEventPostAsync ( HANDLE * qhp )
 

Asynchronously post an event to a specified queue.

Wake up the thread with the highest priority waiting on the specified queue. But even if the priority of the woken thread is higher than the current thread's priority, the current one continues running.

Note:
It is save to call this function from within an interrupt handler. In any case interrupts should be disabled when calling this function.
Parameters:
qhp   Identifies the queue an event is posted to.

int NutEventWait ( HANDLE * qhp,
u_long ms )
 

Wait for an event in a specified queue.

Give up the CPU until another thread posts an event to this queue or until a time-out occurs, whichever comes first.

Note:
Interrupts are automatically enabled when this function returns.

Returns:
0 if event received, -1 on timeout.


© 2000-2001 by egnite Software GmbH - visit http://www.ethernut.de/