|
AM243x MCU+ SDK
09.02.01
|
|
Go to the documentation of this file.
57 #ifndef CB_LLD_THREAD_H
58 #define CB_LLD_THREAD_H
63 #include "lld_thread.h"
72 #define TILLD_SUCCESS (0)
73 #define TILLD_FAILURE (-1)
74 #define TILLD_TIMEDOUT (-2)
76 #define CB_THREAD_T cb_lld_task_t*
77 #define CB_THREAD_CREATE cb_lld_task_create
78 #define CB_THREAD_JOIN cb_lld_task_join
79 #define CB_THREAD_EXIT cb_lld_task_exit
80 #define CB_THREAD_MUTEX_T cb_lld_mutex_t
81 #define CB_THREAD_MUTEX_LOCK cb_lld_mutex_lock
82 #define CB_THREAD_MUTEX_TRYLOCK cb_lld_mutex_trylock
83 #define CB_THREAD_MUTEX_TIMEDLOCK cb_lld_mutex_timedlock
84 #define CB_THREAD_MUTEX_UNLOCK cb_lld_mutex_unlock
85 #define CB_THREAD_MUTEX_INIT cb_lld_mutex_init
86 #define CB_THREAD_MUTEX_DESTROY cb_lld_mutex_destroy
87 #define CB_THREAD_IS_MUTEX_INITIALIZED(x) ((x).lldmutex!=NULL)
88 #define CB_STATIC_MUTEX_INITIALIZER(x) x=TILLD_MUTEX_INITIALIZER
89 #define CB_STATIC_MUTEX_CONSTRUCTOR(x) \
90 UB_PROTECTED_FUNC_VOID(cb_lld_mutex_init_protect,&(x))
91 #define CB_STATIC_MUTEX_DESTRUCTOR(x) \
92 UB_PROTECTED_FUNC_VOID(cb_lld_mutex_destroy_protect, &(x))
95 #define CB_THREAD_MUTEXATTR_T void*
96 #define CB_THREAD_MUTEXATTR_INIT(a)
97 #define CB_THREAD_MUTEXATTR_SETPSHARED(a,b)
98 #define CB_THREAD_PROCESS_SHARED 0 //PTHREAD_PROCESS_SHARED
100 #define CB_SEM_T cb_lld_sem_t*
101 #define CB_SEM_INIT cb_lld_sem_init
102 #define CB_SEM_GETVALUE cb_lld_sem_getvalue
103 #define CB_SEM_WAIT cb_lld_sem_wait
104 #define CB_SEM_TRYWAIT cb_lld_sem_trywait
105 #define CB_SEM_TIMEDWAIT cb_lld_sem_timedwait
106 #define CB_SEM_POST cb_lld_sem_post
107 #define CB_SEM_DESTROY cb_lld_sem_destroy
110 #define CB_THREAD_COND_T void*
111 #define CB_THREAD_COND_INIT(a, b)
112 #define CB_THREAD_COND_DESTROY(a)
113 #define CB_THREAD_COND_WAIT(a, b)
114 #define CB_THREAD_COND_SIGNAL(a)
115 #define CB_THREAD_COND_BROADCAST(a)
240 if(cbmutex->lldmutex == NULL) {
return;}
242 cbmutex->lldmutex = NULL;
309 #endif //CB_LLD_THREAD_H
int cb_lld_sem_init(CB_SEM_T *sem, int pshared, unsigned int value)
Initializes a semaphore.
static int cb_lld_mutex_init_protect(void *mutex)
Initializes a mutex that will be protected by the UB_PROTECTED_FUNC_VOID().
Definition: cb_lld_thread.h:214
int cb_lld_mutex_trylock(CB_THREAD_MUTEX_T *mutex)
Attempts to lock a mutex without blocking.
static void cb_lld_mutex_destroy_protect(void *mutex)
Destroy a mutex that will be protected by the UB_PROTECTED_FUNC_VOID().
Definition: cb_lld_thread.h:237
int cb_lld_sem_post(CB_SEM_T *sem)
Posts (signals) a semaphore, releasing a waiting thread.
#define CB_THREAD_T
Definition: cb_lld_thread.h:76
int cb_lld_mutex_destroy(CB_THREAD_MUTEX_T *mutex)
Destroys a mutex.
struct cb_lld_sem cb_lld_sem_t
Definition: cb_lld_thread.h:69
#define CB_THREAD_MUTEXATTR_T
Definition: cb_lld_thread.h:95
void cb_lld_task_exit(void *retval)
Terminates the calling thread.
#define CB_SEM_T
Definition: cb_lld_thread.h:100
int cb_lld_mutex_unlock(CB_THREAD_MUTEX_T *mutex)
Unlocks a mutex.
int cb_lld_mutex_timedlock(CB_THREAD_MUTEX_T *mutex, struct timespec *abstime)
Locks a mutex and waits until a timeout occurs.
uint32_t value
Definition: tisci_otp_revision.h:2
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...
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 exe...
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.
int cb_lld_sem_trywait(CB_SEM_T *sem)
Attempts to wait on a semaphore without blocking. To know if the semaphore was acquired,...
#define CB_THREAD_MUTEX_T
Definition: cb_lld_thread.h:80
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 w...
int cb_lld_mutex_lock(CB_THREAD_MUTEX_T *mutex)
Locks a mutex.
int cb_lld_sem_getvalue(CB_SEM_T *sem, int *sval)
return the count of a semaphore
int cb_lld_mutex_init(CB_THREAD_MUTEX_T *mutex, CB_THREAD_MUTEXATTR_T attr)
Initializes a mutex.
int cb_lld_sem_destroy(CB_SEM_T *sem)
Destroys a semaphore.
struct cb_lld_task cb_lld_task_t
Definition: cb_lld_thread.h:70
int cb_lld_sem_wait(CB_SEM_T *sem)
Waits on a semaphore until it becomes available.