X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/39c6a42ab89e515e5be6f68c11cd3ba98b85cb47..6d17036094433f0304c29b6f57922cee32b0c67c:/src/msg/m_process.c diff --git a/src/msg/m_process.c b/src/msg/m_process.c index c3b04d11d3..586e756134 100644 --- a/src/msg/m_process.c +++ b/src/msg/m_process.c @@ -36,25 +36,25 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_process, msg, "Logging specific to MSG (proc * \sa MSG_process_create_with_arguments */ m_process_t MSG_process_create(const char *name, - m_process_code_t code, void *data, + xbt_main_func_t code, void *data, m_host_t host) { return MSG_process_create_with_arguments(name, code, data, host, -1, NULL); } -static void MSG_process_cleanup(void *arg) +void __MSG_process_cleanup(void *arg) { /* arg is a pointer to a simix process, we can get the msg process with the field data */ - m_process_t proc = ((smx_process_t)arg)->data; - xbt_fifo_remove(msg_global->process_list, proc); - SIMIX_process_cleanup(arg); - free(proc->name); - proc->name = NULL; - free(proc->simdata); - proc->simdata = NULL; - free(proc); - - return; + m_process_t proc = ((smx_process_t)arg)->data; + xbt_fifo_remove(msg_global->process_list, proc); + SIMIX_process_cleanup(arg); + free(proc->name); + proc->name = NULL; + free(proc->simdata); + proc->simdata = NULL; + free(proc); + + return; } /** \ingroup m_process_management @@ -85,7 +85,7 @@ static void MSG_process_cleanup(void *arg) m_process_t __MSG_process_create_with_arguments(const char *name, - m_process_code_t code, void *data, + xbt_main_func_t code, void *data, char * hostname, int argc, char **argv) { m_host_t host = MSG_get_host_by_name(hostname); @@ -93,7 +93,7 @@ m_process_t __MSG_process_create_with_arguments(const char *name, } m_process_t MSG_process_create_with_arguments(const char *name, - m_process_code_t code, void *data, + xbt_main_func_t code, void *data, m_host_t host, int argc, char **argv) { simdata_process_t simdata = xbt_new0(s_simdata_process_t,1); @@ -103,15 +103,18 @@ m_process_t MSG_process_create_with_arguments(const char *name, /* Simulator Data */ simdata->PID = msg_global->PID++; simdata->waiting_task = NULL; - simdata->host = host; + simdata->m_host = host; simdata->argc = argc; simdata->argv = argv; - simdata->smx_process = SIMIX_process_create(name, (smx_process_code_t)code, (void*)process, host->name, argc, argv, MSG_process_cleanup ); - - if (SIMIX_process_self()) { - simdata->PPID = MSG_process_get_PID(SIMIX_process_self()->data); - } - else simdata->PPID = -1; + simdata->s_process = SIMIX_process_create(name, code, + (void*)process, host->name, argc, argv, + __MSG_process_cleanup ); + + if (SIMIX_process_self()) { + simdata->PPID = MSG_process_get_PID(SIMIX_process_self()->data); + } else { + simdata->PPID = -1; + } simdata->last_errno=MSG_OK; @@ -120,7 +123,7 @@ m_process_t MSG_process_create_with_arguments(const char *name, process->simdata = simdata; process->data = data; - xbt_fifo_unshift(msg_global->process_list, process); + xbt_fifo_unshift(msg_global->process_list, process); return process; } @@ -134,22 +137,22 @@ void MSG_process_kill(m_process_t process) { simdata_process_t p_simdata = process->simdata; - DEBUG3("Killing %s(%d) on %s",process->name, p_simdata->PID, p_simdata->host->name); + DEBUG3("Killing %s(%d) on %s", + process->name, p_simdata->PID, p_simdata->m_host->name); - if(p_simdata->waiting_task) { - DEBUG1("Canceling waiting task %s",p_simdata->waiting_task->name); + if(p_simdata->waiting_task) { + DEBUG1("Canceling waiting task %s",p_simdata->waiting_task->name); if(p_simdata->waiting_task->simdata->compute) { - SIMIX_action_cancel(p_simdata->waiting_task->simdata->compute); - } - else if (p_simdata->waiting_task->simdata->comm) { - SIMIX_action_cancel(p_simdata->waiting_task->simdata->comm); + SIMIX_action_cancel(p_simdata->waiting_task->simdata->compute); + } else if (p_simdata->waiting_task->simdata->comm) { + SIMIX_action_cancel(p_simdata->waiting_task->simdata->comm); } } xbt_fifo_remove(msg_global->process_list,process); - SIMIX_process_kill(process->simdata->smx_process); + SIMIX_process_kill(process->simdata->s_process); - return; + return; } /** \ingroup m_process_management @@ -204,7 +207,7 @@ m_host_t MSG_process_get_host(m_process_t process) { xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters"); - return (((simdata_process_t) process->simdata)->host); + return (((simdata_process_t) process->simdata)->m_host); } /** \ingroup m_process_management @@ -230,14 +233,14 @@ m_process_t MSG_process_from_PID(int PID) * \brief Returns the process ID of \a process. * * This functions checks whether \a process is a valid pointer or not - and return its PID. + and return its PID (or 0 in case of problem). */ int MSG_process_get_PID(m_process_t process) { /* Do not raise an exception here: this function is used in the logs, and it will be called back by the exception handling stuff */ if (process == NULL || process->simdata == NULL) - return -1; + return 0; return (((simdata_process_t) process->simdata)->PID); } @@ -318,7 +321,7 @@ MSG_error_t MSG_process_suspend(m_process_t process) xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters"); CHECK_HOST(); - SIMIX_process_suspend(process->simdata->smx_process); + SIMIX_process_suspend(process->simdata->s_process); MSG_RETURN(MSG_OK); } @@ -334,7 +337,7 @@ MSG_error_t MSG_process_resume(m_process_t process) xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters"); CHECK_HOST(); - SIMIX_process_resume(process->simdata->smx_process); + SIMIX_process_resume(process->simdata->s_process); MSG_RETURN(MSG_OK); } @@ -347,6 +350,6 @@ MSG_error_t MSG_process_resume(m_process_t process) int MSG_process_is_suspended(m_process_t process) { xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters"); - return SIMIX_process_is_suspended(process->simdata->smx_process); + return SIMIX_process_is_suspended(process->simdata->s_process); }