SimGrid  3.16
Versatile Simulation of Distributed Systems

Detailed Description

Thread portability layer.

This section describes the thread portability layer. It defines types and functions very close to the pthread API, but it's portable to windows too.

Typedefs

typedef struct xbt_os_thread_xbt_os_thread_t
 Thread data type (opaque structure) More...
 
typedef struct xbt_os_mutex_xbt_os_mutex_t
 Thread mutex data type (opaque structure) More...
 
typedef struct xbt_os_cond_xbt_os_cond_t
 Thread condition data type (opaque structure) More...
 
typedef struct xbt_os_sem_xbt_os_sem_t
 Semaphore data type (opaque structure) More...
 

Functions

int xbt_os_get_numcores (void)
 Returns the amount of cores on the current host. More...
 
xbt_os_thread_t xbt_os_thread_create (const char *name, pvoid_f_pvoid_t start_routine, void *param, void *data)
 
void xbt_os_thread_exit (int *retcode)
 
void xbt_os_thread_detach (xbt_os_thread_t thread)
 
xbt_os_thread_t xbt_os_thread_self (void)
 
const char * xbt_os_thread_self_name (void)
 
void xbt_os_thread_set_extra_data (void *data)
 
voidxbt_os_thread_get_extra_data (void)
 
void xbt_os_thread_key_create (xbt_os_thread_key_t *key)
 
void xbt_os_thread_set_specific (xbt_os_thread_key_t key, void *value)
 
voidxbt_os_thread_get_specific (xbt_os_thread_key_t key)
 
void xbt_os_thread_join (xbt_os_thread_t thread, void **thread_return)
 
void xbt_os_thread_yield (void)
 
void xbt_os_thread_cancel (xbt_os_thread_t thread)
 
void xbt_os_thread_setstacksize (int stack_size)
 
void xbt_os_thread_setguardsize (int guard_size)
 
int xbt_os_thread_bind (xbt_os_thread_t thread, int core)
 Bind the thread to the given core, if possible. More...
 
int xbt_os_thread_atfork (void(*prepare)(void), void(*parent)(void), void(*child)(void))
 Calls pthread_atfork() if present, and raise an exception otherwise. More...
 
xbt_os_mutex_t xbt_os_mutex_init (void)
 
void xbt_os_mutex_acquire (xbt_os_mutex_t mutex)
 
void xbt_os_mutex_release (xbt_os_mutex_t mutex)
 
void xbt_os_mutex_destroy (xbt_os_mutex_t mutex)
 
xbt_os_cond_t xbt_os_cond_init (void)
 
void xbt_os_cond_wait (xbt_os_cond_t cond, xbt_os_mutex_t mutex)
 
void xbt_os_cond_signal (xbt_os_cond_t cond)
 
void xbt_os_cond_broadcast (xbt_os_cond_t cond)
 
void xbt_os_cond_destroy (xbt_os_cond_t cond)
 
xbt_os_sem_t xbt_os_sem_init (unsigned int value)
 
void xbt_os_sem_acquire (xbt_os_sem_t sem)
 
void xbt_os_sem_release (xbt_os_sem_t sem)
 
void xbt_os_sem_destroy (xbt_os_sem_t sem)
 

Typedef Documentation

◆ xbt_os_thread_t

Thread data type (opaque structure)

◆ xbt_os_mutex_t

typedef struct xbt_os_mutex_* xbt_os_mutex_t

Thread mutex data type (opaque structure)

◆ xbt_os_cond_t

typedef struct xbt_os_cond_* xbt_os_cond_t

Thread condition data type (opaque structure)

◆ xbt_os_sem_t

typedef struct xbt_os_sem_* xbt_os_sem_t

Semaphore data type (opaque structure)

Function Documentation

◆ xbt_os_get_numcores()

int xbt_os_get_numcores ( void  )

Returns the amount of cores on the current host.

◆ xbt_os_thread_create()

xbt_os_thread_t xbt_os_thread_create ( const char *  name,
pvoid_f_pvoid_t  start_routine,
void param,
void data 
)

◆ xbt_os_thread_exit()

void xbt_os_thread_exit ( int *  retcode)

◆ xbt_os_thread_detach()

void xbt_os_thread_detach ( xbt_os_thread_t  thread)

◆ xbt_os_thread_self()

xbt_os_thread_t xbt_os_thread_self ( void  )

◆ xbt_os_thread_self_name()

const char* xbt_os_thread_self_name ( void  )

◆ xbt_os_thread_set_extra_data()

void xbt_os_thread_set_extra_data ( void data)

◆ xbt_os_thread_get_extra_data()

void* xbt_os_thread_get_extra_data ( void  )

◆ xbt_os_thread_key_create()

void xbt_os_thread_key_create ( xbt_os_thread_key_t key)

◆ xbt_os_thread_set_specific()

void xbt_os_thread_set_specific ( xbt_os_thread_key_t  key,
void value 
)

◆ xbt_os_thread_get_specific()

void* xbt_os_thread_get_specific ( xbt_os_thread_key_t  key)

◆ xbt_os_thread_join()

void xbt_os_thread_join ( xbt_os_thread_t  thread,
void **  thread_return 
)

◆ xbt_os_thread_yield()

void xbt_os_thread_yield ( void  )

◆ xbt_os_thread_cancel()

void xbt_os_thread_cancel ( xbt_os_thread_t  thread)

◆ xbt_os_thread_setstacksize()

void xbt_os_thread_setstacksize ( int  stack_size)

◆ xbt_os_thread_setguardsize()

void xbt_os_thread_setguardsize ( int  guard_size)

◆ xbt_os_thread_bind()

int xbt_os_thread_bind ( xbt_os_thread_t  thread,
int  cpu 
)

Bind the thread to the given core, if possible.

If pthread_setaffinity_np is not usable on that (non-gnu) platform, this function does nothing.

◆ xbt_os_thread_atfork()

int xbt_os_thread_atfork ( void(*)(void prepare,
void(*)(void parent,
void(*)(void child 
)

Calls pthread_atfork() if present, and raise an exception otherwise.

The only known user of this wrapper is mmalloc_preinit(), but it is absolutely mandatory there: when used with tesh, mmalloc must be mutex protected and resistant to forks. This functionality is the only way to get it working (by ensuring that the mutex is consistently released on forks)

◆ xbt_os_mutex_init()

xbt_os_mutex_t xbt_os_mutex_init ( void  )

◆ xbt_os_mutex_acquire()

void xbt_os_mutex_acquire ( xbt_os_mutex_t  mutex)

◆ xbt_os_mutex_release()

void xbt_os_mutex_release ( xbt_os_mutex_t  mutex)

◆ xbt_os_mutex_destroy()

void xbt_os_mutex_destroy ( xbt_os_mutex_t  mutex)

◆ xbt_os_cond_init()

xbt_os_cond_t xbt_os_cond_init ( void  )

◆ xbt_os_cond_wait()

void xbt_os_cond_wait ( xbt_os_cond_t  cond,
xbt_os_mutex_t  mutex 
)

◆ xbt_os_cond_signal()

void xbt_os_cond_signal ( xbt_os_cond_t  cond)

◆ xbt_os_cond_broadcast()

void xbt_os_cond_broadcast ( xbt_os_cond_t  cond)

◆ xbt_os_cond_destroy()

void xbt_os_cond_destroy ( xbt_os_cond_t  cond)

◆ xbt_os_sem_init()

xbt_os_sem_t xbt_os_sem_init ( unsigned int  value)

◆ xbt_os_sem_acquire()

void xbt_os_sem_acquire ( xbt_os_sem_t  sem)

◆ xbt_os_sem_release()

void xbt_os_sem_release ( xbt_os_sem_t  sem)

◆ xbt_os_sem_destroy()

void xbt_os_sem_destroy ( xbt_os_sem_t  sem)