Threading and Sync Primitives
[Event Discrimination Service]


Files

file  xdasd_thread.c
 OpenXDAS daemon threading primatives implementation.
file  xdasd_thread.h
 OpenXDAS threading and synchronization primitives.

Data Structures

struct  sem_t

Defines

#define mutex_t   pthread_mutex_t
#define mutex_create(x)   (void)pthread_mutex_init((x),0)
#define mutex_destroy   (void)pthread_mutex_destroy
#define mutex_acquire   (void)pthread_mutex_lock
#define mutex_release   (void)pthread_mutex_unlock
#define cv_t   pthread_cond_t
#define cv_create(x)   pthread_cond_init((x),0)
#define cv_destroy   pthread_cond_destroy
#define cv_signal   pthread_cond_signal
#define cv_wait   pthread_cond_wait

Typedefs

typedef void * thread_t

Functions

thread_t thread_create (void *(*thread_proc)(void *), void *arg)
 Create a new thread of execution.
void * thread_wait (thread_t th)
 Wait for a thread to terminate.
static void p_operation_cleanup (void *arg)
 A pthread cleanup callback routine.
int sem_create (sem_t *sp, int count)
 Create an inter-thread semaphore object.
void sem_destroy (sem_t *sp)
 Destroy an inter-thread semaphore object.
void sem_wait (sem_t *sp)
 Wait for an inter-thread semaphore signal.
void sem_signal (sem_t *sp, int count)
 Signal an inter-thread semaphore.

Define Documentation

#define cv_create (  )     pthread_cond_init((x),0)

Definition at line 79 of file xdasd_thread.h.

Referenced by xdasd_mqueue_create().

#define cv_destroy   pthread_cond_destroy

Definition at line 80 of file xdasd_thread.h.

Referenced by xdasd_mqueue_create(), and xdasd_mqueue_destroy().

#define cv_signal   pthread_cond_signal

Definition at line 81 of file xdasd_thread.h.

Referenced by xdasd_mqueue_append(), and xdasd_mqueue_destroy().

#define cv_t   pthread_cond_t

Definition at line 78 of file xdasd_thread.h.

#define cv_wait   pthread_cond_wait

Definition at line 82 of file xdasd_thread.h.

Referenced by bg_proc().

#define mutex_acquire   (void)pthread_mutex_lock

Definition at line 74 of file xdasd_thread.h.

Referenced by bg_proc(), xdasd_mqueue_append(), and xdasd_mqueue_destroy().

#define mutex_create (  )     (void)pthread_mutex_init((x),0)

Definition at line 72 of file xdasd_thread.h.

Referenced by xdasd_mqueue_create().

#define mutex_destroy   (void)pthread_mutex_destroy

Definition at line 73 of file xdasd_thread.h.

Referenced by xdasd_mqueue_create(), and xdasd_mqueue_destroy().

#define mutex_release   (void)pthread_mutex_unlock

Definition at line 75 of file xdasd_thread.h.

Referenced by bg_proc(), xdasd_mqueue_append(), and xdasd_mqueue_destroy().

#define mutex_t   pthread_mutex_t

Definition at line 71 of file xdasd_thread.h.


Typedef Documentation

typedef void* thread_t

Definition at line 86 of file xdasd_thread.h.


Function Documentation

static void p_operation_cleanup ( void *  arg  )  [static]

A pthread cleanup callback routine.

Parameters:
[in] arg - A typeless alias for the semaphore whose mutex should be released.

For internal use only.

Definition at line 362 of file xdasd_thread.c.

Referenced by sem_wait().

int sem_create ( sem_t sp,
int  count 
)

Create an inter-thread semaphore object.

Parameters:
[in] sp - The semaphore to be created.
[in] count - The initial count for the new semaphore.
Returns:
Zero on success or a non-zero status code on failure.

For internal use only.

Definition at line 374 of file xdasd_thread.c.

References sem_t::cond, sem_t::count, and sem_t::lock.

void sem_destroy ( sem_t sp  ) 

Destroy an inter-thread semaphore object.

Parameters:
[in] sp - The semaphore to be destroyed.

For internal use only.

Definition at line 393 of file xdasd_thread.c.

References sem_t::cond, sem_t::lock, and void().

void sem_signal ( sem_t sp,
int  count 
)

Signal an inter-thread semaphore.

Parameters:
[in] sp - The semaphore to be signaled.
[in] count - The number of signals to apply to sp.

For internal use only.

Definition at line 424 of file xdasd_thread.c.

References sem_t::cond, sem_t::count, and sem_t::lock.

void sem_wait ( sem_t sp  ) 

Wait for an inter-thread semaphore signal.

Parameters:
[in] sp - The semaphore on which to wait.

For internal use only.

Definition at line 405 of file xdasd_thread.c.

References sem_t::cond, sem_t::count, sem_t::lock, and p_operation_cleanup().

thread_t thread_create ( void *(*)(void *)  thread_proc,
void *  arg 
)

Create a new thread of execution.

Parameters:
[in] thread_proc - The function to run on a new thread.
[in] arg - Context data to pass to thread_proc.
Returns:
A thread handle that may be used later by another thread to synchronize with the new thread's termination point. In pthread parlance, this attribute is called "joinable".
Remarks:
The function address passed for thread_proc must match the following signature: void * thread_proc(void *), where the return value and the parameter must both be integer values the size of a pointer on the target platform.

For internal use only.

Definition at line 65 of file xdasd_thread.c.

Referenced by xdasd_mqueue_create().

void * thread_wait ( thread_t  th  ) 

Wait for a thread to terminate.

Causes the caller to wait in an efficient wait-state until the thread associated with the handle th terminates.

Parameters:
[in] th - The thread handle to wait on.
Returns:
The thread's exit code.

For internal use only.

Definition at line 87 of file xdasd_thread.c.

Referenced by xdasd_mqueue_destroy().


Generated on Thu Aug 20 22:33:07 2009 for OpenXDAS by  doxygen 1.5.6