65 #define CB_TSN_THREAD_NAME_SIZE 128 70 typedef struct cb_tsn_thread_attr{
81 #ifdef CB_THREAD_NON_POSIX_H 85 #include CB_THREAD_NON_POSIX_H 88 #include <semaphore.h> 91 #define CB_THREAD_T pthread_t 92 #define CB_THREAD_CREATE(th, attr, func, arg) pthread_create(th, NULL, func, arg) 93 #define CB_THREAD_JOIN pthread_join 94 #define CB_THREAD_EXIT pthread_exit 95 #define CB_THREAD_MUTEX_T pthread_mutex_t 96 #define CB_THREAD_MUTEX_LOCK pthread_mutex_lock 97 #define CB_THREAD_MUTEX_TRYLOCK pthread_mutex_trylock 98 #define CB_THREAD_MUTEX_TIMEDLOCK pthread_mutex_timedlock 99 #define CB_THREAD_MUTEX_UNLOCK pthread_mutex_unlock 100 #define CB_THREAD_MUTEX_INIT pthread_mutex_init 101 #define CB_THREAD_MUTEX_DESTROY pthread_mutex_destroy 102 #define CB_THREAD_MUTEXATTR_T pthread_mutexattr_t 103 #define CB_THREAD_MUTEXATTR_INIT pthread_mutexattr_init 104 #define CB_THREAD_MUTEXATTR_SETPSHARED pthread_mutexattr_setpshared 105 #define CB_THREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED 106 #define CB_THREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE 107 #define CB_THREAD_COND_T pthread_cond_t 108 #define CB_THREAD_COND_INIT pthread_cond_init 109 #define CB_THREAD_COND_DESTROY pthread_cond_destroy 110 #define CB_THREAD_COND_WAIT pthread_cond_wait 111 #define CB_THREAD_COND_SIGNAL pthread_cond_signal 112 #define CB_THREAD_COND_BROADCAST pthread_cond_broadcast 113 #if !defined(CB_STATIC_MUTEX_INITIALIZER) && defined(PTHREAD_MUTEX_INITIALIZER) 114 #define CB_STATIC_MUTEX_INITIALIZER(x) x=PTHREAD_MUTEX_INITIALIZER 115 #define CB_STATIC_MUTEX_CONSTRUCTOR(x) 117 #define CB_SEM_T sem_t 118 #define CB_SEM_INIT sem_init 119 #define CB_SEM_GETVALUE sem_getvalue 120 #define CB_SEM_WAIT sem_wait 121 #define CB_SEM_TRYWAIT sem_trywait 122 #define CB_SEM_TIMEDWAIT sem_timedwait 123 #define CB_SEM_POST sem_post 124 #define CB_SEM_DESTROY sem_destroy 125 #define CB_SEM_OPEN sem_open 126 #define CB_SEM_CLOSE sem_close 127 #define CB_SEM_UNLINK sem_unlink 128 #define CB_SEM_FAILED SEM_FAILED 132 int stack_size,
const char* name)
134 if(!attr) {
return -1;}
136 if(pri>0){attr->
pri=pri;}
137 if(stack_size>0){attr->
stack_size=stack_size;}
158 typedef struct cb_waitpoint {
199 if(((uint64_t)(time-wp->
time)<((uint64_t)1<<63))){
231 #define cb_waitpoint_wakeup(wp) CB_THREAD_COND_SIGNAL(&(wp)->condition) 239 #define cb_waitpoint_broadcast(wp) CB_THREAD_COND_BROADCAST(&(wp)->condition) 245 #define cb_waitpoint_lock(wp) CB_THREAD_MUTEX_LOCK(&(wp)->lock) 251 #define cb_waitpoint_unlock(wp) CB_THREAD_MUTEX_UNLOCK(&(wp)->lock) #define CB_TSN_THREAD_NAME_SIZE
data structure for thread attributes
Definition: cb_thread.h:65
CB_THREAD_COND_T condition
Definition: cb_thread.h:161
int pri
Definition: cb_thread.h:71
static int cb_tsn_thread_attr_set_stackaddr(cb_tsn_thread_attr_t *attr, void *stack_addr)
Definition: cb_thread.h:144
uint64_t time
Definition: cb_thread.h:163
static bool cb_waitpoint_check(cb_waitpoint_t *wp, uint64_t time)
Wait point check.
Definition: cb_thread.h:195
static void cb_waitpoint_init(cb_waitpoint_t *wp)
Wait point initialization.
Definition: cb_thread.h:173
int stack_size
Definition: cb_thread.h:73
#define CB_THREAD_MUTEX_T
Definition: cb_thread.h:95
CB_THREAD_MUTEX_T lock
Definition: cb_thread.h:159
#define CB_THREAD_MUTEX_INIT
Definition: cb_thread.h:100
char name[CB_TSN_THREAD_NAME_SIZE]
Definition: cb_thread.h:75
bool wakeup
Definition: cb_thread.h:165
#define CB_THREAD_COND_T
Definition: cb_thread.h:107
#define CB_THREAD_COND_INIT
Definition: cb_thread.h:108
#define NULL
Define NULL if not defined.
Definition: csl_types.h:107
parameters to initialize thread
Definition: cb_thread.h:70
#define CB_THREAD_COND_WAIT
Definition: cb_thread.h:110
static void cb_waitpoint_deinit(cb_waitpoint_t *wp)
Wait point de-initialization.
Definition: cb_thread.h:184
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:217
void * stack_addr
Definition: cb_thread.h:77
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:131
Wait points that blocks the execution of a thread at a specific code point until an event occurs.
Definition: cb_thread.h:158
#define CB_THREAD_MUTEX_DESTROY
Definition: cb_thread.h:101
#define CB_THREAD_COND_DESTROY
Definition: cb_thread.h:109