Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix race condition.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 20 May 2014 13:02:22 +0000 (15:02 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 20 May 2014 14:16:50 +0000 (16:16 +0200)
Avoid to launch and cancel the task at the same time.  It seems to work with
HAVE_TRACING, but fails without.  In fact, the task cancelation happens before
the task starts to execute.  As a workaround, add a small delay before firing
up the cancel.

teshsuite/msg/task_destroy_cancel/task_destroy_cancel.c
teshsuite/msg/task_destroy_cancel/task_destroy_cancel.tesh

index 6dda8b5..2081663 100644 (file)
@@ -114,6 +114,7 @@ int slave(int argc, char *argv[])
 
     if (!strcmp(MSG_task_get_name(task), "cancel")) {
       MSG_process_create("worker1", worker_main, task, MSG_host_self());
 
     if (!strcmp(MSG_task_get_name(task), "cancel")) {
       MSG_process_create("worker1", worker_main, task, MSG_host_self());
+      MSG_process_sleep(0.1);
       XBT_INFO("Canceling task \"%s\"", task->name);
       MSG_task_cancel(task);
       continue;
       XBT_INFO("Canceling task \"%s\"", task->name);
       MSG_task_cancel(task);
       continue;
index c20f5ce..07f0c68 100644 (file)
@@ -9,10 +9,10 @@ $ ./task_destroy_cancel ${srcdir:=.}/task_destroy_cancel_p.xml ${srcdir:=.}/task
 > [Jupiter:slave:(2) 0.682345] [msg_test/INFO] Task "normal" done in 0.655342 (amount 0.000000)
 > [Jupiter:slave:(2) 0.709348] [msg_test/INFO] Handling task "cancel"
 > [Jupiter:worker1:(3) 0.709348] [msg_test/INFO] Start cancel
 > [Jupiter:slave:(2) 0.682345] [msg_test/INFO] Task "normal" done in 0.655342 (amount 0.000000)
 > [Jupiter:slave:(2) 0.709348] [msg_test/INFO] Handling task "cancel"
 > [Jupiter:worker1:(3) 0.709348] [msg_test/INFO] Start cancel
-> [Jupiter:slave:(2) 0.709348] [msg_test/INFO] Canceling task "cancel"
-> [Jupiter:worker1:(3) 0.710127] [msg_test/INFO] Task failed
-> [Tremblay:master:(1) 0.736350] [msg_test/INFO] Goodbye now!
-> [Jupiter:slave:(2) 0.736350] [msg_test/INFO] Handling task "finalize"
-> [Jupiter:slave:(2) 0.736350] [msg_test/INFO] Destroying task "finalize"
-> [Jupiter:slave:(2) 0.736350] [msg_test/INFO] I'm done. See you!
-> [0.736350] [msg_test/INFO] Simulation time 0.73635
+> [Jupiter:slave:(2) 0.809348] [msg_test/INFO] Canceling task "cancel"
+> [Jupiter:worker1:(3) 0.810127] [msg_test/INFO] Task failed
+> [Tremblay:master:(1) 0.836350] [msg_test/INFO] Goodbye now!
+> [Jupiter:slave:(2) 0.836350] [msg_test/INFO] Handling task "finalize"
+> [Jupiter:slave:(2) 0.836350] [msg_test/INFO] Destroying task "finalize"
+> [Jupiter:slave:(2) 0.836350] [msg_test/INFO] I'm done. See you!
+> [0.836350] [msg_test/INFO] Simulation time 0.83635