【问题标题】:How properly use MSG_host_set_property_value() in SimGrid?如何在 SimGrid 中正确使用 MSG_host_set_property_value()?
【发布时间】:2016-07-29 17:01:17
【问题描述】:

只有一个主机:

<host id="Worker1" speed="1Mf" core="101"/>

此主机上仅部署一个进程:

<process host="Worker1" function="worker"/>

worker函数如下:

int worker(int argc, char *argv[])
{
    MSG_host_set_property_value(MSG_host_self(), "activeCore", "0", xbt_free_f);
    MSG_task_execute(MSG_task_create("kot", 10e6, 0, NULL));
    XBT_INFO("I've executed some stuff and changed my value");
    MSG_host_set_property_value(MSG_host_self(), "activeCore", "1", xbt_free_f);
    return 0;
}

当我第二次使用MSG_host_set_property_value 时,Segmentation fault 会引发。

如何避免?

我知道xbt_free_f中的原因。如果我将其更改为 NULL 模拟将正常工作。但我担心这会影响生产力。

【问题讨论】:

    标签: properties platform simgrid


    【解决方案1】:

    查看examples/msg/platform-properties/platform-properties.c 你应该写 MSG_host_set_property_value(MSG_host_self(), "activeCore", xbt_strdup("0"), xbt_free_f);

    MSG_host_set_property_value(MSG_host_self(), "activeCore", xbt_strdup("1"), xbt_free_f);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-17
      • 2018-09-25
      • 2017-02-19
      • 2011-02-06
      • 2017-09-04
      • 2017-08-19
      相关资源
      最近更新 更多