From 12b884a0e928fc554aff99d3afb02d98a957f571 Mon Sep 17 00:00:00 2001 From: navarro Date: Tue, 17 Jan 2012 14:47:41 +0100 Subject: [PATCH] Implement SIMIX_process_from_PID --- include/simix/context.h | 1 + src/msg/msg_process.c | 4 +--- src/simix/smx_process.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/simix/context.h b/include/simix/context.h index f3dba8b1a0..137e374519 100644 --- a/include/simix/context.h +++ b/include/simix/context.h @@ -96,6 +96,7 @@ XBT_PUBLIC(smx_context_t) smx_ctx_base_self(void); XBT_PUBLIC(void) *smx_ctx_base_get_data(smx_context_t context); XBT_PUBLIC(xbt_dynar_t) SIMIX_process_get_runnable(void); +XBT_PUBLIC(smx_process_t) SIMIX_process_from_PID(int PID); /* parallelism */ XBT_INLINE int SIMIX_context_is_parallel(void); diff --git a/src/msg/msg_process.c b/src/msg/msg_process.c index 931ec4e19c..39c4a8f5a4 100644 --- a/src/msg/msg_process.c +++ b/src/msg/msg_process.c @@ -309,9 +309,7 @@ m_host_t MSG_process_get_host(m_process_t process) */ m_process_t MSG_process_from_PID(int PID) { - /* FIXME: reimplement this function using SIMIX when we have a good PID. - * In the meantime, I guess nobody uses it so it should not break anything. */ - THROW_UNIMPLEMENTED; + return SIMIX_process_from_PID(PID); } /** \ingroup m_process_management diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index 8e32dd7a3c..5af0e0b0db 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -648,3 +648,17 @@ xbt_dynar_t SIMIX_process_get_runnable(void) { return simix_global->process_to_run; } + +/** + * \brief Returns the process from PID. + */ +smx_process_t SIMIX_process_from_PID(int PID) +{ + smx_process_t proc; + xbt_swag_foreach(proc, simix_global->process_list) + { + if(proc->pid == PID) + return proc; + } + return NULL; +} -- 2.20.1