100 개 프로세스를 시작하는 과정이있다. 그래서 동시에 작업을 시작하고 동시에 처리를 시작하는 100 개의 프로세스가 있습니다. 활성 상태의 스텝 크기만큼 (I 예상대로)SimGrid에서 동시에 속성을 올바르게 설정하는 방법은 무엇입니까?</p> <pre><code>for (int i = 0; i < 100; ++i) { MSG_process_create("w", executor, NULL, MSG_host_self()); } </code></pre> <p>집행자 샘플 작업을 생성하고 실행 :
가[ 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이므로
: 프로세스의 수를 모니터링하는 I는 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
어떻게 올바르게 수행 할 수 있습니까?
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);
}