Search code examples
simgrid

Delete pending task in SimGrid


I have process worker which launches executor. Executor is a process which creates a 10-sec task and executes it. But after 2 sec worker kills executor process. SimGrid gives me a log after killing executor:

[  2.000000] (0:maestro@) dp_objs: 1 pending task?

How should I properly destroy tasks and task_data when another process kill currently working process?

int worker(int argc, char *argv[])
{
    msg_process_t x = MSG_process_create("", executor, NULL, MSG_host_self());
    MSG_process_sleep(2);
    MSG_process_kill(x);
}

int executor(){
    MSG_process_on_exit(my_onexit, NULL);
    task = MSG_task_create("", 1e10, 10, NULL);
    MSG_task_execute(task);
    return 0;
}
int my_onexit() {
     MSG_task_cancel(task);
     XBT_INFO("Exiting now (done sleeping or got killed).");
     return 0;
}

UPD: I declared a global variable msg_task_t task.

Now when I run code I have:

[  2.000000] (0:maestro@) Oops ! Deadlock or code not perfectly clean.
[  2.000000] (0:maestro@) 1 processes are still running, waiting for something.
[  2.000000] (0:maestro@) Legend of the following listing: "Process <pid> (<name>@<host>): <status>"
[  2.000000] (0:maestro@) Process 2 (@Worker2)
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

I expected that simgrid would show xbt_info message, but it didn't and interrupted with SIGABRT error.


Solution

  • You should MSG_task_cancel() the task that you want to "kill". You could do that in a function that is registered in the MSG_process_on_exit() callback.