Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SURF does not use long doubles. Reverting MSG to doubles.
[simgrid.git] / src / msg / gos.c
index 7cfb055..3831fa4 100644 (file)
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gos, msg,
                                "Logging specific to MSG (gos)");
 
+/** \defgroup msg_gos_functions MSG Operating System Functions
+ *  \brief This section describes the functions that can be used
+ *  by an agent for handling some task.
+ */
+
 /** \ingroup msg_gos_functions
  * \brief This function is now deprecated and useless. Please stop using it.
  */
-
 MSG_error_t MSG_process_start(m_process_t process)
 {
   xbt_assert0(0,"This function is now deprecated and useless. Please stop using it.");
@@ -58,8 +62,10 @@ MSG_error_t MSG_task_get(m_task_t * task,
   h = MSG_host_self();
   h_simdata = h->simdata;
   while ((t = xbt_fifo_pop(h_simdata->mbox[channel])) == NULL) {
-    xbt_assert0(!(h_simdata->sleeping[channel]),
-               "A process is already blocked on this channel");
+    xbt_assert2(!(h_simdata->sleeping[channel]),
+               "A process (%s(%d)) is already blocked on this channel",
+               h_simdata->sleeping[channel]->name,
+               h_simdata->sleeping[channel]->simdata->PID);
     h_simdata->sleeping[channel] = process; /* I'm waiting. Wake me up when you're ready */
     __MSG_process_block();
     if(surf_workstation_resource->extension_public->get_state(h_simdata->host) 
@@ -85,6 +91,8 @@ MSG_error_t MSG_task_get(m_task_t * task,
   if(__MSG_process_isBlocked(t_simdata->sender)) 
     __MSG_process_unblock(t_simdata->sender);
 
+  PAJE_PROCESS_PUSH_STATE(process,"C");  
+
   do {
     __MSG_task_wait_event(process, t);
     state=surf_workstation_resource->common_public->action_get_state(t_simdata->comm);
@@ -95,6 +103,9 @@ MSG_error_t MSG_task_get(m_task_t * task,
     xbt_context_yield();
   }
 
+  PAJE_PROCESS_POP_STATE(process);  
+  PAJE_COMM_STOP(process,t,channel);
+
   if(state == SURF_ACTION_DONE) MSG_RETURN(MSG_OK);
   else if(surf_workstation_resource->extension_public->get_state(h_simdata->host) 
          == SURF_CPU_OFF)
@@ -193,17 +204,21 @@ MSG_error_t MSG_task_put(m_task_t task,
 
   xbt_fifo_push(((simdata_host_t) remote_host->simdata)->
                mbox[channel], task);
+
+  PAJE_COMM_START(process,task,channel);
     
   if(remote_host->simdata->sleeping[channel]) 
     __MSG_process_unblock(remote_host->simdata->sleeping[channel]);
-/*   else { */
+
   process->simdata->put_host = dest;
   process->simdata->put_channel = channel;
   while(!(task_simdata->comm)) 
     __MSG_process_block();
   process->simdata->put_host = NULL;
   process->simdata->put_channel = -1;
-/*   } */
+
+
+  PAJE_PROCESS_PUSH_STATE(process,"C");  
 
   state=surf_workstation_resource->common_public->action_get_state(task_simdata->comm);
   while (state==SURF_ACTION_RUNNING) {
@@ -213,6 +228,8 @@ MSG_error_t MSG_task_put(m_task_t task,
     
   MSG_task_destroy(task);
 
+  PAJE_PROCESS_POP_STATE(process);  
+
   if(state == SURF_ACTION_DONE) MSG_RETURN(MSG_OK);
   else if(surf_workstation_resource->extension_public->get_state(local_host->simdata->host) 
          == SURF_CPU_OFF)
@@ -220,12 +237,19 @@ MSG_error_t MSG_task_put(m_task_t task,
   else MSG_RETURN(MSG_TRANSFER_FAILURE);
 }
 
+/** \ingroup msg_gos_functions
+ * \brief Does exactly the same as MSG_task_put but with a bounded transmition 
+ * rate.
+ *
+ * \sa MSG_task_put
+ */
 MSG_error_t MSG_task_put_bounded(m_task_t task,
                                 m_host_t dest, m_channel_t channel,
-                                long double max_rate)
+                                double max_rate)
 {
   task->simdata->rate=max_rate;
   return(MSG_task_put(task, dest, channel));
+  task->simdata->rate=-1.0;
 }
 
 /** \ingroup msg_gos_functions
@@ -241,9 +265,13 @@ MSG_error_t MSG_task_put_bounded(m_task_t task,
 MSG_error_t MSG_task_execute(m_task_t task)
 {
   m_process_t process = MSG_process_self();
-
+  MSG_error_t res;
   __MSG_task_execute(process, task);
-  return __MSG_wait_for_computation(process,task);
+
+  PAJE_PROCESS_PUSH_STATE(process,"E");  
+  res = __MSG_wait_for_computation(process,task);
+  PAJE_PROCESS_POP_STATE(process);
+  return res;
 }
 
 void __MSG_task_execute(m_process_t process, m_task_t task)
@@ -288,7 +316,7 @@ MSG_error_t __MSG_wait_for_computation(m_process_t process, m_task_t task)
  *
  * \param nb_sec a number of second
  */
-MSG_error_t MSG_process_sleep(long double nb_sec)
+MSG_error_t MSG_process_sleep(double nb_sec)
 {
   e_surf_action_state_t state = SURF_ACTION_NOT_IN_THE_SYSTEM;
   m_process_t process = MSG_process_self();
@@ -351,4 +379,3 @@ MSG_error_t MSG_get_errno(void)
 {
   return PROCESS_GET_ERRNO();
 }
-