SimGrid  3.13
Versatile Simulation of Distributed Systems
smx_context.cpp File Reference
#include "src/internal_config.h"
#include "xbt/log.h"
#include "xbt/swag.h"
#include "xbt/xbt_os_thread.h"
#include "smx_private.h"
#include "smx_private.hpp"
#include "simgrid/sg_config.h"
#include "simgrid/modelchecker.h"
#include <sys/mman.h>

Functions

 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (simix_context, simix,"Context switching mechanism")
 
void SIMIX_context_mod_init (void)
 This function is called by SIMIX_global_init() to initialize the context module. More...
 
void SIMIX_context_mod_exit (void)
 This function is called by SIMIX_clean() to finalize the context module. More...
 
voidSIMIX_context_stack_new (void)
 
void SIMIX_context_stack_delete (void *stack)
 
int SIMIX_context_is_parallel (void)
 Returns whether some parallel threads are used for the user contexts. More...
 
int SIMIX_context_get_nthreads (void)
 Returns the number of parallel threads used for the user contexts. More...
 
void SIMIX_context_set_nthreads (int nb_threads)
 Sets the number of parallel threads to use for the user contexts. More...
 
int SIMIX_context_get_parallel_threshold (void)
 Returns the threshold above which user processes are run in parallel. More...
 
void SIMIX_context_set_parallel_threshold (int threshold)
 Sets the threshold above which user processes are run in parallel. More...
 
e_xbt_parmap_mode_t SIMIX_context_get_parallel_mode (void)
 Returns the synchronization mode used when processes are run in parallel. More...
 
void SIMIX_context_set_parallel_mode (e_xbt_parmap_mode_t mode)
 Sets the synchronization mode to use when processes are run in parallel. More...
 
smx_context_t SIMIX_context_get_current (void)
 Returns the current context of this thread. More...
 
void SIMIX_context_set_current (smx_context_t context)
 Sets the current context of this thread. More...
 

Variables

char * smx_context_factory_name = NULL
 
int smx_context_stack_size
 
int smx_context_stack_size_was_set = 0
 
int smx_context_guard_size
 
int smx_context_guard_size_was_set = 0
 
static xbt_os_thread_key_t smx_current_context_key = 0
 
static smx_context_t smx_current_context_serial
 
static int smx_parallel_contexts = 1
 
static int smx_parallel_threshold = 2
 
static e_xbt_parmap_mode_t smx_parallel_synchronization_mode = XBT_PARMAP_DEFAULT
 

Function Documentation

XBT_LOG_NEW_DEFAULT_SUBCATEGORY ( simix_context  ,
simix  ,
"Context switching mechanism"   
)
void SIMIX_context_mod_init ( void  )

This function is called by SIMIX_global_init() to initialize the context module.

void SIMIX_context_mod_exit ( void  )

This function is called by SIMIX_clean() to finalize the context module.

void* SIMIX_context_stack_new ( void  )
void SIMIX_context_stack_delete ( void stack)
int SIMIX_context_is_parallel ( void  )

Returns whether some parallel threads are used for the user contexts.

int SIMIX_context_get_nthreads ( void  )

Returns the number of parallel threads used for the user contexts.

Returns
the number of threads (1 means no parallelism)
void SIMIX_context_set_nthreads ( int  nb_threads)

Sets the number of parallel threads to use for the user contexts.

This function should be called before initializing SIMIX. A value of 1 means no parallelism (1 thread only). If the value is greater than 1, the thread support must be enabled.

Parameters
nb_threadsthe number of threads to use
int SIMIX_context_get_parallel_threshold ( void  )

Returns the threshold above which user processes are run in parallel.

If the number of threads is set to 1, there is no parallelism and this threshold has no effect.

Returns
when the number of user processes ready to run is above this threshold, they are run in parallel
void SIMIX_context_set_parallel_threshold ( int  threshold)

Sets the threshold above which user processes are run in parallel.

If the number of threads is set to 1, there is no parallelism and this threshold has no effect.

Parameters
thresholdwhen the number of user processes ready to run is above this threshold, they are run in parallel
e_xbt_parmap_mode_t SIMIX_context_get_parallel_mode ( void  )

Returns the synchronization mode used when processes are run in parallel.

Returns
how threads are synchronized if processes are run in parallel
void SIMIX_context_set_parallel_mode ( e_xbt_parmap_mode_t  mode)

Sets the synchronization mode to use when processes are run in parallel.

Parameters
modehow to synchronize threads if processes are run in parallel
smx_context_t SIMIX_context_get_current ( void  )

Returns the current context of this thread.

Returns
the current context of this thread
void SIMIX_context_set_current ( smx_context_t  context)

Sets the current context of this thread.

Parameters
contextthe context to set

Variable Documentation

char* smx_context_factory_name = NULL
int smx_context_stack_size
int smx_context_stack_size_was_set = 0
int smx_context_guard_size
int smx_context_guard_size_was_set = 0
xbt_os_thread_key_t smx_current_context_key = 0
static
smx_context_t smx_current_context_serial
static
int smx_parallel_contexts = 1
static
int smx_parallel_threshold = 2
static
e_xbt_parmap_mode_t smx_parallel_synchronization_mode = XBT_PARMAP_DEFAULT
static