Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Smarter assert in MSG_task_execute and take care of failures as suggested by
[simgrid.git] / src / msg / gos.c
index fd35c1b..9fc31e8 100644 (file)
@@ -75,11 +75,11 @@ static MSG_error_t __MSG_task_get_with_time_out_from_host(m_task_t * task,
     } else {
       __MSG_process_block(-1);
     }
+    h_simdata->sleeping[channel] = NULL;
+    first_time = 0;
     if(surf_workstation_resource->extension_public->get_state(h_simdata->host) 
        == SURF_CPU_OFF)
       MSG_RETURN(MSG_HOST_FAILURE);
-    h_simdata->sleeping[channel] = NULL;
-    first_time = 0;
     /* OK, we should both be ready now. Are you there ? */
   }
 
@@ -124,7 +124,7 @@ static MSG_error_t __MSG_task_get_with_time_out_from_host(m_task_t * task,
     __MSG_process_unblock(t_simdata->sender);
   }
 
-  PAJE_PROCESS_PUSH_STATE(process,"C");  
+  PAJE_PROCESS_PUSH_STATE(process,"C",t);  
 
   do {
     DEBUG0("Waiting for action termination");
@@ -306,7 +306,8 @@ MSG_error_t MSG_channel_select_from(m_channel_t channel, double max_duration,
   }
 
   if(max_duration==0.0) {
-    return MSG_task_probe_from(channel);
+    *PID = MSG_task_probe_from(channel);
+    MSG_RETURN(MSG_OK);
   } else {
     CHECK_HOST();
     h = MSG_host_self();
@@ -421,7 +422,8 @@ MSG_error_t MSG_task_put(m_task_t task,
   task_simdata = task->simdata;
   task_simdata->sender = process;
   task_simdata->source = MSG_process_get_host(process);
-  xbt_assert0(task_simdata->using==1,"Gargl!");
+  xbt_assert0(task_simdata->using==1,
+             "This taks is still being used somewhere else. You cannot send it now. Go fix your code!");
   task_simdata->comm = NULL;
   
   local_host = ((simdata_process_t) process->simdata)->host;
@@ -445,6 +447,13 @@ MSG_error_t MSG_task_put(m_task_t task,
   while(!(task_simdata->comm)) {
     DEBUG0("Communication not initiated yet. Let's block!");
     __MSG_process_block(-1);
+    if(surf_workstation_resource->extension_public->
+       get_state(remote_host->simdata->host) == SURF_CPU_OFF) {
+      xbt_fifo_remove(((simdata_host_t) remote_host->simdata)->mbox[channel],
+                     task);
+      MSG_task_destroy(task);
+      MSG_RETURN(MSG_HOST_FAILURE);
+    }
   }
   DEBUG0("Registering to this communication");
   surf_workstation_resource->common_public->action_use(task_simdata->comm);
@@ -452,7 +461,7 @@ MSG_error_t MSG_task_put(m_task_t task,
   process->simdata->put_channel = -1;
 
 
-  PAJE_PROCESS_PUSH_STATE(process,"C");  
+  PAJE_PROCESS_PUSH_STATE(process,"C",task);  
 
   state=surf_workstation_resource->common_public->action_get_state(task_simdata->comm);
   while (state==SURF_ACTION_RUNNING) {
@@ -461,6 +470,7 @@ MSG_error_t MSG_task_put(m_task_t task,
     state=surf_workstation_resource->common_public->action_get_state(task_simdata->comm);
   }
   DEBUG0("Action terminated");
+  task->simdata->rate=-1.0; /* Sets the rate back to default */
 
   PAJE_PROCESS_POP_STATE(process);  
 
@@ -496,7 +506,6 @@ MSG_error_t MSG_task_put_bounded(m_task_t task,
   MSG_error_t res = MSG_OK;
   task->simdata->rate=max_rate;
   res = MSG_task_put(task, dest, channel);
-  task->simdata->rate=-1.0;
   return(res);
 }
 
@@ -519,7 +528,7 @@ MSG_error_t MSG_task_execute(m_task_t task)
 
   __MSG_task_execute(process, task);
 
-  PAJE_PROCESS_PUSH_STATE(process,"E");  
+  PAJE_PROCESS_PUSH_STATE(process,"E",task);  
   res = __MSG_wait_for_computation(process,task);
   PAJE_PROCESS_POP_STATE(process);
   return res;
@@ -532,7 +541,9 @@ void __MSG_task_execute(m_process_t process, m_task_t task)
   CHECK_HOST();
 
   simdata = task->simdata;
-
+  xbt_assert0((!simdata->compute)&&(task->simdata->using==1),
+             "This taks is executed somewhere else. Go fix your code!");
+  task->simdata->using++;
   simdata->compute = surf_workstation_resource->extension_public->
     execute(MSG_process_get_host(process)->simdata->host,
            simdata->computation_amount);
@@ -540,6 +551,7 @@ void __MSG_task_execute(m_process_t process, m_task_t task)
     set_priority(simdata->compute, simdata->priority);
 
   surf_workstation_resource->common_public->action_set_data(simdata->compute,task);
+  task->simdata->using--;
 }
 
 MSG_error_t __MSG_wait_for_computation(m_process_t process, m_task_t task)