1 #include "smx_private.h"
3 #include "xbt/xbt_os_thread.h"
4 #include "../mc/mc_private.h"
6 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_smurf, simix,
7 "Logging specific to SIMIX (SMURF)");
9 XBT_INLINE smx_simcall_t SIMIX_simcall_mine()
11 smx_process_t issuer = SIMIX_process_self();
12 return &issuer->simcall;
16 * \brief Makes the current process do a simcall to the kernel and yields
17 * until completion. If the current thread is maestro, we don't yield and
18 * execute the simcall directly.
19 * \param self the current process
21 void SIMIX_simcall_push(smx_process_t self)
23 if (self != simix_global->maestro_process) {
24 XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
25 SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
26 SIMIX_process_yield(self);
28 XBT_DEBUG("I'm the maestro, execute the simcall directly");
29 SIMIX_simcall_pre(&self->simcall, 0);
33 void SIMIX_simcall_answer(smx_simcall_t simcall)
35 if (simcall->issuer != simix_global->maestro_process){
36 XBT_DEBUG("Answer simcall %s (%d) issued by %s (%p)", SIMIX_simcall_name(simcall->call), (int)simcall->call,
37 simcall->issuer->name, simcall->issuer);
38 simcall->issuer->simcall.call = SIMCALL_NONE;
39 /* This check should be useless and slows everyone. Reactivate if you see something
40 * weird in process scheduling.
42 /* if(!xbt_dynar_member(simix_global->process_to_run, &(simcall->issuer))) */
43 xbt_dynar_push_as(simix_global->process_to_run, smx_process_t, simcall->issuer);
44 /* else DIE_IMPOSSIBLE; */
48 void SIMIX_simcall_pre(smx_simcall_t simcall, int value)
50 XBT_DEBUG("Handling simcall %p: %s", simcall, SIMIX_simcall_name(simcall->call));
51 simcall->mc_value = value;
52 switch (simcall->call) {
53 SIMCALL_LIST(SIMCALL_CASE, SIMCALL_SEP_NOTHING)
57 THROWF(arg_error,0,"Asked to do the noop syscall on %s@%s",
58 SIMIX_process_get_name(simcall->issuer),
59 SIMIX_host_get_name(SIMIX_process_get_host(simcall->issuer))
63 /* ****************************************************************************************** */
64 /* TUTORIAL: New API */
65 /* ****************************************************************************************** */
66 case SIMCALL_NEW_API_INIT:
67 SIMIX_pre_new_api_fct(simcall);
72 void SIMIX_simcall_post(smx_action_t action)
74 switch (action->type) {
76 case SIMIX_ACTION_EXECUTE:
77 case SIMIX_ACTION_PARALLEL_EXECUTE:
78 SIMIX_post_host_execute(action);
81 case SIMIX_ACTION_COMMUNICATE:
82 SIMIX_post_comm(action);
85 case SIMIX_ACTION_SLEEP:
86 SIMIX_post_process_sleep(action);
89 case SIMIX_ACTION_SYNCHRO:
90 SIMIX_post_synchro(action);
94 SIMIX_post_io(action);
97 /* ****************************************************************************************** */
98 /* TUTORIAL: New API */
99 /* ****************************************************************************************** */
100 case SIMIX_ACTION_NEW_API:
101 SIMIX_post_new_api(action);
106 /* New Simcal interface */
108 /* FIXME: add types for every simcall */
109 //const char *simcall_types[NUM_SIMCALLS] = { [SIMCALL_HOST_EXECUTE] = "%s%p%f%f%p" };
110 /* FIXME find a way to make this work
111 simcall_handler_t simcall_table[NUM_SIMCALLS] = {
112 #undef SIMCALL_ENUM_ELEMENT
113 #define SIMCALL_ENUM_ELEMENT(x,y) &y // generate strings from the enumeration values
115 #undef SIMCALL_ENUM_ELEMENT
118 /* New Simcal interface */
120 /* FIXME: add types for every simcall */
121 //const char *simcall_types[NUM_SIMCALLS] = { [SIMCALL_HOST_EXECUTE] = "%s%p%f%f%p", [SIMCALL_HOST_EXECUTION_WAIT] = "%p%p" };
124 /*TOFIX find a way to make this work
125 simcall_handler_t simcall_table[NUM_SIMCALLS] = {
126 #undef SIMCALL_ENUM_ELEMENT
127 #define SIMCALL_ENUM_ELEMENT(x,y) &y // generate strings from the enumeration values
129 #undef SIMCALL_ENUM_ELEMENT