Files | |
file | cb_lld_thread.h |
bindings to TI ENET LLD specific thread, mutex and semaphore functions | |
Functions | |
int | cb_lld_sem_init (CB_SEM_T *sem, int pshared, unsigned int value) |
Initializes a semaphore. More... | |
int | cb_lld_sem_wait (CB_SEM_T *sem) |
Waits on a semaphore until it becomes available. More... | |
int | cb_lld_sem_trywait (CB_SEM_T *sem) |
Attempts to wait on a semaphore without blocking. To know if the semaphore was acquired, get the return value from the cb_lld_sem_wait_status(). If the return value is 1, then the semaphore was acquired. Otherwise, the semaphore was not acquired. More... | |
int | cb_lld_sem_timedwait (CB_SEM_T *sem, struct timespec *abstime) |
Waits on a semaphore until it becomes available or until a timeout occurs. To know if the semaphore was acquired, refer to the cb_lld_sem_wait_status(). More... | |
int | cb_lld_sem_post (CB_SEM_T *sem) |
Posts (signals) a semaphore, releasing a waiting thread. More... | |
int | cb_lld_sem_getvalue (CB_SEM_T *sem, int *sval) |
return the count of a semaphore More... | |
int | cb_lld_sem_destroy (CB_SEM_T *sem) |
Destroys a semaphore. More... | |
int | cb_lld_sem_wait_status (CB_SEM_T *sem) |
Get the semaphore wait status. The return value of this function determines the wait status of cb_lld_sem_wait(), cb_lld_sem_trywait() and cb_lld_sem_timedwait() More... | |
int | cb_lld_mutex_init (CB_THREAD_MUTEX_T *mutex, CB_THREAD_MUTEXATTR_T attr) |
Initializes a mutex. More... | |
static int | cb_lld_mutex_init_protect (void *mutex) |
Initializes a mutex that will be protected by the UB_PROTECTED_FUNC_VOID(). More... | |
int | cb_lld_mutex_destroy (CB_THREAD_MUTEX_T *mutex) |
Destroys a mutex. More... | |
static void | cb_lld_mutex_destroy_protect (void *mutex) |
Destroy a mutex that will be protected by the UB_PROTECTED_FUNC_VOID(). More... | |
int | cb_lld_mutex_lock (CB_THREAD_MUTEX_T *mutex) |
Locks a mutex. More... | |
int | cb_lld_mutex_unlock (CB_THREAD_MUTEX_T *mutex) |
Unlocks a mutex. More... | |
int | cb_lld_mutex_trylock (CB_THREAD_MUTEX_T *mutex) |
Attempts to lock a mutex without blocking. More... | |
int | cb_lld_mutex_timedlock (CB_THREAD_MUTEX_T *mutex, struct timespec *abstime) |
Locks a mutex and waits until a timeout occurs. More... | |
int | cb_lld_task_create (CB_THREAD_T *th, void *attr, void *(*func)(void *), void *arg) |
Creates a new thread. This function creates a new thread with the specified attributes and starts executing the specified function with the provided argument. More... | |
int | cb_lld_task_join (CB_THREAD_T th, void **retval) |
Waits for a thread to terminate. This function waits for the specified thread to terminate. More... | |
void | cb_lld_task_exit (void *retval) |
Terminates the calling thread. More... | |
Typedefs | |
typedef struct cb_lld_sem | cb_lld_sem_t |
typedef struct cb_lld_task | cb_lld_task_t |
#define TILLD_SUCCESS (0) |
#define TILLD_FAILURE (-1) |
#define TILLD_TIMEDOUT (-2) |
#define CB_THREAD_T cb_lld_task_t* |
#define CB_THREAD_CREATE cb_lld_task_create |
#define CB_THREAD_JOIN cb_lld_task_join |
#define CB_THREAD_EXIT cb_lld_task_exit |
#define CB_THREAD_MUTEX_T cb_lld_mutex_t |
#define CB_THREAD_MUTEX_LOCK cb_lld_mutex_lock |
#define CB_THREAD_MUTEX_TRYLOCK cb_lld_mutex_trylock |
#define CB_THREAD_MUTEX_TIMEDLOCK cb_lld_mutex_timedlock |
#define CB_THREAD_MUTEX_UNLOCK cb_lld_mutex_unlock |
#define CB_THREAD_MUTEX_INIT cb_lld_mutex_init |
#define CB_THREAD_MUTEX_DESTROY cb_lld_mutex_destroy |
#define CB_THREAD_IS_MUTEX_INITIALIZED | ( | x | ) | ((x).lldmutex!=NULL) |
#define CB_STATIC_MUTEX_INITIALIZER | ( | x | ) | x=TILLD_MUTEX_INITIALIZER |
#define CB_STATIC_MUTEX_CONSTRUCTOR | ( | x | ) | UB_PROTECTED_FUNC_VOID(cb_lld_mutex_init_protect,&(x)) |
#define CB_STATIC_MUTEX_DESTRUCTOR | ( | x | ) | UB_PROTECTED_FUNC_VOID(cb_lld_mutex_destroy_protect, &(x)) |
#define CB_THREAD_MUTEXATTR_T void* |
#define CB_THREAD_MUTEXATTR_INIT | ( | a | ) |
#define CB_THREAD_MUTEXATTR_SETPSHARED | ( | a, | |
b | |||
) |
#define CB_THREAD_PROCESS_SHARED 0 |
#define CB_SEM_T cb_lld_sem_t* |
#define CB_SEM_INIT cb_lld_sem_init |
#define CB_SEM_GETVALUE cb_lld_sem_getvalue |
#define CB_SEM_WAIT cb_lld_sem_wait |
#define CB_SEM_TRYWAIT cb_lld_sem_trywait |
#define CB_SEM_TIMEDWAIT cb_lld_sem_timedwait |
#define CB_SEM_POST cb_lld_sem_post |
#define CB_SEM_DESTROY cb_lld_sem_destroy |
#define CB_THREAD_COND_T void* |
#define CB_THREAD_COND_INIT | ( | a, | |
b | |||
) |
#define CB_THREAD_COND_DESTROY | ( | a | ) |
#define CB_THREAD_COND_WAIT | ( | a, | |
b | |||
) |
#define CB_THREAD_COND_SIGNAL | ( | a | ) |
#define CB_THREAD_COND_BROADCAST | ( | a | ) |
typedef struct cb_lld_sem cb_lld_sem_t |
typedef struct cb_lld_task cb_lld_task_t |
int cb_lld_sem_init | ( | CB_SEM_T * | sem, |
int | pshared, | ||
unsigned int | value | ||
) |
Initializes a semaphore.
sem | Pointer to the semaphore. |
pshared | Indicates whether the semaphore is shared among processes. |
value | The initial value of the semaphore. |
int cb_lld_sem_wait | ( | CB_SEM_T * | sem | ) |
Waits on a semaphore until it becomes available.
sem | Pointer to the semaphore. |
int cb_lld_sem_trywait | ( | CB_SEM_T * | sem | ) |
Attempts to wait on a semaphore without blocking. To know if the semaphore was acquired, get the return value from the cb_lld_sem_wait_status(). If the return value is 1, then the semaphore was acquired. Otherwise, the semaphore was not acquired.
sem | Pointer to the semaphore. |
int cb_lld_sem_timedwait | ( | CB_SEM_T * | sem, |
struct timespec * | abstime | ||
) |
Waits on a semaphore until it becomes available or until a timeout occurs. To know if the semaphore was acquired, refer to the cb_lld_sem_wait_status().
sem | Pointer to the semaphore. |
abstime | Pointer to the absolute timeout value. |
int cb_lld_sem_post | ( | CB_SEM_T * | sem | ) |
Posts (signals) a semaphore, releasing a waiting thread.
sem | Pointer to the semaphore. |
int cb_lld_sem_getvalue | ( | CB_SEM_T * | sem, |
int * | sval | ||
) |
return the count of a semaphore
sem | Pointer to the semaphore. |
sval | return value of semaphore counter |
int cb_lld_sem_destroy | ( | CB_SEM_T * | sem | ) |
Destroys a semaphore.
sem | Pointer to the semaphore. |
int cb_lld_sem_wait_status | ( | CB_SEM_T * | sem | ) |
Get the semaphore wait status. The return value of this function determines the wait status of cb_lld_sem_wait(), cb_lld_sem_trywait() and cb_lld_sem_timedwait()
sem | Pointer to the semaphore. |
int cb_lld_mutex_init | ( | CB_THREAD_MUTEX_T * | mutex, |
CB_THREAD_MUTEXATTR_T | attr | ||
) |
Initializes a mutex.
mutex | Pointer to the mutex. |
attr | Pointer to the mutex attributes. |
|
inlinestatic |
Initializes a mutex that will be protected by the UB_PROTECTED_FUNC_VOID().
This function is primarily designed for initializing a mutex used in conjunction with the UB_PROTECTED_FUNC_VOID(). For general use cases, consider utilizing the cb_lld_mutex_init() function instead.
mutex | Pointer to a mutex of type CB_THREAD_MUTEX_T. |
int cb_lld_mutex_destroy | ( | CB_THREAD_MUTEX_T * | mutex | ) |
Destroys a mutex.
mutex | Pointer to the mutex. |
|
inlinestatic |
Destroy a mutex that will be protected by the UB_PROTECTED_FUNC_VOID().
This function is primarily designed for destroying a mutex used in conjunction with the UB_PROTECTED_FUNC_VOID(). For general use cases, consider utilizing the cb_lld_mutex_destroy() function instead.
mutex | Pointer to a mutex of type CB_THREAD_MUTEX_T. |
int cb_lld_mutex_lock | ( | CB_THREAD_MUTEX_T * | mutex | ) |
Locks a mutex.
mutex | Pointer to the mutex. |
int cb_lld_mutex_unlock | ( | CB_THREAD_MUTEX_T * | mutex | ) |
Unlocks a mutex.
mutex | Pointer to the mutex. |
int cb_lld_mutex_trylock | ( | CB_THREAD_MUTEX_T * | mutex | ) |
Attempts to lock a mutex without blocking.
mutex | Pointer to the mutex. |
int cb_lld_mutex_timedlock | ( | CB_THREAD_MUTEX_T * | mutex, |
struct timespec * | abstime | ||
) |
Locks a mutex and waits until a timeout occurs.
mutex | Pointer to the mutex. |
abstime | Pointer to the absolute timeout value. |
int cb_lld_task_create | ( | CB_THREAD_T * | th, |
void * | attr, | ||
void *(*)(void *) | func, | ||
void * | arg | ||
) |
Creates a new thread. This function creates a new thread with the specified attributes and starts executing the specified function with the provided argument.
th | Pointer to a thread object that will be initialized with the created thread. |
attr | Thread attributes. |
func | Pointer to the function that will be executed by the thread. |
arg | Argument to be passed to the thread function. |
int cb_lld_task_join | ( | CB_THREAD_T | th, |
void ** | retval | ||
) |
Waits for a thread to terminate. This function waits for the specified thread to terminate.
th | Thread to be joined. |
retval | Pointer to a pointer that will be set to the exit status of the joined thread (unsupported). |
void cb_lld_task_exit | ( | void * | retval | ) |
Terminates the calling thread.
retval | Exit value of the thread (unsupported). |