Search code examples
propertiesplatformsimgrid

How properly use MSG_host_set_property_value() in SimGrid?


There is one host:

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

Only one process deploys on this host:

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

The worker function is below:

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;
}

When I use MSG_host_set_property_value for the second time the Segmentation fault raises.

How to avoid it?

I know that the reason in xbt_free_f. If I change it to NULL simulation will work fine. But I fear that will impact on productivity.


Solution

  • looking at examples/msg/platform-properties/platform-properties.c you should write MSG_host_set_property_value(MSG_host_self(), "activeCore", xbt_strdup("0"), xbt_free_f);

    and

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