我有进程worker,它启动executor。Executor是一个创建10秒任务并执行它的进程.但是在2秒后,工作人员会杀死executor进程。SimGrid在杀了executor之后给了我一条日志
[ 2.000000] (0:maestro@) dp_objs: 1 pending task?当另一个进程杀死当前的工作进程时,我应该如何正确地销毁任务和task_data?
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:我声明了一个全局变量msg_task_t task。
现在,当我运行代码时,我有:
[ 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)我原以为simgrid会显示xbt_info消息,但它没有显示,并因SIGABRT错误而中断。
发布于 2016-08-08 14:17:25
您应该MSG_task_cancel()您想要“杀死”的任务。您可以在一个在MSG_process_on_exit()回调中注册的函数中这样做。
发布于 2016-08-09 14:30:40
再想一想,你看到的信息不是错误信息,而是警告。你可以安全地忽略它。我非常肯定,当处理器被杀死时,执行的任务会自动取消。
所以你不用做任何事情来让它起作用,我会说。别管那个信息了。
https://stackoverflow.com/questions/38830563
复制相似问题