SimGrid  3.16
Versatile Simulation of Distributed Systems
ActorImpl.cpp File Reference
#include <exception>
#include <functional>
#include <string>
#include <utility>
#include <boost/range/algorithm.hpp>
#include "xbt/dict.h"
#include "xbt/ex.hpp"
#include "xbt/functional.hpp"
#include "xbt/log.h"
#include "xbt/sysdep.h"
#include "simgrid/s4u/Host.hpp"
#include "mc/mc.h"
#include "smx_private.h"
#include "src/kernel/activity/SleepImpl.hpp"
#include "src/kernel/activity/SynchroIo.hpp"
#include "src/kernel/activity/SynchroRaw.hpp"
#include "src/mc/mc_replay.h"
#include "src/mc/remote/Client.hpp"
#include "src/msg/msg_private.h"
#include "src/surf/cpu_interface.hpp"
#include "src/surf/surf_interface.hpp"

Namespaces

 simgrid
 Alltoall Bruck.
 
 simgrid::simix
 

Functions

 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (simix_process, simix, "Logging specific to SIMIX (process)")
 
smx_actor_t SIMIX_process_ref (smx_actor_t process)
 Increase the refcount for this process. More...
 
void SIMIX_process_unref (smx_actor_t process)
 Decrease the refcount for this process. More...
 
smx_actor_t SIMIX_process_self ()
 Returns the current agent. More...
 
int SIMIX_process_has_pending_comms (smx_actor_t process)
 Returns whether a process has pending asynchronous communications. More...
 
void SIMIX_process_cleanup (smx_actor_t process)
 Moves a process to the list of processes to destroy. More...
 
void SIMIX_process_empty_trash ()
 Garbage collection. More...
 
static int simgrid::simix::dying_daemon (void *exit_status, void *data)
 
void simgrid::simix::create_maestro (std::function< void()> code)
 
void SIMIX_maestro_create (void(*code)(void *), void *data)
 Creates and runs the maestro process. More...
 
smx_actor_t SIMIX_process_create (const char *name, std::function< void()> code, void *data, simgrid::s4u::Host *host, xbt_dict_t properties, smx_actor_t parent_process)
 Internal function to create a process. More...
 
smx_actor_t SIMIX_process_attach (const char *name, void *data, const char *hostname, xbt_dict_t properties, smx_actor_t parent_process)
 
void SIMIX_process_detach ()
 
void SIMIX_process_runall ()
 Executes the processes from simix_global->process_to_run. More...
 
void simcall_HANDLER_process_kill (smx_simcall_t simcall, smx_actor_t process)
 
void SIMIX_process_kill (smx_actor_t process, smx_actor_t issuer)
 Internal function to kill a SIMIX process. More...
 
void SIMIX_process_throw (smx_actor_t process, xbt_errcat_t cat, int value, const char *msg)
 Ask another process to raise the given exception. More...
 
void simcall_HANDLER_process_killall (smx_simcall_t simcall, int reset_pid)
 
void SIMIX_process_killall (smx_actor_t issuer, int reset_pid)
 Kills all running processes. More...
 
void simcall_HANDLER_process_set_host (smx_simcall_t simcall, smx_actor_t process, sg_host_t dest)
 
void SIMIX_process_change_host (smx_actor_t process, sg_host_t dest)
 
void simcall_HANDLER_process_suspend (smx_simcall_t simcall, smx_actor_t process)
 
smx_activity_t SIMIX_process_suspend (smx_actor_t process, smx_actor_t issuer)
 
void SIMIX_process_resume (smx_actor_t process)
 
int SIMIX_process_get_maxpid ()
 
int SIMIX_process_count ()
 
int SIMIX_process_get_PID (smx_actor_t self)
 
voidSIMIX_process_self_get_data ()
 
void SIMIX_process_self_set_data (void *data)
 
void SIMIX_process_set_data (smx_actor_t process, void *data)
 
const char * SIMIX_process_self_get_name ()
 
smx_actor_t SIMIX_process_get_by_name (const char *name)
 
int SIMIX_process_is_suspended (smx_actor_t process)
 
xbt_dict_t SIMIX_process_get_properties (smx_actor_t process)
 
void simcall_HANDLER_process_join (smx_simcall_t simcall, smx_actor_t process, double timeout)
 
static int SIMIX_process_join_finish (smx_process_exit_status_t status, void *synchro)
 
smx_activity_t SIMIX_process_join (smx_actor_t issuer, smx_actor_t process, double timeout)
 
void simcall_HANDLER_process_sleep (smx_simcall_t simcall, double duration)
 
smx_activity_t SIMIX_process_sleep (smx_actor_t process, double duration)
 
void SIMIX_process_sleep_destroy (smx_activity_t synchro)
 
void SIMIX_process_yield (smx_actor_t self)
 Calling this function makes the process to yield. More...
 
void SIMIX_process_exception_terminate (xbt_ex_t *e)
 
smx_context_t SIMIX_process_get_context (smx_actor_t p)
 
void SIMIX_process_set_context (smx_actor_t p, smx_context_t c)
 
xbt_dynar_t SIMIX_process_get_runnable ()
 Returns the list of processes to run. More...
 
smx_actor_t SIMIX_process_from_PID (aid_t PID)
 Returns the process from PID. More...
 
xbt_dynar_t SIMIX_processes_as_dynar ()
 returns a dynar containing all currently existing processes More...
 
void SIMIX_process_on_exit_runall (smx_actor_t process)
 
void SIMIX_process_on_exit (smx_actor_t process, int_f_pvoid_pvoid_t fun, void *data)
 
void SIMIX_process_auto_restart_set (smx_actor_t process, int auto_restart)
 Sets the auto-restart status of the process. More...
 
smx_actor_t simcall_HANDLER_process_restart (smx_simcall_t simcall, smx_actor_t process)
 
smx_actor_t SIMIX_process_restart (smx_actor_t process, smx_actor_t issuer)
 Restart a process, starting it again from the beginning. More...
 
void SIMIX_segment_index_set (smx_actor_t proc, int index)
 
smx_actor_t simcall_process_create (const char *name, xbt_main_func_t code, void *data, sg_host_t host, int argc, char **argv, xbt_dict_t properties)
 Creates and runs a new SIMIX process. More...
 
smx_actor_t simcall_process_create (const char *name, std::function< void()> code, void *data, sg_host_t host, xbt_dict_t properties)
 

Variables

unsigned long simix_process_maxpid = 0
 

Function Documentation

◆ XBT_LOG_NEW_DEFAULT_SUBCATEGORY()

XBT_LOG_NEW_DEFAULT_SUBCATEGORY ( simix_process  ,
simix  ,
"Logging specific to SIMIX (process)"   
)

◆ SIMIX_process_ref()

smx_actor_t SIMIX_process_ref ( smx_actor_t  process)

Increase the refcount for this process.

◆ SIMIX_process_unref()

void SIMIX_process_unref ( smx_actor_t  process)

Decrease the refcount for this process.

◆ SIMIX_process_self()

smx_actor_t SIMIX_process_self ( )

Returns the current agent.

This functions returns the currently running SIMIX process.

Returns
The SIMIX process

◆ SIMIX_process_has_pending_comms()

int SIMIX_process_has_pending_comms ( smx_actor_t  process)

Returns whether a process has pending asynchronous communications.

Returns
true if there are asynchronous communications in this process

◆ SIMIX_process_cleanup()

void SIMIX_process_cleanup ( smx_actor_t  process)

Moves a process to the list of processes to destroy.

◆ SIMIX_process_empty_trash()

void SIMIX_process_empty_trash ( )

Garbage collection.

Should be called some time to time to free the memory allocated for processes that have finished (or killed).

◆ SIMIX_maestro_create()

void SIMIX_maestro_create ( void(*)(void *)  code,
void data 
)

Creates and runs the maestro process.

◆ SIMIX_process_create()

smx_actor_t SIMIX_process_create ( const char *  name,
std::function< void()>  code,
void data,
simgrid::s4u::Host host,
xbt_dict_t  properties,
smx_actor_t  parent_process 
)

Internal function to create a process.

This function actually creates the process. It may be called when a SIMCALL_PROCESS_CREATE simcall occurs, or directly for SIMIX internal purposes. The sure thing is that it's called from maestro context.

Returns
the process created

◆ SIMIX_process_attach()

smx_actor_t SIMIX_process_attach ( const char *  name,
void data,
const char *  hostname,
xbt_dict_t  properties,
smx_actor_t  parent_process 
)

◆ SIMIX_process_detach()

void SIMIX_process_detach ( )

◆ SIMIX_process_runall()

void SIMIX_process_runall ( )

Executes the processes from simix_global->process_to_run.

The processes of simix_global->process_to_run are run (in parallel if possible). On exit, simix_global->process_to_run is empty, and simix_global->process_that_ran contains the list of processes that just ran. The two lists are swapped so, be careful when using them before and after a call to this function.

◆ simcall_HANDLER_process_kill()

void simcall_HANDLER_process_kill ( smx_simcall_t  simcall,
smx_actor_t  process 
)

◆ SIMIX_process_kill()

void SIMIX_process_kill ( smx_actor_t  process,
smx_actor_t  issuer 
)

Internal function to kill a SIMIX process.

This function may be called when a SIMCALL_PROCESS_KILL simcall occurs, or directly for SIMIX internal purposes.

Parameters
processpoor victim
issuerthe process which has sent the PROCESS_KILL. Important to not schedule twice the same process.

◆ SIMIX_process_throw()

void SIMIX_process_throw ( smx_actor_t  process,
xbt_errcat_t  cat,
int  value,
const char *  msg 
)

Ask another process to raise the given exception.

Parameters
processThe process that should raise that exception
catcategory of exception
valuevalue associated to the exception
msgstring information associated to the exception

◆ simcall_HANDLER_process_killall()

void simcall_HANDLER_process_killall ( smx_simcall_t  simcall,
int  reset_pid 
)

◆ SIMIX_process_killall()

void SIMIX_process_killall ( smx_actor_t  issuer,
int  reset_pid 
)

Kills all running processes.

Parameters
issuerthis one will not be killed

◆ simcall_HANDLER_process_set_host()

void simcall_HANDLER_process_set_host ( smx_simcall_t  simcall,
smx_actor_t  process,
sg_host_t  dest 
)

◆ SIMIX_process_change_host()

void SIMIX_process_change_host ( smx_actor_t  process,
sg_host_t  dest 
)

◆ simcall_HANDLER_process_suspend()

void simcall_HANDLER_process_suspend ( smx_simcall_t  simcall,
smx_actor_t  process 
)

◆ SIMIX_process_suspend()

smx_activity_t SIMIX_process_suspend ( smx_actor_t  process,
smx_actor_t  issuer 
)

◆ SIMIX_process_resume()

void SIMIX_process_resume ( smx_actor_t  process)

◆ SIMIX_process_get_maxpid()

int SIMIX_process_get_maxpid ( )

◆ SIMIX_process_count()

int SIMIX_process_count ( )

◆ SIMIX_process_get_PID()

int SIMIX_process_get_PID ( smx_actor_t  self)

◆ SIMIX_process_self_get_data()

void* SIMIX_process_self_get_data ( )

◆ SIMIX_process_self_set_data()

void SIMIX_process_self_set_data ( void data)

◆ SIMIX_process_set_data()

void SIMIX_process_set_data ( smx_actor_t  process,
void data 
)

◆ SIMIX_process_self_get_name()

const char* SIMIX_process_self_get_name ( )

◆ SIMIX_process_get_by_name()

smx_actor_t SIMIX_process_get_by_name ( const char *  name)

◆ SIMIX_process_is_suspended()

int SIMIX_process_is_suspended ( smx_actor_t  process)

◆ SIMIX_process_get_properties()

xbt_dict_t SIMIX_process_get_properties ( smx_actor_t  process)

◆ simcall_HANDLER_process_join()

void simcall_HANDLER_process_join ( smx_simcall_t  simcall,
smx_actor_t  process,
double  timeout 
)

◆ SIMIX_process_join_finish()

static int SIMIX_process_join_finish ( smx_process_exit_status_t  status,
void synchro 
)
static

◆ SIMIX_process_join()

smx_activity_t SIMIX_process_join ( smx_actor_t  issuer,
smx_actor_t  process,
double  timeout 
)

◆ simcall_HANDLER_process_sleep()

void simcall_HANDLER_process_sleep ( smx_simcall_t  simcall,
double  duration 
)

◆ SIMIX_process_sleep()

smx_activity_t SIMIX_process_sleep ( smx_actor_t  process,
double  duration 
)

◆ SIMIX_process_sleep_destroy()

void SIMIX_process_sleep_destroy ( smx_activity_t  synchro)

◆ SIMIX_process_yield()

void SIMIX_process_yield ( smx_actor_t  self)

Calling this function makes the process to yield.

Only the current process can call this function, giving back the control to maestro.

Parameters
selfthe current process

◆ SIMIX_process_exception_terminate()

void SIMIX_process_exception_terminate ( xbt_ex_t e)

◆ SIMIX_process_get_context()

smx_context_t SIMIX_process_get_context ( smx_actor_t  p)

◆ SIMIX_process_set_context()

void SIMIX_process_set_context ( smx_actor_t  p,
smx_context_t  c 
)

◆ SIMIX_process_get_runnable()

xbt_dynar_t SIMIX_process_get_runnable ( )

Returns the list of processes to run.

◆ SIMIX_process_from_PID()

smx_actor_t SIMIX_process_from_PID ( aid_t  PID)

Returns the process from PID.

◆ SIMIX_processes_as_dynar()

xbt_dynar_t SIMIX_processes_as_dynar ( )

returns a dynar containing all currently existing processes

◆ SIMIX_process_on_exit_runall()

void SIMIX_process_on_exit_runall ( smx_actor_t  process)

◆ SIMIX_process_on_exit()

void SIMIX_process_on_exit ( smx_actor_t  process,
int_f_pvoid_pvoid_t  fun,
void data 
)

◆ SIMIX_process_auto_restart_set()

void SIMIX_process_auto_restart_set ( smx_actor_t  process,
int  auto_restart 
)

Sets the auto-restart status of the process.

If set to 1, the process will be automatically restarted when its host comes back.

◆ simcall_HANDLER_process_restart()

smx_actor_t simcall_HANDLER_process_restart ( smx_simcall_t  simcall,
smx_actor_t  process 
)

◆ SIMIX_process_restart()

smx_actor_t SIMIX_process_restart ( smx_actor_t  process,
smx_actor_t  issuer 
)

Restart a process, starting it again from the beginning.

◆ SIMIX_segment_index_set()

void SIMIX_segment_index_set ( smx_actor_t  proc,
int  index 
)

◆ simcall_process_create()

smx_actor_t simcall_process_create ( const char *  name,
std::function< void()>  code,
void data,
sg_host_t  host,
xbt_dict_t  properties 
)

Variable Documentation

◆ simix_process_maxpid

unsigned long simix_process_maxpid = 0