2016-07-29 79 views
0

有一个主持人:在SimGrid中如何正确使用MSG_host_set_property_value()?

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

只有一个进程在该主机上部署:

<process host="Worker1" function="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,模拟将正常工作。但我担心这会影响生产力。

回答

1

看例子/邮件/平台的属性/平台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);