CAEN Utility  2.0.2
Utilities for CAEN projects
Thread related functions

Platform independent functions to manage threads. More...

Collaboration diagram for Thread related functions:

Modules

 Tickets related functions
 Platform independent implementation of fair mutex.
 

Functions

c_thread_t c_thread_invalid ()
 
int32_t c_thread_create (c_thread_t *thr, c_tstart_t func, void *arg)
 
int32_t c_thread_join (c_thread_t thr, int *res)
 
int32_t c_thread_timedjoin (c_thread_t thr, int *res, int32_t timeout_ms)
 
int32_t c_thread_setaffinity (c_thread_t thr, uint64_t mask)
 
c_thread_t c_thread_current (void)
 
void c_thread_yield (void)
 
int32_t c_thread_detach (c_thread_t thr)
 
void c_thread_exit (int res)
 
bool c_thread_equal (c_thread_t lhs, c_thread_t rhs)
 
int32_t c_thread_sleep (const struct timespec *duration, struct timespec *remaining)
 
int32_t c_sleep (uint32_t ms)
 

Detailed Description

Platform independent functions to manage threads.

Function Documentation

◆ c_thread_invalid()

c_thread_t c_thread_invalid ( )

Initializer for invalid c_thread_t

Definition at line 609 of file CAENThread.c.

Here is the caller graph for this function:

◆ c_thread_create()

int32_t c_thread_create ( c_thread_t thr,
c_tstart_t  func,
void *  arg 
)

Create thread

Parameters
[out]thra pointer to uninitialized c_thread_t
[in]funcfunction to execute
[out]argargument to pass to the function

Definition at line 621 of file CAENThread.c.

Here is the call graph for this function:

◆ c_thread_join()

int32_t c_thread_join ( c_thread_t  thr,
int *  res 
)

Join thread

Parameters
[in]thra pointer to initialized c_thread_t
[out]reslocation to put the result code to

Definition at line 654 of file CAENThread.c.

Here is the call graph for this function:

◆ c_thread_timedjoin()

int32_t c_thread_timedjoin ( c_thread_t  thr,
int *  res,
int32_t  timeout_ms 
)

Join thread with timeout

Parameters
[in]thra pointer to initialized c_thread_t
[out]reslocation to put the result code to
[in]timeout_mstimeout in milliseconds

Definition at line 658 of file CAENThread.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_thread_setaffinity()

int32_t c_thread_setaffinity ( c_thread_t  thr,
uint64_t  mask 
)

Set affinity to a specific set of CPU core

Precondition
Linux only
Parameters
[in]thra pointer to initialized c_thread_t
[in]maska mask with bit set to 1 at the position of the required cores

Definition at line 68 of file CAENThread.c.

◆ c_thread_current()

c_thread_t c_thread_current ( void  )

Get the identifier of the calling thread.

Definition at line 100 of file CAENThread.c.

Here is the caller graph for this function:

◆ c_thread_yield()

void c_thread_yield ( void  )

Provides a hint to the implementation to reschedule the execution of threads, allowing other threads to run

Definition at line 112 of file CAENThread.c.

◆ c_thread_detach()

int32_t c_thread_detach ( c_thread_t  thr)

Detach a thread

Parameters
[in]thra pointer to initialized c_thread_t

Definition at line 127 of file CAENThread.c.

◆ c_thread_exit()

void c_thread_exit ( int  res)

Terminate the execution of the calling thread and set its result code to res.

Parameters
[in]resresult code

Definition at line 147 of file CAENThread.c.

◆ c_thread_equal()

bool c_thread_equal ( c_thread_t  lhs,
c_thread_t  rhs 
)

Checks whether lhs and rhs refer to the same thread.

Parameters
[in]lhsthread to compare
[in]rhsthread to compare
Returns
true if equal

Definition at line 155 of file CAENThread.c.

Here is the caller graph for this function:

◆ c_thread_sleep()

int32_t c_thread_sleep ( const struct timespec *  duration,
struct timespec *  remaining 
)

Blocks the execution of the current thread for a period of time

Parameters
[in]durationpointer to the duration to sleep for
[out]remainingpointer to the object to put the remaining time on interruption; may be NULL, in which case it is ignored
Returns
0 on success, -1 if a signal occurred, other negative value if an error occurred
Warning
This function does not return values from CAENThread_RetCode_t, for compatibility with C11 thrd_sleep().

Definition at line 537 of file CAENThread.c.

◆ c_sleep()

int32_t c_sleep ( uint32_t  ms)

Blocks the execution of the current thread for a period of time

Parameters
[in]msperiod in ms

Definition at line 566 of file CAENThread.c.