condition-variable

조건을 기다리는 방법어떤 조건이 참이 되기 전까지 스레드가 대기하는 것이 필요하다.물론 조건이 참이 될 때까지 단순히 반복할 수 있지만 ⇒ CPU 사이클을 낭비volatile int done = 0;void *child(void *arg) { printf("child\\n"); done = 1; return NULL;}int main(int argc, char *argv[]) { pthread_t c; printf("parent: begin\\n"); pthread_create(&c, NULL, child, NULL); // create child while (done == 0); // 회전 printf("parent: end\\n"); return 0;}..
unemployedMan
'condition-variable' 태그의 글 목록