 |
AM261x MCU+ SDK
10.02.00
|
|
Go to the documentation of this file.
67 #define CB_TSN_THREAD_NAME_SIZE 128
72 typedef struct cb_tsn_thread_attr{
83 #ifdef CB_THREAD_NON_POSIX_H
87 #include CB_THREAD_NON_POSIX_H
91 #include <semaphore.h>
94 #define CB_THREAD_T pthread_t
95 #define CB_THREAD_CREATE(th, attr, func, arg) pthread_create(th, NULL, func, arg)
96 #define CB_THREAD_JOIN pthread_join
97 #define CB_THREAD_EXIT pthread_exit
98 #define CB_THREAD_MUTEX_T pthread_mutex_t
99 #define CB_THREAD_MUTEX_LOCK pthread_mutex_lock
100 #define CB_THREAD_MUTEX_TRYLOCK pthread_mutex_trylock
101 #define CB_THREAD_MUTEX_TIMEDLOCK pthread_mutex_timedlock
102 #define CB_THREAD_MUTEX_UNLOCK pthread_mutex_unlock
103 #define CB_THREAD_MUTEX_INIT pthread_mutex_init
104 #define CB_THREAD_MUTEX_DESTROY pthread_mutex_destroy
105 #define CB_THREAD_MUTEXATTR_T pthread_mutexattr_t
106 #define CB_THREAD_MUTEXATTR_INIT pthread_mutexattr_init
107 #define CB_THREAD_MUTEXATTR_SETPSHARED pthread_mutexattr_setpshared
108 #define CB_THREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
109 #define CB_THREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
110 #define CB_THREAD_COND_T pthread_cond_t
111 #define CB_THREAD_COND_INIT pthread_cond_init
112 #define CB_THREAD_COND_DESTROY pthread_cond_destroy
113 #define CB_THREAD_COND_WAIT pthread_cond_wait
114 #define CB_THREAD_COND_SIGNAL pthread_cond_signal
115 #define CB_THREAD_COND_BROADCAST pthread_cond_broadcast
116 #if !defined(CB_STATIC_MUTEX_INITIALIZER) && defined(PTHREAD_MUTEX_INITIALIZER)
117 #define CB_STATIC_MUTEX_INITIALIZER(x) x=PTHREAD_MUTEX_INITIALIZER
118 #define CB_STATIC_MUTEX_CONSTRUCTOR(x)
119 #define CB_STATIC_MUTEX_DESTRUCTOR(x)
121 #define CB_SEM_T sem_t
122 #define CB_SEM_INIT sem_init
123 #define CB_SEM_GETVALUE sem_getvalue
124 #define CB_SEM_WAIT sem_wait
125 #define CB_SEM_TRYWAIT sem_trywait
126 #define CB_SEM_TIMEDWAIT sem_timedwait
127 #define CB_SEM_POST sem_post
128 #define CB_SEM_DESTROY sem_destroy
129 #define CB_SEM_OPEN sem_open
130 #define CB_SEM_CLOSE sem_close
131 #define CB_SEM_UNLINK sem_unlink
132 #define CB_SEM_FAILED SEM_FAILED
134 #define CB_GETPID getpid
138 int stack_size,
const char* name)
140 if(!attr) {
return -1;}
142 if(pri>0){attr->
pri=pri;}
143 if(stack_size>0){attr->
stack_size=stack_size;}
164 typedef struct cb_waitpoint {
205 if(((uint64_t)(time-wp->
time)<((uint64_t)1<<63))){
236 #define cb_waitpoint_wakeup(wp) CB_THREAD_COND_SIGNAL(&(wp)->condition)
244 #define cb_waitpoint_broadcast(wp) CB_THREAD_COND_BROADCAST(&(wp)->condition)
250 #define cb_waitpoint_lock(wp) CB_THREAD_MUTEX_LOCK(&(wp)->lock)
256 #define cb_waitpoint_unlock(wp) CB_THREAD_MUTEX_UNLOCK(&(wp)->lock)
static void cb_waitpoint_wakeup_at(cb_waitpoint_t *wp, uint64_t time, bool dosleep)
Wait point blocks until wake point has been awoken and after specified time.
Definition: cb_thread.h:222
#define CB_THREAD_MUTEX_DESTROY
Definition: cb_thread.h:104
#define CB_THREAD_COND_DESTROY
Definition: cb_thread.h:112
uint64_t time
Definition: cb_thread.h:169
#define CB_TSN_THREAD_NAME_SIZE
data structure for thread attributes
Definition: cb_thread.h:67
Wait points that blocks the execution of a thread at a specific code point until an event occurs.
Definition: cb_thread.h:164
CB_THREAD_COND_T condition
Definition: cb_thread.h:167
#define CB_THREAD_COND_T
Definition: cb_thread.h:110
CB_THREAD_MUTEX_T lock
Definition: cb_thread.h:165
#define CB_THREAD_COND_WAIT
Definition: cb_thread.h:113
unibase general global header
#define CB_THREAD_MUTEX_INIT
Definition: cb_thread.h:103
int stack_size
Definition: cb_thread.h:75
bool wakeup
Definition: cb_thread.h:171
int ub_strncpy(char *dest, const char *src, int maxlen)
copy a string
static bool cb_waitpoint_check(cb_waitpoint_t *wp, uint64_t time)
Wait point check.
Definition: cb_thread.h:201
char name[CB_TSN_THREAD_NAME_SIZE]
Definition: cb_thread.h:77
static void cb_waitpoint_init(cb_waitpoint_t *wp)
Wait point initialization.
Definition: cb_thread.h:179
#define CB_THREAD_COND_INIT
Definition: cb_thread.h:111
void cb_waitproc(int64_t objnum, bool thread_mode)
void * stack_addr
Definition: cb_thread.h:79
static void cb_waitpoint_deinit(cb_waitpoint_t *wp)
Wait point de-initialization.
Definition: cb_thread.h:190
static int cb_tsn_thread_attr_init(cb_tsn_thread_attr_t *attr, int pri, int stack_size, const char *name)
Definition: cb_thread.h:137
#define CB_THREAD_MUTEX_T
Definition: cb_thread.h:98
parameters to initialize thread
Definition: cb_thread.h:72
int cb_killproc(int64_t objnum, bool thread_mode)
kill forcefully running process or thread
int pri
Definition: cb_thread.h:73
static int cb_tsn_thread_attr_set_stackaddr(cb_tsn_thread_attr_t *attr, void *stack_addr)
Definition: cb_thread.h:150