Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
No need to rebuild the parser if you're not a maintainer.
[simgrid.git] / src / msg / gos.c
index 7e7a349..9041afd 100644 (file)
@@ -14,7 +14,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gos, msg,
 /** \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.");
@@ -75,9 +74,11 @@ MSG_error_t MSG_task_get(m_task_t * task,
 
   /* Transfer */
   t_simdata->using++;
+
   t_simdata->comm = surf_workstation_resource->extension_public->
     communicate(MSG_process_get_host(t_simdata->sender)->simdata->host,
-               h->simdata->host, t_simdata->message_size);
+               h->simdata->host, t_simdata->message_size,t_simdata->rate);
+  
   surf_workstation_resource->common_public->action_set_data(t_simdata->comm,t);
 
   if(__MSG_process_isBlocked(t_simdata->sender)) 
@@ -88,6 +89,11 @@ MSG_error_t MSG_task_get(m_task_t * task,
     state=surf_workstation_resource->common_public->action_get_state(t_simdata->comm);
   } while (state==SURF_ACTION_RUNNING);
 
+  if(t->simdata->using>1) {
+    xbt_fifo_unshift(msg_global->process_to_run,process);
+    xbt_context_yield();
+  }
+
   if(state == SURF_ACTION_DONE) MSG_RETURN(MSG_OK);
   else if(surf_workstation_resource->extension_public->get_state(h_simdata->host) 
          == SURF_CPU_OFF)
@@ -189,19 +195,20 @@ MSG_error_t MSG_task_put(m_task_t task,
     
   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;
-  }
+/*   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;
+/*   } */
 
-  do {
+  state=surf_workstation_resource->common_public->action_get_state(task_simdata->comm);
+  while (state==SURF_ACTION_RUNNING) {
     __MSG_task_wait_event(process, task);
     state=surf_workstation_resource->common_public->action_get_state(task_simdata->comm);
-  } while (state==SURF_ACTION_RUNNING);
+  }
     
   MSG_task_destroy(task);
 
@@ -212,6 +219,20 @@ 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)
+{
+  task->simdata->rate=max_rate;
+  return(MSG_task_put(task, dest, channel));
+}
+
 /** \ingroup msg_gos_functions
  * \brief Executes a task and waits for its termination.
  *
@@ -335,4 +356,3 @@ MSG_error_t MSG_get_errno(void)
 {
   return PROCESS_GET_ERRNO();
 }
-