Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Keep execution alive after timeout in sg_exec_wait_for.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 3 May 2021 13:54:45 +0000 (15:54 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 3 May 2021 14:46:14 +0000 (16:46 +0200)
examples/c/energy-exec-ptask/energy-exec-ptask.c
src/s4u/s4u_Exec.cpp

index a92b767..2356cc6 100644 (file)
@@ -47,7 +47,8 @@ static void runner(int argc, char* argv[])
       communication_amounts[i * host_count + j] = 1e7; // 10 MB
 
   sg_exec_t exec = sg_actor_parallel_exec_init(host_count, hosts, computation_amounts, communication_amounts);
-  sg_exec_wait_for(exec, 1 /* timeout (in seconds)*/);
+  if (sg_exec_wait_for(exec, 1 /* timeout (in seconds)*/) == SG_ERROR_TIMEOUT)
+    sg_exec_cancel(exec);
   xbt_free(communication_amounts);
   xbt_free(computation_amounts);
 
index 7d9d44c..24e0111 100644 (file)
@@ -300,6 +300,7 @@ sg_error_t sg_exec_wait_for(sg_exec_t exec, double timeout)
   try {
     s4u_exec->wait_for(timeout);
   } catch (const simgrid::TimeoutException&) {
+    s4u_exec->add_ref(); // the wait_for timeouted, keep the exec alive
     status = SG_ERROR_TIMEOUT;
   } catch (const simgrid::CancelException&) {
     status = SG_ERROR_CANCELED;