PDK API Guide for J721E

Introduction

Files

file  cb_thread.h
 Bindings to POSIX thread, mutex and semaphore functions.
 

Data Structures

struct  cb_tsn_thread_attr_t
 parameters to initialize thread More...
 
struct  cb_waitpoint_t
 Wait points that blocks the execution of a thread at a specific code point until an event occurs. More...
 

Functions

static int cb_tsn_thread_attr_init (cb_tsn_thread_attr_t *attr, int pri, int stack_size, const char *name)
 
static int cb_tsn_thread_attr_set_stackaddr (cb_tsn_thread_attr_t *attr, void *stack_addr)
 
static void cb_waitpoint_init (cb_waitpoint_t *wp)
 Wait point initialization. More...
 
static void cb_waitpoint_deinit (cb_waitpoint_t *wp)
 Wait point de-initialization. More...
 
static bool cb_waitpoint_check (cb_waitpoint_t *wp, uint64_t time)
 Wait point check. More...
 
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. More...
 

Macros

#define CB_TSN_THREAD_NAME_SIZE   128
 data structure for thread attributes More...
 
#define CB_THREAD_T   pthread_t
 
#define CB_THREAD_CREATE(th, attr, func, arg)   pthread_create(th, NULL, func, arg)
 
#define CB_THREAD_JOIN   pthread_join
 
#define CB_THREAD_EXIT   pthread_exit
 
#define CB_THREAD_MUTEX_T   pthread_mutex_t
 
#define CB_THREAD_MUTEX_LOCK   pthread_mutex_lock
 
#define CB_THREAD_MUTEX_TRYLOCK   pthread_mutex_trylock
 
#define CB_THREAD_MUTEX_TIMEDLOCK   pthread_mutex_timedlock
 
#define CB_THREAD_MUTEX_UNLOCK   pthread_mutex_unlock
 
#define CB_THREAD_MUTEX_INIT   pthread_mutex_init
 
#define CB_THREAD_MUTEX_DESTROY   pthread_mutex_destroy
 
#define CB_THREAD_MUTEXATTR_T   pthread_mutexattr_t
 
#define CB_THREAD_MUTEXATTR_INIT   pthread_mutexattr_init
 
#define CB_THREAD_MUTEXATTR_SETPSHARED   pthread_mutexattr_setpshared
 
#define CB_THREAD_PROCESS_SHARED   PTHREAD_PROCESS_SHARED
 
#define CB_THREAD_PROCESS_PRIVATE   PTHREAD_PROCESS_PRIVATE
 
#define CB_THREAD_COND_T   pthread_cond_t
 
#define CB_THREAD_COND_INIT   pthread_cond_init
 
#define CB_THREAD_COND_DESTROY   pthread_cond_destroy
 
#define CB_THREAD_COND_WAIT   pthread_cond_wait
 
#define CB_THREAD_COND_SIGNAL   pthread_cond_signal
 
#define CB_THREAD_COND_BROADCAST   pthread_cond_broadcast
 
#define CB_SEM_T   sem_t
 
#define CB_SEM_INIT   sem_init
 
#define CB_SEM_GETVALUE   sem_getvalue
 
#define CB_SEM_WAIT   sem_wait
 
#define CB_SEM_TRYWAIT   sem_trywait
 
#define CB_SEM_TIMEDWAIT   sem_timedwait
 
#define CB_SEM_POST   sem_post
 
#define CB_SEM_DESTROY   sem_destroy
 
#define CB_SEM_OPEN   sem_open
 
#define CB_SEM_CLOSE   sem_close
 
#define CB_SEM_UNLINK   sem_unlink
 
#define CB_SEM_FAILED   SEM_FAILED
 
#define cb_waitpoint_wakeup(wp)   CB_THREAD_COND_SIGNAL(&(wp)->condition)
 Wait point wakeup to signal any one thread currently at this wait point. More...
 
#define cb_waitpoint_broadcast(wp)   CB_THREAD_COND_BROADCAST(&(wp)->condition)
 Wait point wakeup to signal all threads currently at this wait point. More...
 
#define cb_waitpoint_lock(wp)   CB_THREAD_MUTEX_LOCK(&(wp)->lock)
 Wait point lock. More...
 
#define cb_waitpoint_unlock(wp)   CB_THREAD_MUTEX_UNLOCK(&(wp)->lock)
 Wait point unlock. More...
 

Macro Definition Documentation

◆ CB_TSN_THREAD_NAME_SIZE

#define CB_TSN_THREAD_NAME_SIZE   128

data structure for thread attributes

◆ CB_THREAD_T

#define CB_THREAD_T   pthread_t

◆ CB_THREAD_CREATE

#define CB_THREAD_CREATE (   th,
  attr,
  func,
  arg 
)    pthread_create(th, NULL, func, arg)

◆ CB_THREAD_JOIN

#define CB_THREAD_JOIN   pthread_join

◆ CB_THREAD_EXIT

#define CB_THREAD_EXIT   pthread_exit

◆ CB_THREAD_MUTEX_T

#define CB_THREAD_MUTEX_T   pthread_mutex_t

◆ CB_THREAD_MUTEX_LOCK

#define CB_THREAD_MUTEX_LOCK   pthread_mutex_lock

◆ CB_THREAD_MUTEX_TRYLOCK

#define CB_THREAD_MUTEX_TRYLOCK   pthread_mutex_trylock

◆ CB_THREAD_MUTEX_TIMEDLOCK

#define CB_THREAD_MUTEX_TIMEDLOCK   pthread_mutex_timedlock

◆ CB_THREAD_MUTEX_UNLOCK

#define CB_THREAD_MUTEX_UNLOCK   pthread_mutex_unlock

◆ CB_THREAD_MUTEX_INIT

#define CB_THREAD_MUTEX_INIT   pthread_mutex_init

◆ CB_THREAD_MUTEX_DESTROY

#define CB_THREAD_MUTEX_DESTROY   pthread_mutex_destroy

◆ CB_THREAD_MUTEXATTR_T

#define CB_THREAD_MUTEXATTR_T   pthread_mutexattr_t

◆ CB_THREAD_MUTEXATTR_INIT

#define CB_THREAD_MUTEXATTR_INIT   pthread_mutexattr_init

◆ CB_THREAD_MUTEXATTR_SETPSHARED

#define CB_THREAD_MUTEXATTR_SETPSHARED   pthread_mutexattr_setpshared

◆ CB_THREAD_PROCESS_SHARED

#define CB_THREAD_PROCESS_SHARED   PTHREAD_PROCESS_SHARED

◆ CB_THREAD_PROCESS_PRIVATE

#define CB_THREAD_PROCESS_PRIVATE   PTHREAD_PROCESS_PRIVATE

◆ CB_THREAD_COND_T

#define CB_THREAD_COND_T   pthread_cond_t

◆ CB_THREAD_COND_INIT

#define CB_THREAD_COND_INIT   pthread_cond_init

◆ CB_THREAD_COND_DESTROY

#define CB_THREAD_COND_DESTROY   pthread_cond_destroy

◆ CB_THREAD_COND_WAIT

#define CB_THREAD_COND_WAIT   pthread_cond_wait

◆ CB_THREAD_COND_SIGNAL

#define CB_THREAD_COND_SIGNAL   pthread_cond_signal

◆ CB_THREAD_COND_BROADCAST

#define CB_THREAD_COND_BROADCAST   pthread_cond_broadcast

◆ CB_SEM_T

#define CB_SEM_T   sem_t

◆ CB_SEM_INIT

#define CB_SEM_INIT   sem_init

◆ CB_SEM_GETVALUE

#define CB_SEM_GETVALUE   sem_getvalue

◆ CB_SEM_WAIT

#define CB_SEM_WAIT   sem_wait

◆ CB_SEM_TRYWAIT

#define CB_SEM_TRYWAIT   sem_trywait

◆ CB_SEM_TIMEDWAIT

#define CB_SEM_TIMEDWAIT   sem_timedwait

◆ CB_SEM_POST

#define CB_SEM_POST   sem_post

◆ CB_SEM_DESTROY

#define CB_SEM_DESTROY   sem_destroy

◆ CB_SEM_OPEN

#define CB_SEM_OPEN   sem_open

◆ CB_SEM_CLOSE

#define CB_SEM_CLOSE   sem_close

◆ CB_SEM_UNLINK

#define CB_SEM_UNLINK   sem_unlink

◆ CB_SEM_FAILED

#define CB_SEM_FAILED   SEM_FAILED

◆ cb_waitpoint_wakeup

#define cb_waitpoint_wakeup (   wp)    CB_THREAD_COND_SIGNAL(&(wp)->condition)

Wait point wakeup to signal any one thread currently at this wait point.

Parameters
wpobject reference to a waitpoint

This interface should be called within and cb_waitpoint_lock/cb_waitpoint_unlock.

◆ cb_waitpoint_broadcast

#define cb_waitpoint_broadcast (   wp)    CB_THREAD_COND_BROADCAST(&(wp)->condition)

Wait point wakeup to signal all threads currently at this wait point.

Parameters
wpobject reference to a waitpoint

This interface should be called within and cb_waitpoint_lock/cb_waitpoint_unlock.

◆ cb_waitpoint_lock

#define cb_waitpoint_lock (   wp)    CB_THREAD_MUTEX_LOCK(&(wp)->lock)

Wait point lock.

Parameters
wpobject reference to a waitpoint

◆ cb_waitpoint_unlock

#define cb_waitpoint_unlock (   wp)    CB_THREAD_MUTEX_UNLOCK(&(wp)->lock)

Wait point unlock.

Parameters
wpobject reference to a waitpoint

Function Documentation

◆ cb_tsn_thread_attr_init()

static int cb_tsn_thread_attr_init ( cb_tsn_thread_attr_t attr,
int  pri,
int  stack_size,
const char *  name 
)
inlinestatic

◆ cb_tsn_thread_attr_set_stackaddr()

static int cb_tsn_thread_attr_set_stackaddr ( cb_tsn_thread_attr_t attr,
void *  stack_addr 
)
inlinestatic

◆ cb_waitpoint_init()

static void cb_waitpoint_init ( cb_waitpoint_t wp)
inlinestatic

Wait point initialization.

Parameters
wpobject reference to a waitpoint

◆ cb_waitpoint_deinit()

static void cb_waitpoint_deinit ( cb_waitpoint_t wp)
inlinestatic

Wait point de-initialization.

Parameters
wpobject reference to a waitpoint

◆ cb_waitpoint_check()

static bool cb_waitpoint_check ( cb_waitpoint_t wp,
uint64_t  time 
)
inlinestatic

Wait point check.

Parameters
wpobject reference to a waitpoint
timereference time, usually the current time
Returns
true if wait time has elapsed and not yet awoke, otherwise false

◆ cb_waitpoint_wakeup_at()

static void cb_waitpoint_wakeup_at ( cb_waitpoint_t wp,
uint64_t  time,
bool  dosleep 
)
inlinestatic

Wait point blocks until wake point has been awoken and after specified time.

Parameters
wpobject reference to a waitpoint
timereference time, usually the current time
dosleepwhether to wait on waitpoint condition or not
Returns
true if wait time has elapsed and not yet awoke, otherwise false

This interface should be called within and cb_waitpoint_lock, which is then automatically unlocked before entering blocking state and then automatically locked again when exiting the blocked state.