2016-07-29 18 views
0

Es gibt einen Wirt:Wie richtig verwenden Sie MSG_host_set_property_value() in SimGrid?

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

nur einen Prozess auf diesem Host setzt:

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

Die Funktion Arbeiter unter:

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

Als ich MSG_host_set_property_value zum zweiten Mal verwenden die Segmentation fault erhöht.

Wie kann ich es vermeiden?

Ich weiß, dass der Grund in xbt_free_f. Wenn ich es in NULL ändern, wird die Simulation gut funktionieren. Aber ich fürchte, das wird sich auf die Produktivität auswirken.

Antwort

1

auf Beispiele suchen/msg/Plattform-Eigenschaften/Plattform-properties.c sollten Sie schreiben MSG_host_set_property_value (MSG_host_self() "activeCore", xbt_strdup ("0"), xbt_free_f);

und

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