 |
AM261x MCU+ SDK
10.02.00
|
|
Go to the documentation of this file.
58 #ifndef CB_LLD_THREAD_H
59 #define CB_LLD_THREAD_H
64 #include "lld_thread.h"
73 #define TILLD_SUCCESS (0)
74 #define TILLD_FAILURE (-1)
75 #define TILLD_TIMEDOUT (-2)
77 #define CB_THREAD_T cb_lld_task_t*
78 #define CB_THREAD_CREATE cb_lld_task_create
79 #define CB_THREAD_JOIN cb_lld_task_join
80 #define CB_THREAD_EXIT cb_lld_task_exit
81 #define CB_THREAD_MUTEX_T cb_lld_mutex_t
82 #define CB_THREAD_MUTEX_LOCK cb_lld_mutex_lock
83 #define CB_THREAD_MUTEX_TRYLOCK cb_lld_mutex_trylock
84 #define CB_THREAD_MUTEX_TIMEDLOCK cb_lld_mutex_timedlock
85 #define CB_THREAD_MUTEX_UNLOCK cb_lld_mutex_unlock
86 #define CB_THREAD_MUTEX_INIT cb_lld_mutex_init
87 #define CB_THREAD_MUTEX_DESTROY cb_lld_mutex_destroy
88 #define CB_THREAD_IS_MUTEX_INITIALIZED(x) ((x).lldmutex!=NULL)
89 #define CB_STATIC_MUTEX_INITIALIZER(x) x=TILLD_MUTEX_INITIALIZER
90 #define CB_STATIC_MUTEX_CONSTRUCTOR(x) \
91 UB_PROTECTED_FUNC_VOID(cb_lld_mutex_init_protect,&(x))
92 #define CB_STATIC_MUTEX_DESTRUCTOR(x) \
93 UB_PROTECTED_FUNC_VOID(cb_lld_mutex_destroy_protect, &(x))
94 #define CB_GETPID() ( 0 )
95 #define CB_GETTID() ( 0 )
98 #define CB_THREAD_MUTEXATTR_T void*
99 #define CB_THREAD_MUTEXATTR_INIT(a)
100 #define CB_THREAD_MUTEXATTR_SETPSHARED(a,b)
101 #define CB_THREAD_PROCESS_SHARED 0 //PTHREAD_PROCESS_SHARED
103 #define CB_SEM_T cb_lld_sem_t*
104 #define CB_SEM_INIT cb_lld_sem_init
105 #define CB_SEM_GETVALUE cb_lld_sem_getvalue
106 #define CB_SEM_WAIT cb_lld_sem_wait
107 #define CB_SEM_TRYWAIT cb_lld_sem_trywait
108 #define CB_SEM_TIMEDWAIT cb_lld_sem_timedwait
109 #define CB_SEM_POST cb_lld_sem_post
110 #define CB_SEM_DESTROY cb_lld_sem_destroy
113 #define CB_THREAD_COND_T void*
114 #define CB_THREAD_COND_INIT(a, b)
115 #define CB_THREAD_COND_DESTROY(a)
116 #define CB_THREAD_COND_WAIT(a, b)
117 #define CB_THREAD_COND_SIGNAL(a)
118 #define CB_THREAD_COND_BROADCAST(a)
243 if(cbmutex->lldmutex == NULL) {
return;}
245 cbmutex->lldmutex = NULL;
323 #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:217
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:240
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:77
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:70
#define CB_THREAD_MUTEXATTR_T
Definition: cb_lld_thread.h:98
void cb_lld_task_exit(void *retval)
Terminates the calling thread.
void cb_waitproc(int64_t objnum, bool thread_mode)
Wait process to be finished.
#define CB_SEM_T
Definition: cb_lld_thread.h:103
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.
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_killproc(int64_t objnum, bool thread_mode)
Kill thread by ID.
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:81
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:71
int cb_lld_sem_wait(CB_SEM_T *sem)
Waits on a semaphore until it becomes available.