+void SIMIX_process_killall(smx_process_t issuer, int reset_pid)
+{
+ smx_process_t p = NULL;
+
+ while ((p = xbt_swag_extract(simix_global->process_list))) {
+ if (p != issuer) {
+ SIMIX_process_kill(p,issuer);
+ }
+ }
+
+ if (reset_pid > 0)
+ simix_process_maxpid = reset_pid;
+
+ SIMIX_context_runall();
+
+ SIMIX_process_empty_trash();
+}
+
+void SIMIX_pre_process_change_host(smx_simcall_t simcall, smx_process_t process,
+ smx_host_t dest)
+{
+ process->new_host = dest;
+}
+void SIMIX_process_change_host(smx_process_t process,
+ smx_host_t dest)
+{
+ xbt_assert((process != NULL), "Invalid parameters");
+ xbt_swag_remove(process, SIMIX_host_priv(process->smx_host)->process_list);
+ process->smx_host = dest;
+ xbt_swag_insert(process, SIMIX_host_priv(dest)->process_list);
+}
+
+
+void SIMIX_pre_process_suspend(smx_simcall_t simcall, smx_process_t process)
+{
+ smx_action_t action_suspend =
+ SIMIX_process_suspend(process, simcall->issuer);
+
+ if (process != simcall->issuer) {
+ SIMIX_simcall_answer(simcall);
+ } else {
+ xbt_fifo_push(action_suspend->simcalls, simcall);
+ process->waiting_action = action_suspend;
+ SIMIX_host_execution_suspend(process->waiting_action);
+ }
+ /* If we are suspending ourselves, then just do not finish the simcall now */
+}
+
+smx_action_t SIMIX_process_suspend(smx_process_t process, smx_process_t issuer)
+{
+ xbt_assert((process != NULL), "Invalid parameters");
+
+ if (process->suspended) {
+ XBT_DEBUG("Process '%s' is already suspended", process->name);
+ return NULL;
+ }
+
+ process->suspended = 1;
+
+ /* If we are suspending another process, and it is waiting on an action,
+ suspend its action. */
+ if (process != issuer) {
+
+ if (process->waiting_action) {
+
+ switch (process->waiting_action->type) {
+
+ case SIMIX_ACTION_EXECUTE:
+ case SIMIX_ACTION_PARALLEL_EXECUTE:
+ SIMIX_host_execution_suspend(process->waiting_action);
+ break;
+
+ case SIMIX_ACTION_COMMUNICATE:
+ SIMIX_comm_suspend(process->waiting_action);
+ break;
+
+ case SIMIX_ACTION_SLEEP:
+ SIMIX_process_sleep_suspend(process->waiting_action);
+ break;
+
+ case SIMIX_ACTION_SYNCHRO:
+ /* Suspension is delayed to when the process is rescheduled. */
+ break;
+
+ default:
+ xbt_die("Internal error in SIMIX_process_suspend: unexpected action type %d",
+ (int)process->waiting_action->type);
+ }
+ return NULL;
+ } else {
+ /* Suspension is delayed to when the process is rescheduled. */
+ return NULL;
+ }
+ } else {
+ /* FIXME: computation size is zero. Is it okay that bound is zero ? */
+ return SIMIX_host_execute("suspend", process->smx_host, 0.0, 1.0, 0.0, 0);
+ }
+}
+
+void SIMIX_pre_process_resume(smx_simcall_t simcall, smx_process_t process){
+ SIMIX_process_resume(process, simcall->issuer);
+}
+
+void SIMIX_process_resume(smx_process_t process, smx_process_t issuer)
+{
+ XBT_IN("process = %p, issuer = %p", process, issuer);
+
+ if(process->context->iwannadie) {
+ XBT_VERB("Ignoring request to suspend a process that is currently dying.");
+ return;
+ }
+
+ if(!process->suspended) return;
+ process->suspended = 0;
+
+ /* If we are resuming another process, resume the action it was waiting for
+ if any. Otherwise add it to the list of process to run in the next round. */
+ if (process != issuer) {
+
+ if (process->waiting_action) {
+
+ switch (process->waiting_action->type) {
+
+ case SIMIX_ACTION_EXECUTE:
+ case SIMIX_ACTION_PARALLEL_EXECUTE:
+ SIMIX_host_execution_resume(process->waiting_action);
+ break;
+
+ case SIMIX_ACTION_COMMUNICATE:
+ SIMIX_comm_resume(process->waiting_action);
+ break;
+
+ case SIMIX_ACTION_SLEEP:
+ SIMIX_process_sleep_resume(process->waiting_action);
+ break;
+
+ case SIMIX_ACTION_SYNCHRO:
+ /* I cannot resume it now. This is delayed to when the process is rescheduled at
+ * the end of the synchro. */
+ break;
+
+ default:
+ xbt_die("Internal error in SIMIX_process_resume: unexpected action type %d",
+ (int)process->waiting_action->type);
+ }
+ }
+ } else XBT_WARN("Strange. Process %p is trying to resume himself.", issuer);
+
+ XBT_OUT();
+}
+
+int SIMIX_process_get_maxpid(void) {
+ return simix_process_maxpid;
+}
+
+int SIMIX_pre_process_count(smx_simcall_t simcall){
+ return SIMIX_process_count();
+}
+int SIMIX_process_count(void)