AM263x MCU+ SDK  10.00.00
TI ENET LLD thread specific

Introduction

Files

file  cb_lld_thread.h
 bindings to TI ENET LLD specific thread, mutex and semaphore functions
 

Functions

int cb_lld_sem_init (CB_SEM_T *sem, int pshared, unsigned int value)
 Initializes a semaphore. More...
 
int cb_lld_sem_wait (CB_SEM_T *sem)
 Waits on a semaphore until it becomes available. More...
 
int cb_lld_sem_trywait (CB_SEM_T *sem)
 Attempts to wait on a semaphore without blocking. To know if the semaphore was acquired, get the return value from the cb_lld_sem_wait_status(). If the return value is 1, then the semaphore was acquired. Otherwise, the semaphore was not acquired. More...
 
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 was acquired, refer to the cb_lld_sem_wait_status(). More...
 
int cb_lld_sem_post (CB_SEM_T *sem)
 Posts (signals) a semaphore, releasing a waiting thread. More...
 
int cb_lld_sem_getvalue (CB_SEM_T *sem, int *sval)
 return the count of a semaphore More...
 
int cb_lld_sem_destroy (CB_SEM_T *sem)
 Destroys a semaphore. More...
 
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_sem_wait(), cb_lld_sem_trywait() and cb_lld_sem_timedwait() More...
 
int cb_lld_mutex_init (CB_THREAD_MUTEX_T *mutex, CB_THREAD_MUTEXATTR_T attr)
 Initializes a mutex. More...
 
static int cb_lld_mutex_init_protect (void *mutex)
 Initializes a mutex that will be protected by the UB_PROTECTED_FUNC_VOID(). More...
 
int cb_lld_mutex_destroy (CB_THREAD_MUTEX_T *mutex)
 Destroys a mutex. More...
 
static void cb_lld_mutex_destroy_protect (void *mutex)
 Destroy a mutex that will be protected by the UB_PROTECTED_FUNC_VOID(). More...
 
int cb_lld_mutex_lock (CB_THREAD_MUTEX_T *mutex)
 Locks a mutex. More...
 
int cb_lld_mutex_unlock (CB_THREAD_MUTEX_T *mutex)
 Unlocks a mutex. More...
 
int cb_lld_mutex_trylock (CB_THREAD_MUTEX_T *mutex)
 Attempts to lock a mutex without blocking. More...
 
int cb_lld_mutex_timedlock (CB_THREAD_MUTEX_T *mutex, struct timespec *abstime)
 Locks a mutex and waits until a timeout occurs. More...
 
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 executing the specified function with the provided argument. More...
 
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. More...
 
void cb_lld_task_exit (void *retval)
 Terminates the calling thread. More...
 

Typedefs

typedef struct cb_lld_sem cb_lld_sem_t
 
typedef struct cb_lld_task cb_lld_task_t
 

Macros

#define TILLD_SUCCESS   (0)
 
#define TILLD_FAILURE   (-1)
 
#define TILLD_TIMEDOUT   (-2)
 
#define CB_THREAD_T   cb_lld_task_t*
 
#define CB_THREAD_CREATE   cb_lld_task_create
 
#define CB_THREAD_JOIN   cb_lld_task_join
 
#define CB_THREAD_EXIT   cb_lld_task_exit
 
#define CB_THREAD_MUTEX_T   cb_lld_mutex_t
 
#define CB_THREAD_MUTEX_LOCK   cb_lld_mutex_lock
 
#define CB_THREAD_MUTEX_TRYLOCK   cb_lld_mutex_trylock
 
#define CB_THREAD_MUTEX_TIMEDLOCK   cb_lld_mutex_timedlock
 
#define CB_THREAD_MUTEX_UNLOCK   cb_lld_mutex_unlock
 
#define CB_THREAD_MUTEX_INIT   cb_lld_mutex_init
 
#define CB_THREAD_MUTEX_DESTROY   cb_lld_mutex_destroy
 
#define CB_THREAD_IS_MUTEX_INITIALIZED(x)   ((x).lldmutex!=NULL)
 
#define CB_STATIC_MUTEX_INITIALIZER(x)   x=TILLD_MUTEX_INITIALIZER
 
#define CB_STATIC_MUTEX_CONSTRUCTOR(x)    UB_PROTECTED_FUNC_VOID(cb_lld_mutex_init_protect,&(x))
 
#define CB_STATIC_MUTEX_DESTRUCTOR(x)    UB_PROTECTED_FUNC_VOID(cb_lld_mutex_destroy_protect, &(x))
 
#define CB_THREAD_MUTEXATTR_T   void*
 
#define CB_THREAD_MUTEXATTR_INIT(a)
 
#define CB_THREAD_MUTEXATTR_SETPSHARED(a, b)
 
#define CB_THREAD_PROCESS_SHARED   0
 
#define CB_SEM_T   cb_lld_sem_t*
 
#define CB_SEM_INIT   cb_lld_sem_init
 
#define CB_SEM_GETVALUE   cb_lld_sem_getvalue
 
#define CB_SEM_WAIT   cb_lld_sem_wait
 
#define CB_SEM_TRYWAIT   cb_lld_sem_trywait
 
#define CB_SEM_TIMEDWAIT   cb_lld_sem_timedwait
 
#define CB_SEM_POST   cb_lld_sem_post
 
#define CB_SEM_DESTROY   cb_lld_sem_destroy
 
#define CB_THREAD_COND_T   void*
 
#define CB_THREAD_COND_INIT(a, b)
 
#define CB_THREAD_COND_DESTROY(a)
 
#define CB_THREAD_COND_WAIT(a, b)
 
#define CB_THREAD_COND_SIGNAL(a)
 
#define CB_THREAD_COND_BROADCAST(a)
 

Macro Definition Documentation

◆ TILLD_SUCCESS

#define TILLD_SUCCESS   (0)

◆ TILLD_FAILURE

#define TILLD_FAILURE   (-1)

◆ TILLD_TIMEDOUT

#define TILLD_TIMEDOUT   (-2)

◆ CB_THREAD_T

#define CB_THREAD_T   cb_lld_task_t*

◆ CB_THREAD_CREATE

#define CB_THREAD_CREATE   cb_lld_task_create

◆ CB_THREAD_JOIN

#define CB_THREAD_JOIN   cb_lld_task_join

◆ CB_THREAD_EXIT

#define CB_THREAD_EXIT   cb_lld_task_exit

◆ CB_THREAD_MUTEX_T

#define CB_THREAD_MUTEX_T   cb_lld_mutex_t

◆ CB_THREAD_MUTEX_LOCK

#define CB_THREAD_MUTEX_LOCK   cb_lld_mutex_lock

◆ CB_THREAD_MUTEX_TRYLOCK

#define CB_THREAD_MUTEX_TRYLOCK   cb_lld_mutex_trylock

◆ CB_THREAD_MUTEX_TIMEDLOCK

#define CB_THREAD_MUTEX_TIMEDLOCK   cb_lld_mutex_timedlock

◆ CB_THREAD_MUTEX_UNLOCK

#define CB_THREAD_MUTEX_UNLOCK   cb_lld_mutex_unlock

◆ CB_THREAD_MUTEX_INIT

#define CB_THREAD_MUTEX_INIT   cb_lld_mutex_init

◆ CB_THREAD_MUTEX_DESTROY

#define CB_THREAD_MUTEX_DESTROY   cb_lld_mutex_destroy

◆ CB_THREAD_IS_MUTEX_INITIALIZED

#define CB_THREAD_IS_MUTEX_INITIALIZED (   x)    ((x).lldmutex!=NULL)

◆ CB_STATIC_MUTEX_INITIALIZER

#define CB_STATIC_MUTEX_INITIALIZER (   x)    x=TILLD_MUTEX_INITIALIZER

◆ CB_STATIC_MUTEX_CONSTRUCTOR

#define CB_STATIC_MUTEX_CONSTRUCTOR (   x)     UB_PROTECTED_FUNC_VOID(cb_lld_mutex_init_protect,&(x))

◆ CB_STATIC_MUTEX_DESTRUCTOR

#define CB_STATIC_MUTEX_DESTRUCTOR (   x)     UB_PROTECTED_FUNC_VOID(cb_lld_mutex_destroy_protect, &(x))

◆ CB_THREAD_MUTEXATTR_T

#define CB_THREAD_MUTEXATTR_T   void*

◆ CB_THREAD_MUTEXATTR_INIT

#define CB_THREAD_MUTEXATTR_INIT (   a)

◆ CB_THREAD_MUTEXATTR_SETPSHARED

#define CB_THREAD_MUTEXATTR_SETPSHARED (   a,
 
)

◆ CB_THREAD_PROCESS_SHARED

#define CB_THREAD_PROCESS_SHARED   0

◆ CB_SEM_T

#define CB_SEM_T   cb_lld_sem_t*

◆ CB_SEM_INIT

#define CB_SEM_INIT   cb_lld_sem_init

◆ CB_SEM_GETVALUE

#define CB_SEM_GETVALUE   cb_lld_sem_getvalue

◆ CB_SEM_WAIT

#define CB_SEM_WAIT   cb_lld_sem_wait

◆ CB_SEM_TRYWAIT

#define CB_SEM_TRYWAIT   cb_lld_sem_trywait

◆ CB_SEM_TIMEDWAIT

#define CB_SEM_TIMEDWAIT   cb_lld_sem_timedwait

◆ CB_SEM_POST

#define CB_SEM_POST   cb_lld_sem_post

◆ CB_SEM_DESTROY

#define CB_SEM_DESTROY   cb_lld_sem_destroy

◆ CB_THREAD_COND_T

#define CB_THREAD_COND_T   void*

◆ CB_THREAD_COND_INIT

#define CB_THREAD_COND_INIT (   a,
 
)

◆ CB_THREAD_COND_DESTROY

#define CB_THREAD_COND_DESTROY (   a)

◆ CB_THREAD_COND_WAIT

#define CB_THREAD_COND_WAIT (   a,
 
)

◆ CB_THREAD_COND_SIGNAL

#define CB_THREAD_COND_SIGNAL (   a)

◆ CB_THREAD_COND_BROADCAST

#define CB_THREAD_COND_BROADCAST (   a)

Typedef Documentation

◆ cb_lld_sem_t

typedef struct cb_lld_sem cb_lld_sem_t

◆ cb_lld_task_t

typedef struct cb_lld_task cb_lld_task_t

Function Documentation

◆ cb_lld_sem_init()

int cb_lld_sem_init ( CB_SEM_T sem,
int  pshared,
unsigned int  value 
)

Initializes a semaphore.

Parameters
semPointer to the semaphore.
psharedIndicates whether the semaphore is shared among processes.
valueThe initial value of the semaphore.
Returns
0 on success, or -1 on error.

◆ cb_lld_sem_wait()

int cb_lld_sem_wait ( CB_SEM_T sem)

Waits on a semaphore until it becomes available.

Parameters
semPointer to the semaphore.
Returns
0 on success, or -1 on error.

◆ cb_lld_sem_trywait()

int cb_lld_sem_trywait ( CB_SEM_T sem)

Attempts to wait on a semaphore without blocking. To know if the semaphore was acquired, get the return value from the cb_lld_sem_wait_status(). If the return value is 1, then the semaphore was acquired. Otherwise, the semaphore was not acquired.

Parameters
semPointer to the semaphore.
Returns
0 if no error, or -1 on error.

◆ cb_lld_sem_timedwait()

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 was acquired, refer to the cb_lld_sem_wait_status().

Parameters
semPointer to the semaphore.
abstimePointer to the absolute timeout value.
Returns
0 if no error, or -1 on error.

◆ cb_lld_sem_post()

int cb_lld_sem_post ( CB_SEM_T sem)

Posts (signals) a semaphore, releasing a waiting thread.

Parameters
semPointer to the semaphore.
Returns
0 on success, or -1 on error.

◆ cb_lld_sem_getvalue()

int cb_lld_sem_getvalue ( CB_SEM_T sem,
int *  sval 
)

return the count of a semaphore

Parameters
semPointer to the semaphore.
svalreturn value of semaphore counter
Returns
0 on success, or -1 on error.

◆ cb_lld_sem_destroy()

int cb_lld_sem_destroy ( CB_SEM_T sem)

Destroys a semaphore.

Parameters
semPointer to the semaphore.
Returns
0 on success, or -1 on error.

◆ cb_lld_sem_wait_status()

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_sem_wait(), cb_lld_sem_trywait() and cb_lld_sem_timedwait()

Parameters
semPointer to the semaphore.
Returns
TILLD_SUCCESS: semaphore was acquired, TILLD_FAILURE: on failure, TILLD_TIMEDOUT: on timeout.

◆ cb_lld_mutex_init()

int cb_lld_mutex_init ( CB_THREAD_MUTEX_T mutex,
CB_THREAD_MUTEXATTR_T  attr 
)

Initializes a mutex.

Parameters
mutexPointer to the mutex.
attrPointer to the mutex attributes.
Returns
0 on success, or -1 on error.

◆ cb_lld_mutex_init_protect()

static int cb_lld_mutex_init_protect ( void *  mutex)
inlinestatic

Initializes a mutex that will be protected by the UB_PROTECTED_FUNC_VOID().

This function is primarily designed for initializing a mutex used in conjunction with the UB_PROTECTED_FUNC_VOID(). For general use cases, consider utilizing the cb_lld_mutex_init() function instead.

Parameters
mutexPointer to a mutex of type CB_THREAD_MUTEX_T.
Returns
0 on success, or -1 on error.

◆ cb_lld_mutex_destroy()

int cb_lld_mutex_destroy ( CB_THREAD_MUTEX_T mutex)

Destroys a mutex.

Parameters
mutexPointer to the mutex.
Returns
0 on success, or -1 on error.

◆ cb_lld_mutex_destroy_protect()

static void cb_lld_mutex_destroy_protect ( void *  mutex)
inlinestatic

Destroy a mutex that will be protected by the UB_PROTECTED_FUNC_VOID().

This function is primarily designed for destroying a mutex used in conjunction with the UB_PROTECTED_FUNC_VOID(). For general use cases, consider utilizing the cb_lld_mutex_destroy() function instead.

Parameters
mutexPointer to a mutex of type CB_THREAD_MUTEX_T.

◆ cb_lld_mutex_lock()

int cb_lld_mutex_lock ( CB_THREAD_MUTEX_T mutex)

Locks a mutex.

Parameters
mutexPointer to the mutex.
Returns
0 on success, or -1 on error.

◆ cb_lld_mutex_unlock()

int cb_lld_mutex_unlock ( CB_THREAD_MUTEX_T mutex)

Unlocks a mutex.

Parameters
mutexPointer to the mutex.
Returns
0 on success, or -1 on error.

◆ cb_lld_mutex_trylock()

int cb_lld_mutex_trylock ( CB_THREAD_MUTEX_T mutex)

Attempts to lock a mutex without blocking.

Parameters
mutexPointer to the mutex.
Returns
0 on success, or -1 on error.

◆ cb_lld_mutex_timedlock()

int cb_lld_mutex_timedlock ( CB_THREAD_MUTEX_T mutex,
struct timespec *  abstime 
)

Locks a mutex and waits until a timeout occurs.

Parameters
mutexPointer to the mutex.
abstimePointer to the absolute timeout value.
Returns
0 on success, -1 on error

◆ cb_lld_task_create()

int cb_lld_task_create ( CB_THREAD_T th,
void *  attr,
void *(*)(void *)  func,
void *  arg 
)

Creates a new thread. This function creates a new thread with the specified attributes and starts executing the specified function with the provided argument.

Parameters
thPointer to a thread object that will be initialized with the created thread.
attrThread attributes.
funcPointer to the function that will be executed by the thread.
argArgument to be passed to the thread function.
Returns
0 on success, -1 on error

◆ cb_lld_task_join()

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.

Parameters
thThread to be joined.
retvalPointer to a pointer that will be set to the exit status of the joined thread (unsupported).
Returns
0 on success, -1 on error

◆ cb_lld_task_exit()

void cb_lld_task_exit ( void *  retval)

Terminates the calling thread.

Parameters
retvalExit value of the thread (unsupported).