Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a function I need in GRAS
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 31 Dec 2004 12:08:57 +0000 (12:08 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 31 Dec 2004 12:08:57 +0000 (12:08 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@715 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/msg/gos.c
src/msg/task.c

index 3e1a6e6..fd042a4 100644 (file)
@@ -115,6 +115,33 @@ int MSG_task_Iprobe(m_channel_t channel)
   return(xbt_fifo_getFirstItem(h_simdata->mbox[channel])!=NULL);
 }
 
   return(xbt_fifo_getFirstItem(h_simdata->mbox[channel])!=NULL);
 }
 
+/** \ingroup msg_gos_functions
+ * \brief Test whether there is a pending communication on a channel, and who sent it.
+ *
+ * It takes one parameter.
+ * \param channel the channel on which the agent should be
+   listening. This value has to be >=0 and < than the maximal
+   number of channels fixed with MSG_set_channel_number().
+ * \return -1 if there is no pending communication and the PID of the process who sent it otherwise
+ */
+int MSG_task_probe_from(m_channel_t channel)
+{
+  m_host_t h = NULL;
+  simdata_host_t h_simdata = NULL;
+  xbt_fifo_item_t item;
+  m_task_t t;
+
+  CHECK_HOST();
+  h = MSG_host_self();
+  h_simdata = h->simdata;
+   
+  item = xbt_fifo_getFirstItem(((simdata_host_t)h->simdata)->mbox[channel]);
+  if (!item || !(t = xbt_fifo_get_item_content(item)) || (simdata_task_t)t->simdata)
+    return -1;
+   
+  return MSG_process_get_PID(((simdata_task_t)t->simdata)->sender);
+}
+
 /** \ingroup msg_gos_functions
  * \brief Put a task on a channel of an host and waits for the end of the
  * transmission.
 /** \ingroup msg_gos_functions
  * \brief Put a task on a channel of an host and waits for the end of the
  * transmission.
index 530be8b..af973f0 100644 (file)
@@ -67,6 +67,18 @@ void *MSG_task_get_data(m_task_t task)
   return (task->data);
 }
 
   return (task->data);
 }
 
+/** \ingroup m_task_management
+ * \brief Return the sender of a #m_task_t.
+ *
+ * This functions returns the #m_process_t which sent this task
+ */
+m_process_t MSG_task_get_sender(m_task_t task)
+{
+   xbt_assert0(task, "Invalid parameters");
+   return ((simdata_task_t) task->simdata)->sender;
+}
+
+
 /** \ingroup m_task_management
  * \brief Destroy a #m_task_t.
  *
 /** \ingroup m_task_management
  * \brief Destroy a #m_task_t.
  *