Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

Thread implementation
[SB Library]

PThreads. More...

Data Structures

struct  rdwr_var
 Reader/Writer lock struct. More...

Defines

#define thread_rdwrattr_default   NULL;
 default value
#define T_RDWR   thread_rdwr_t
 wrapper for read/write thread struct
#define T_RDWRATTR   thread_rdwrattr_t
 wrapper for read/write attr struct
#define T_MUTEX   int
 dummy wrapper for mutex
#define T_MUTEXATTR   int
 dummy wrapper for mutex attributes
#define T_COND   int
 dummy wrapper for conditional
#define T_CONDATTR   int
 dummy wrapper for conditional attributes
#define T_THREAD   int
 dummy wrapper for thread
#define T_THREADATTR   int
 dummy wrapper for thread attributes
#define T_MUTEX_INIT(mutex, attr)   thread_mutex_init(mutex, attr)
 wrapper for initialize mutex lock
#define T_MUTEX_LOCK(mutex)   thread_mutex_lock(mutex)
 wrapper for setting mutex lock
#define T_MUTEX_TRYLOCK(mutex)   thread_mutex_trylock(mutex)
 wrapper for setting mutex try lock
#define T_MUTEX_UNLOCK(mutex)   thread_mutex_unlock(mutex)
 wrapper for releasing mutex lock
#define T_MUTEX_DESTROY(mutex)   thread_mutex_destroy(mutex)
 wrapper for destroying mutex
#define T_COND_INIT(cond, attr)   thread_cond_init(cond, attr);
 wrapper for initialize conditional
#define T_COND_SIGNAL(cond)   thread_cond_signal(cond)
 wrapper for sending conditional signal
#define T_COND_BROADCAST(cond)   thread_cond_broadcast(cond)
 wrapper for sending conditional broadcast
#define T_COND_WAIT(cond, mutex)   thread_cond_wait(cond, mutex)
 wrapper for waiting for conditional wait on mutex
#define T_COND_TIMEDWAIT(c, m, t)   thread_cond_timedwait(c, m, t)
 wrapper for waiting for conditional wait on mutex with timeout
#define T_COND_DESTROY(cond)   thread_cond_destroy(cond)
 wrapper for destroying conditional
#define T_RDWR_INIT(rdwrp, attrp)   thread_rdwr_init_np(rdwrp, attrp)
 wrapper for initialize read/write lock
#define T_RDWR_RLOCK(rdwrp)   thread_rdwr_rlock_np(rdwrp)
 wrapper for setting read lock
#define T_RDWR_RUNLOCK(rdwrp)   thread_rdwr_runlock_np(rdwrp)
 wrapper for releasing read lock
#define T_RDWR_WLOCK(rdwrp)   thread_rdwr_wlock_np(rdwrp)
 wrapper for setting write lock
#define T_RDWR_WUNLOCK(rdwrp)   thread_rdwr_wunlock_np(rdwrp)
 wrapper for releasing write lock
#define T_CREATE(t, attr, func, arg)   thread_create(t, attr, func, arg)
 wrapper for creating new thread
#define T_JOIN(t, ret)   thread_join(t, ret)
 wrapper for joining a thread
#define T_EXIT(ret)   thread_exit(ret)
 wrapper for exiting a thread
#define T_CANCEL(t)   thread_cancel(t)
 wrapper for cancelling a thread

Typedefs

typedef void * thread_rdwrattr_t
 read/write lock pointer
typedef rdwr_var T_RDWR
 Reader/Writer lock struct.

Functions

int thread_create (T_THREAD *thread, T_THREADATTR *attr, void *(*routine)(void *), void *arg)
 Create a thread.
int thread_join (T_THREAD thread, void **ret)
 Join a thread.
int thread_exit (void *ret)
 Exit a thread.
int thread_cancel (T_THREAD thread)
 Cancel a thread.
int thread_cond_init (T_COND *cond, T_CONDATTR *cond_attr)
 Initializing a conditional variable.
int thread_cond_signal (T_COND *cond)
 Sending a conditional signal.
int thread_cond_broadcast (T_COND *cond)
 Sending a conditional broadcast.
int thread_cond_wait (T_COND *cond, T_MUTEX *mutex)
 Waiting for conditional wait on mutex.
int thread_cond_timedwait (T_COND *cond, T_MUTEX *mutex, unsigned int timeout)
 Waiting for conditional wait on mutex with timeout.
int thread_cond_destroy (T_COND *cond)
 Destroying conditional.
int thread_mutex_init (T_MUTEX *mutex, T_MUTEXATTR *mutexattr)
 Initializing a mutex.
int thread_mutex_lock (T_MUTEX *mutex)
 Lock a mutex.
int thread_mutex_trylock (T_MUTEX *mutex)
 Try to lock a mutex.
int thread_mutex_unlock (T_MUTEX *mutex)
 Unlock a mutex.
int thread_mutex_destroy (T_MUTEX *mutex)
 Lock a mutex.
int thread_rdwr_init_np (T_RDWR *rdwrp, T_RDWRATTR *attrp)
 Initializing a Reader/Writer Lock.
int thread_rdwr_rlock_np (T_RDWR *rdwrp)
 Read Locking a Reader/Writer Lock.
int thread_rdwr_runlock_np (T_RDWR *rdwrp)
 Read Unlocking a Reader/Writer Lock.
int thread_rdwr_wlock_np (T_RDWR *rdwrp)
 Write Locking a Reader/Writer Lock.
int thread_rdwr_wunlock_np (T_RDWR *rdwrp)
 Write Unlocking a Reader/Writer Lock.

Detailed Description

PThreads.

Author:
Stefan Bambach (sbambach@gmx.net)
Version:
0.1

Function Documentation

int thread_cancel T_THREAD  thread  ) 
 

Cancel a thread.

Parameters:
thread Pointer to T_THREAD
Returns:
0 if successful, -1 otherwise.

Definition at line 57 of file threading.c.

int thread_cond_broadcast T_COND *  cond  ) 
 

Sending a conditional broadcast.

Parameters:
cond Pointer to T_COND
Returns:
0 if successful, -1 otherwise.

Definition at line 111 of file threading.c.

int thread_cond_destroy T_COND *  cond  ) 
 

Destroying conditional.

Parameters:
cond Pointer to T_COND
Returns:
0 if successful, -1 otherwise.

Definition at line 177 of file threading.c.

int thread_cond_init T_COND *  cond,
T_CONDATTR *  cond_attr
 

Initializing a conditional variable.

Parameters:
cond Pointer to T_COND
cond_attr Pointer to T_CONDATTR
Returns:
0 if successful, -1 otherwise.

Definition at line 78 of file threading.c.

int thread_cond_signal T_COND *  cond  ) 
 

Sending a conditional signal.

Parameters:
cond Pointer to T_COND
Returns:
0 if successful, -1 otherwise.

Definition at line 95 of file threading.c.

int thread_cond_timedwait T_COND *  cond,
T_MUTEX *  mutex,
unsigned int  timeout
 

Waiting for conditional wait on mutex with timeout.

Parameters:
cond Pointer to T_COND
mutex Pointer to T_MUTEX
timeout Timeout in millisecond
Returns:
0 if successful, -1 if error and 1 if timed out

Definition at line 143 of file threading.c.

int thread_cond_wait T_COND *  cond,
T_MUTEX *  mutex
 

Waiting for conditional wait on mutex.

Parameters:
cond Pointer to T_COND
mutex Pointer to T_MUTEX
Returns:
0 if successful, -1 otherwise.

Definition at line 127 of file threading.c.

int thread_create T_THREAD *  thread,
T_THREADATTR *  attr,
void *(*)(void *)  routine,
void *  arg
 

Create a thread.

Parameters:
thread Pointer to T_THREAD
attr Pointer to T_THREADATTR
routine Pointer to thread function
arg Pointer to argument for function
Returns:
0 if successful, -1 otherwise.

Definition at line 13 of file threading.c.

int thread_exit void *  ret  ) 
 

Exit a thread.

Parameters:
ret Pointer to return value
Returns:
0 if successful, -1 otherwise.

Definition at line 43 of file threading.c.

int thread_join T_THREAD  thread,
void **  ret
 

Join a thread.

Parameters:
thread Pointer to T_THREAD
ret Pointer to return value
Returns:
0 if successful, -1 otherwise.

Definition at line 30 of file threading.c.

int thread_mutex_destroy T_MUTEX *  mutex  ) 
 

Lock a mutex.

Parameters:
mutex Pointer to T_MUTEX
Returns:
0 if successful, -1 otherwise.

Definition at line 266 of file threading.c.

int thread_mutex_init T_MUTEX *  mutex,
T_MUTEXATTR *  mutexattr
 

Initializing a mutex.

Parameters:
mutex Pointer to T_MUTEX
mutexattr Pointer to T_MUTEXATTR
Returns:
0 if successful, -1 otherwise.

Definition at line 201 of file threading.c.

int thread_mutex_lock T_MUTEX *  mutex  ) 
 

Lock a mutex.

Parameters:
mutex Pointer to T_MUTEX
Returns:
0 if successful, -1 otherwise.

Definition at line 218 of file threading.c.

int thread_mutex_trylock T_MUTEX *  mutex  ) 
 

Try to lock a mutex.

Parameters:
mutex Pointer to T_MUTEX
Returns:
0 if successful, -1 otherwise.

Definition at line 234 of file threading.c.

int thread_mutex_unlock T_MUTEX *  mutex  ) 
 

Unlock a mutex.

Parameters:
mutex Pointer to T_MUTEX
Returns:
0 if successful, -1 otherwise.

Definition at line 250 of file threading.c.

int thread_rdwr_init_np T_RDWR rdwrp,
T_RDWRATTR *  attrp
 

Initializing a Reader/Writer Lock.

Parameters:
rdwrp Pointer to T_RDWR struct
attrp Pointer to T_RDWRATTR struct
Returns:
0 if successful, -1 otherwise.

Definition at line 290 of file threading.c.

References rdwr_var::lock_free, rdwr_var::mutex, rdwr_var::readers_reading, T_COND_INIT, T_MUTEX_INIT, T_RDWR, and rdwr_var::writer_writing.

int thread_rdwr_rlock_np T_RDWR rdwrp  ) 
 

Read Locking a Reader/Writer Lock.

Parameters:
rdwrp Pointer to T_RDWR struct
Returns:
0 if successful, -1 otherwise.

Definition at line 307 of file threading.c.

References rdwr_var::lock_free, rdwr_var::mutex, rdwr_var::readers_reading, T_COND_WAIT, T_MUTEX_LOCK, T_MUTEX_UNLOCK, T_RDWR, and rdwr_var::writer_writing.

int thread_rdwr_runlock_np T_RDWR rdwrp  ) 
 

Read Unlocking a Reader/Writer Lock.

Parameters:
rdwrp Pointer to T_RDWR struct
Returns:
0 if successful, -1 otherwise.

Definition at line 326 of file threading.c.

References rdwr_var::lock_free, rdwr_var::mutex, rdwr_var::readers_reading, T_COND_SIGNAL, T_MUTEX_LOCK, T_MUTEX_UNLOCK, and T_RDWR.

int thread_rdwr_wlock_np T_RDWR rdwrp  ) 
 

Write Locking a Reader/Writer Lock.

Parameters:
rdwrp Pointer to T_RDWR struct
Returns:
0 if successful, -1 otherwise.

Definition at line 350 of file threading.c.

References rdwr_var::lock_free, rdwr_var::mutex, rdwr_var::readers_reading, T_COND_WAIT, T_MUTEX_LOCK, T_MUTEX_UNLOCK, T_RDWR, and rdwr_var::writer_writing.

int thread_rdwr_wunlock_np T_RDWR rdwrp  ) 
 

Write Unlocking a Reader/Writer Lock.

Parameters:
rdwrp Pointer to T_RDWR struct
Returns:
0 if successful, -1 otherwise.

Definition at line 369 of file threading.c.

References rdwr_var::lock_free, rdwr_var::mutex, T_COND_BROADCAST, T_MUTEX_LOCK, T_MUTEX_UNLOCK, T_RDWR, and rdwr_var::writer_writing.


Generated on Wed Mar 30 13:43:27 2005 for Mntd by  doxygen 1.3.9.1