Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Implement SIMIX_process_from_PID
authornavarro <navarro@caraja.(none)>
Tue, 17 Jan 2012 13:47:41 +0000 (14:47 +0100)
committernavarro <navarro@caraja.(none)>
Tue, 17 Jan 2012 13:47:41 +0000 (14:47 +0100)
include/simix/context.h
src/msg/msg_process.c
src/simix/smx_process.c

index f3dba8b..137e374 100644 (file)
@@ -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);
index 931ec4e..39c4a8f 100644 (file)
@@ -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
index 8e32dd7..5af0e0b 100644 (file)
@@ -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;
+}