100個のプロセスを起動するプロセスがあります:SimGridでプロパティを同時に正しく設定する方法は?
for (int i = 0; i < 100; ++i) {
MSG_process_create("w", executor, NULL, MSG_host_self());
}
executorがサンプルタスクを作成し、それを実行します。したがって、同時に100タスクが実行され、同時にタスクが完了します。アクティブのステップ量によって(私は予想通り)
が[ 0.000000] (2:[email protected]) Active process amount is 1
[ 0.000000] (3:[email protected]) Active process amount is 2
[ 0.000000] (4:[email protected]) Active process amount is 3
....................................................
[ 0.000000] (101:[email protected]) Active process amount is 100
の各プロセスが減少するはずであるステップ:すべてのexecutor
のプロセスが同時に開始のすべてがOKですので
:プロセスの数を監視するために私はvoid plusOneActiveProcess()
とvoid minusOneActiveProcess()
を持っていますタスクを実行するためにexecutor
が完了したときのプロセス。しかし、それは起こらなかった:
[100.000000] (101:[email protected]) Active process amount is 99
[100.000000] (2:[email protected]) Active process amount is 99
[100.000000] (3:[email protected]) Active process amount is 99
....................................................
[100.000000] (100:[email protected]) Active process amount is 99
それを正しく行うには?
これは機能plusOneActiveProcess()
のコード、minusOneActiveProcess
、executor()
である:それは面白い、
int executor(){
plusOneActiveProcess();
msg_error_t a = MSG_task_execute(MSG_task_create("", 1e9, 0, NULL));
minusOneActiveProcess();
MSG_process_kill(MSG_process_self());
return 0;
}
void plusOneActiveProcess(){
char kot[50];
long number;
number = xbt_str_parse_int(MSG_host_get_property_value(MSG_host_self(), "activeProcess"), "error");
number++;
sprintf(kot, "%ld", number);
MSG_host_set_property_value(MSG_host_self(), "activeProcess", xbt_strdup(kot), NULL);
XBT_INFO("Active process amount is %s", MSG_host_get_property_value(MSG_host_self(), "activeProcess"));
memset(kot, 0, 50);
}
void minusOneActiveProcess(){
char kot[50];
long number;
number = xbt_str_parse_int(MSG_host_get_property_value(MSG_host_self(), "activeProcess"), "error");
number--;
sprintf(kot, "%ld", number);
MSG_host_set_property_value(MSG_host_self(), "activeProcess", xbt_strdup(kot), NULL);
//XBT_INFO("Active process amount is %s", MSG_host_get_property_value(MSG_host_self(), "activeProcess"));
memset(kot, 0, 50);
}