#define _MULTI_THREADED // using kernel thread #include #include #include #include //pthread_cond_t cond = PTHREAD_COND_INITIALIZER; pthread_cond_t cond; pthread_mutex_t mutex; void *thread_f(void *param) { int ret; while(1){ ret = pthread_mutex_lock(&mutex); printf("Thread is Waiting.....\n"); ret = pthread_cond_wait(&cond, &mutex); printf("Thread is Running\n"); ret = pthread_mutex_unlock(&mutex); } } int main(int argc, char **argv) { pthread_cond_init(&cond, NULL);/// pthread_create를 호출하기 전에, cond과mutex를 초기화 해야 된다 pthread_mutex_init(&mutex, NULL); pthread_t pth; int ret; ret = pthread_create(&pth, NULL, thread_f, NULL); printf("pthread_create\n"); sleep(5); // pthread_cond_init(&cond, NULL); // pthread_mutex_init(&mutex, NULL); for(int i=0; i