int auto_restart);
XBT_PUBLIC(void) simcall_process_kill(smx_process_t process);
-XBT_PUBLIC(void) simcall_process_killall(void);
+XBT_PUBLIC(void) simcall_process_killall(int reset_pid);
/* Process handling */
XBT_PUBLIC(void) simcall_process_cleanup(smx_process_t process);
#ifdef MSG_USE_DEPRECATED
msg_global->max_channel = 0;
#endif
- msg_global->PID = 1;
msg_global->sent_msg = 0;
msg_global->task_copy_callback = NULL;
msg_global->process_data_cleanup = NULL;
*/
int MSG_process_killall(int reset_PIDs)
{
- simcall_process_killall();
+ simcall_process_killall(reset_PIDs);
- if (reset_PIDs > 0) {
- msg_global->PID = reset_PIDs;
+ if (reset_PIDs > 0)
msg_global->session++;
- }
- return msg_global->PID;
+ return 0;
}
typedef struct simdata_process {
msg_host_t m_host; /* the host on which the process is running */
- int PID; /* used for debugging purposes */
- int PPID; /* The parent PID */
msg_host_t put_host; /* used for debugging purposes */
#ifdef MSG_USE_DEPRECATED
m_channel_t put_channel; /* used for debugging purposes */
#ifdef MSG_USE_DEPRECATED
int max_channel;
#endif
- int PID;
int session;
unsigned long int sent_msg; /* Total amount of messages sent during the simulation */
void (*task_copy_callback) (msg_task_t task, msg_process_t src, msg_process_t dst);
msg_process_t process;
/* Simulator data for MSG */
- simdata->PID = msg_global->PID++;
simdata->waiting_action = NULL;
simdata->waiting_task = NULL;
simdata->m_host = host;
simdata->data = data;
simdata->last_errno = MSG_OK;
- if (SIMIX_process_self()) {
- simdata->PPID = MSG_process_get_PID(MSG_process_self());
- } else {
- simdata->PPID = -1;
- }
-
-#ifdef HAVE_TRACING
- TRACE_msg_process_create(name, simdata->PID, simdata->m_host);
-#endif
/* Let's create the process: SIMIX may decide to start it right now,
* even before returning the flow control to us */
simcall_process_create(&process, name, code, simdata, sg_host_name(host), -1,
argc, argv, properties,0);
+ #ifdef HAVE_TRACING
+ TRACE_msg_process_create(name, simcall_process_get_PID(process), simdata->m_host);
+ #endif
+
if (!process) {
/* Undo everything we have just changed */
- msg_global->PID--;
xbt_free(simdata);
return NULL;
}
if (process == NULL) {
return 0;
}
-
- simdata_process_t simdata = simcall_process_get_data(process);
-
- return simdata != NULL ? simdata->PID : 0;
+ return simcall_process_get_PID(process);
}
/** \ingroup m_process_management
{
xbt_assert(process != NULL, "Invalid parameter");
- simdata_process_t simdata = simcall_process_get_data(process);
-
- return simdata->PPID;
+ return simcall_process_get_PPID(process);
}
/** \ingroup m_process_management
#endif
/* Kill everyone (except maestro) */
- SIMIX_process_killall(simix_global->maestro_process);
+ SIMIX_process_killall(simix_global->maestro_process, 1);
/* Exit the SIMIX network module */
SIMIX_network_exit();
maestro->context = SIMIX_context_new(NULL, 0, NULL, NULL, maestro);
maestro->simcall.issuer = maestro;
+ if (SIMIX_process_self()) {
+ maestro->ppid = SIMIX_process_get_PID(SIMIX_process_self());
+ } else {
+ maestro->ppid = -1;
+ }
+
simix_global->maestro_process = maestro;
return;
}
(*process)->comms = xbt_fifo_new();
(*process)->simcall.issuer = *process;
+ if (SIMIX_process_self()) {
+ (*process)->ppid = SIMIX_process_get_PID(SIMIX_process_self());
+ } else {
+ (*process)->ppid = -1;
+ }
+
/* Process data for auto-restart */
(*process)->auto_restart = auto_restart;
(*process)->code = code;
}
-void SIMIX_pre_process_killall(smx_simcall_t simcall) {
- SIMIX_process_killall(simcall->issuer);
+void SIMIX_pre_process_killall(smx_simcall_t simcall, int reset_pid) {
+ SIMIX_process_killall(simcall->issuer, reset_pid);
}
/**
* \brief Kills all running processes.
* \param issuer this one will not be killed
*/
-void SIMIX_process_killall(smx_process_t issuer)
+void SIMIX_process_killall(smx_process_t issuer, int reset_pid)
{
smx_process_t p = NULL;
}
}
+ if (reset_pid > 0)
+ simix_process_maxpid = reset_pid;
+
SIMIX_context_runall();
SIMIX_process_empty_trash();
return xbt_swag_size(simix_global->process_list);
}
+int SIMIX_pre_process_get_PID(smx_simcall_t simcall, smx_process_t self){
+ return SIMIX_process_get_PID(self);
+}
+
+int SIMIX_process_get_PID(smx_process_t self){
+ if (self == NULL)
+ return 0;
+ else
+ return self->pid;
+}
+
+int SIMIX_pre_process_get_PPID(smx_simcall_t simcall, smx_process_t self){
+ return SIMIX_process_get_PPID(self);
+}
+
+int SIMIX_process_get_PPID(smx_process_t self){
+ if (self == NULL)
+ return 0;
+ else
+ return self->ppid;
+}
+
void* SIMIX_pre_process_self_get_data(smx_simcall_t simcall, smx_process_t self){
return SIMIX_process_self_get_data(self);
}
s_xbt_swag_hookup_t destroy_hookup;
unsigned long pid;
+ unsigned long ppid;
char *name; /**< @brief process name if any */
smx_host_t smx_host; /* the host on which the process is running */
smx_context_t context; /* the context (uctx/raw/thread) that executes the user function */
int auto_restart);
void SIMIX_process_runall(void);
void SIMIX_process_kill(smx_process_t process, smx_process_t issuer);
-void SIMIX_process_killall(smx_process_t issuer);
+void SIMIX_process_killall(smx_process_t issuer, int reset_pid);
smx_process_t SIMIX_process_create_from_wrapper(smx_process_arg_t args);
void SIMIX_create_maestro_process(void);
void SIMIX_process_stop(smx_process_t arg);
void SIMIX_pre_process_suspend(smx_simcall_t simcall, smx_process_t process);
smx_action_t SIMIX_process_suspend(smx_process_t process, smx_process_t issuer);
void SIMIX_process_resume(smx_process_t process, smx_process_t issuer);
+int SIMIX_process_get_PID(smx_process_t self);
void* SIMIX_process_get_data(smx_process_t process);
void SIMIX_process_set_data(smx_process_t process, void *data);
smx_host_t SIMIX_process_get_host(smx_process_t process);
const char *hostname, double kill_time, int argc,
char **argv, xbt_dict_t properties, int auto_restart);
void SIMIX_pre_process_kill(smx_simcall_t simcall, smx_process_t process);
-void SIMIX_pre_process_killall(smx_simcall_t simcall);
+void SIMIX_pre_process_killall(smx_simcall_t simcall, int reset_pid);
void SIMIX_pre_process_cleanup(smx_simcall_t simcall, smx_process_t process);
void SIMIX_pre_process_resume(smx_simcall_t simcall, smx_process_t process);
int SIMIX_pre_process_count(smx_simcall_t simcall);
void* SIMIX_pre_process_self_get_data(smx_simcall_t simcall, smx_process_t process);
+int SIMIX_pre_process_get_PID(smx_simcall_t simcall, smx_process_t self);
void* SIMIX_pre_process_get_data(smx_simcall_t simcall, smx_process_t process);
void SIMIX_pre_process_set_data(smx_simcall_t simcall, smx_process_t process,
void *data);
ACTION(SIMCALL_HOST_EXECUTION_WAIT, host_execution_wait, WITHOUT_ANSWER, TINT(result), TSPEC(execution, smx_action_t)) sep \
ACTION(SIMCALL_PROCESS_CREATE, process_create, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t*), TSTRING(name), TSPEC(code, xbt_main_func_t), TPTR(data), TSTRING(hostname), TDOUBLE(kill_time), TINT(argc), TSPEC(argv, char**), TSPEC(properties, xbt_dict_t), TINT(auto_restart)) sep \
ACTION(SIMCALL_PROCESS_KILL, process_kill, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
-ACTION(SIMCALL_PROCESS_KILLALL, process_killall, WITH_ANSWER, TVOID(result)) sep \
+ACTION(SIMCALL_PROCESS_KILLALL, process_killall, WITH_ANSWER, TVOID(result), TINT(reset_pid)) sep \
ACTION(SIMCALL_PROCESS_CLEANUP, process_cleanup, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
ACTION(SIMCALL_PROCESS_CHANGE_HOST, process_change_host, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t), TSPEC(dest, smx_host_t)) sep \
ACTION(SIMCALL_PROCESS_SUSPEND, process_suspend, WITHOUT_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
ACTION(SIMCALL_PROCESS_RESUME, process_resume, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
ACTION(SIMCALL_PROCESS_COUNT, process_count, WITH_ANSWER, TINT(result)) sep \
+ACTION(SIMCALL_PROCESS_GET_PID, process_get_PID, WITH_ANSWER, TINT(result), TSPEC(process, smx_process_t)) sep \
+ACTION(SIMCALL_PROCESS_GET_PPID, process_get_PPID, WITH_ANSWER, TINT(result), TSPEC(process, smx_process_t)) sep \
ACTION(SIMCALL_PROCESS_GET_DATA, process_get_data, WITH_ANSWER, TPTR(result), TSPEC(process, smx_process_t)) sep \
ACTION(SIMCALL_PROCESS_SET_DATA, process_set_data, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t), TPTR(data)) sep \
ACTION(SIMCALL_PROCESS_GET_HOST, process_get_host, WITH_ANSWER, TSPEC(result, smx_host_t), TSPEC(process, smx_process_t)) sep \
* \ingroup simix_process_management
* \brief Kills all SIMIX processes.
*/
-void simcall_process_killall(void)
+void simcall_process_killall(int reset_pid)
{
- simcall_BODY_process_killall();
+ simcall_BODY_process_killall(reset_pid);
}
/**
return simcall_BODY_process_count();
}
+/**
+ * \ingroup simix_process_management
+ * \brief Return the PID of a #smx_process_t.
+ * \param process a SIMIX process
+ * \return the PID of this process
+ */
+int simcall_process_get_PID(smx_process_t process)
+{
+ if (process == SIMIX_process_self()) {
+ /* avoid a simcall if this function is called by the process itself */
+ return SIMIX_process_get_PID(process);
+ }
+
+ return simcall_BODY_process_get_PID(process);
+}
+
+/**
+ * \ingroup simix_process_management
+ * \brief Return the parent PID of a #smx_process_t.
+ * \param process a SIMIX process
+ * \return the PID of this process parenrt
+ */
+int simcall_process_get_PPID(smx_process_t process)
+{
+ if (process == SIMIX_process_self()) {
+ /* avoid a simcall if this function is called by the process itself */
+ return SIMIX_process_get_PPID(process);
+ }
+
+ return simcall_BODY_process_get_PPID(process);
+}
+
/**
* \ingroup simix_process_management
* \brief Return the user data of a #smx_process_t.
-! output sort
$ msg/pid ${srcdir:=.}/msg/pid.xml 0 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:sendpid@toto) Sending pid of "1".
> [ 0.000000] (2:sendpid@toto) Sending pid of "2".
> [ 0.003247] (3:sendpid@toto) Process "3" killed.
$ msg/pid ${srcdir:=.}/msg/pid.xml 2 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [ 0.000000] (10:sendpid@toto) Sending pid of "2".
-> [ 0.000000] (11:sendpid@toto) Sending pid of "3".
-> [ 0.000000] (12:sendpid@toto) Sending pid of "4".
-> [ 0.001082] (13:killall@toto) Killing process "2".
-> [ 0.001082] (1:sendpid@toto) Send of pid "2" done.
-> [ 0.001082] (1:sendpid@toto) Process "2" killed.
-> [ 0.002165] (2:sendpid@toto) Send of pid "3" done.
-> [ 0.002165] (4:killall@toto) Killing process "3".
-> [ 0.002165] (2:sendpid@toto) Process "3" killed.
-> [ 0.003247] (3:sendpid@toto) Send of pid "4" done.
-> [ 0.003247] (4:killall@toto) Killing process "4".
-> [ 0.003247] (3:sendpid@toto) Process "4" killed.
+> [ 0.000000] (2:sendpid@toto) Sending pid of "2".
+> [ 0.000000] (3:sendpid@toto) Sending pid of "3".
+> [ 0.000000] (4:sendpid@toto) Sending pid of "4".
+> [ 0.001082] (5:killall@toto) Killing process "2".
+> [ 0.001082] (2:sendpid@toto) Send of pid "2" done.
+> [ 0.001082] (2:sendpid@toto) Process "2" killed.
+> [ 0.002165] (3:sendpid@toto) Send of pid "3" done.
+> [ 0.002165] (5:killall@toto) Killing process "3".
+> [ 0.002165] (3:sendpid@toto) Process "3" killed.
+> [ 0.003247] (4:sendpid@toto) Send of pid "4" done.
+> [ 0.003247] (5:killall@toto) Killing process "4".
+> [ 0.003247] (4:sendpid@toto) Process "4" killed.