首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >删除SimGrid中的挂起任务

删除SimGrid中的挂起任务
EN

Stack Overflow用户
提问于 2016-08-08 13:31:10
回答 2查看 75关注 0票数 0

我有进程worker,它启动executorExecutor是一个创建10秒任务并执行它的进程.但是在2秒后,工作人员会杀死executor进程。SimGrid在杀了executor之后给了我一条日志

代码语言:javascript
复制
[  2.000000] (0:maestro@) dp_objs: 1 pending task?

当另一个进程杀死当前的工作进程时,我应该如何正确地销毁任务和task_data

代码语言:javascript
复制
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

现在,当我运行代码时,我有:

代码语言:javascript
复制
[  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错误而中断。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-08-08 14:17:25

您应该MSG_task_cancel()您想要“杀死”的任务。您可以在一个在MSG_process_on_exit()回调中注册的函数中这样做。

票数 2
EN

Stack Overflow用户

发布于 2016-08-09 14:30:40

再想一想,你看到的信息不是错误信息,而是警告。你可以安全地忽略它。我非常肯定,当处理器被杀死时,执行的任务会自动取消。

所以你不用做任何事情来让它起作用,我会说。别管那个信息了。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38830563

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档