ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
Typedefs | Functions
thread.h File Reference

Generic architecture management facilities. More...

#include <arch/platform.h>
Include dependency graph for thread.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef thrd_ret_t(THREAD_CALL_CONV * thr_run_fnc) (void *)
 The function type of a new thread entry point.
 

Functions

int thread_start (thr_id_t *thr_p, thr_run_fnc t_fnc, void *t_fnc_arg)
 Creates a thread. More...
 
int thread_affinity_set (thr_id_t thr, unsigned core)
 Sets a core affinity for a thread. More...
 
int thread_wait (thr_id_t thr, thrd_ret_t *ret)
 Wait for specified thread to complete execution. More...
 
unsigned thread_cores_count (void)
 Computes the count of available cores on the machine. More...
 

Detailed Description

Generic architecture management facilities.

This module provides generic facilities for thread and core management. In particular, helper functions to startup worker threads are exposed, and a function to synchronize multiple threads on a software barrier.

The software barrier also offers a leader election facility, so that once all threads are synchronized on the barrier, the function returns true to only one of them.

Function Documentation

◆ thread_affinity_set()

thread_affinity_set ( thr_id_t  thr,
unsigned  core 
)

Sets a core affinity for a thread.

Parameters
thrThe identifier of the thread targeted for the affinity change
coreThe core id where the target thread will be pinned on
Returns
0 if successful, -1 otherwise

◆ thread_cores_count()

thread_cores_count ( void  )

Computes the count of available cores on the machine.

Returns
the count of the processing cores available on the machine

◆ thread_start()

thread_start ( thr_id_t *  thr_p,
thr_run_fnc  t_fnc,
void *  t_fnc_arg 
)

Creates a thread.

Parameters
thr_pA pointer to the location where the created thread identifier will be copied
t_fncThe new thread entry point
t_fnc_argA pointer to the argument to be passed to the new thread entry point
Returns
0 if successful, -1 otherwise

◆ thread_wait()

thread_wait ( thr_id_t  thr,
thrd_ret_t *  ret 
)

Wait for specified thread to complete execution.

Parameters
thrThe identifier of the thread to wait for
retA pointer to the location where the return value will be copied, or alternatively NULL
Returns
0 if successful, -1 otherwise