SimGrid: Thread stuff

SimGrid 3.10 Versatile Simulation of Distributed Systems

- Home page
- Online documentation
- Dev's Corner

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Typedefs | Functions
Thread stuff
Misc general purposes library components

Thread portability layer. More...

## Typedefs
typedef struct xbt_os_thread_ * | xbt_os_thread_t
| Thread data type (opaque structure)
typedef struct xbt_os_mutex_ * | xbt_os_mutex_t
| Thread mutex data type (opaque structure)
typedef struct xbt_os_rmutex_ * | xbt_os_rmutex_t
| Thread reentrant mutex data type (opaque structure)
typedef struct xbt_os_cond_ * | xbt_os_cond_t
| Thread condition data type (opaque structure)
typedef struct xbt_os_sem_ * | xbt_os_sem_t
| Semaphore data type (opaque structure)

## Functions
int | xbt_os_thread_atfork (void(*prepare)(void), void(*parent)(void), void(*child)(void))
int | xbt_os_get_numcores (void)
| Returns the amount of cores on the current host.

## 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.

## Function Documentation

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)