SimGrid  3.18
Versatile Simulation of Distributed Systems
xbt_os_thread.c File Reference
#include "src/internal_config.h"
#include <pthread.h>
#include <limits.h>
#include <semaphore.h>
#include <errno.h>
#include <unistd.h>
#include "xbt/sysdep.h"
#include "xbt/ex.h"
#include "xbt/xbt_os_time.h"
#include "xbt/xbt_os_thread.h"
#include "src/xbt_modinter.h"
#include <sched.h>
#include <time.h>
#include <math.h>

Classes

struct  xbt_os_thread_
 
struct  xbt_os_mutex_
 
struct  xbt_os_cond_
 
struct  xbt_os_sem_
 

Macros

#define SEM_FAILED   (-1)
 

Typedefs

typedef struct xbt_os_thread_ s_xbt_os_thread_t
 
typedef struct xbt_os_mutex_ s_xbt_os_mutex_t
 
typedef struct xbt_os_cond_ s_xbt_os_cond_t
 
typedef struct xbt_os_sem_ s_xbt_os_sem_t
 

Functions

 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (xbt_sync_os, xbt, "Synchronization mechanism (OS-level)")
 
static void xbt_os_thread_free_thread_data (xbt_os_thread_t thread)
 
void xbt_os_thread_mod_preinit (void)
 
void xbt_os_thread_mod_postexit (void)
 
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...
 
static voidwrapper_start_routine (void *s)
 
xbt_os_thread_t xbt_os_thread_create (const char *name, pvoid_f_pvoid_t start_routine, void *param, void *extra_data)
 
int xbt_os_thread_bind (XBT_ATTRIB_UNUSED xbt_os_thread_t thread, XBT_ATTRIB_UNUSED int cpu)
 Bind the thread to the given core, if possible. More...
 
void xbt_os_thread_setstacksize (int stack_size)
 
void xbt_os_thread_setguardsize (int guard_size)
 
const char * xbt_os_thread_self_name (void)
 
void xbt_os_thread_join (xbt_os_thread_t thread, void **thread_return)
 
void xbt_os_thread_exit (int *retval)
 
xbt_os_thread_t xbt_os_thread_self (void)
 
void xbt_os_thread_key_create (xbt_os_thread_key_t *key)
 
void xbt_os_thread_key_destroy (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_yield (void)
 
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)
 
int xbt_os_get_numcores (void)
 Returns the amount of cores on the current host. More...
 
void xbt_os_thread_set_extra_data (void *data)
 
voidxbt_os_thread_get_extra_data (void)
 

Variables

static int next_sem_ID = 0
 
static xbt_os_mutex_t next_sem_ID_lock
 
static xbt_os_thread_t main_thread = NULL
 
static pthread_key_t xbt_self_thread_key
 
static int thread_mod_inited = 0
 
static pthread_attr_t thread_attr
 

Macro Definition Documentation

◆ SEM_FAILED

#define SEM_FAILED   (-1)

Typedef Documentation

◆ s_xbt_os_thread_t

◆ s_xbt_os_mutex_t

◆ s_xbt_os_cond_t

typedef struct xbt_os_cond_ s_xbt_os_cond_t

◆ s_xbt_os_sem_t

typedef struct xbt_os_sem_ s_xbt_os_sem_t

Function Documentation

◆ XBT_LOG_NEW_DEFAULT_SUBCATEGORY()

XBT_LOG_NEW_DEFAULT_SUBCATEGORY ( xbt_sync_os  ,
xbt  ,
"Synchronization mechanism (OS-level)"   
)

◆ xbt_os_thread_free_thread_data()

static void xbt_os_thread_free_thread_data ( xbt_os_thread_t  thread)
static

◆ xbt_os_thread_mod_preinit()

void xbt_os_thread_mod_preinit ( void  )

◆ xbt_os_thread_mod_postexit()

void xbt_os_thread_mod_postexit ( void  )

◆ wrapper_start_routine()

static void* wrapper_start_routine ( void s)
static

◆ xbt_os_thread_bind()

int xbt_os_thread_bind ( XBT_ATTRIB_UNUSED xbt_os_thread_t  thread,
XBT_ATTRIB_UNUSED 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.

Variable Documentation

◆ next_sem_ID

int next_sem_ID = 0
static

◆ next_sem_ID_lock

xbt_os_mutex_t next_sem_ID_lock
static

◆ main_thread

xbt_os_thread_t main_thread = NULL
static

◆ xbt_self_thread_key

pthread_key_t xbt_self_thread_key
static

◆ thread_mod_inited

int thread_mod_inited = 0
static

◆ thread_attr

pthread_attr_t thread_attr
static