|
From: <sv...@va...> - 2008-09-09 18:18:16
|
Author: bart Date: 2008-09-09 19:18:26 +0100 (Tue, 09 Sep 2008) New Revision: 8594 Log: Added more comments. Modified: trunk/drd/tests/pth_inconsistent_cond_wait.c Modified: trunk/drd/tests/pth_inconsistent_cond_wait.c =================================================================== --- trunk/drd/tests/pth_inconsistent_cond_wait.c 2008-09-09 18:11:40 UTC (rev 8593) +++ trunk/drd/tests/pth_inconsistent_cond_wait.c 2008-09-09 18:18:26 UTC (rev 8594) @@ -37,21 +37,33 @@ pthread_t tid1; pthread_t tid2; + /* Initialize synchronization objects. */ sem_init(&s_sem, 0, 0); pthread_cond_init(&s_cond, 0); pthread_mutex_init(&s_mutex1, 0); pthread_mutex_init(&s_mutex2, 0); + + /* Create two threads. */ pthread_create(&tid1, 0, &thread1, 0); pthread_create(&tid2, 0, &thread2, 0); + + /* Wait until both threads have called sem_post(). */ sem_wait(&s_sem); sem_wait(&s_sem); + + /* Wait until both threads are waiting inside pthread_cond_wait(). */ pthread_mutex_lock(&s_mutex1); pthread_mutex_lock(&s_mutex2); pthread_mutex_unlock(&s_mutex2); pthread_mutex_unlock(&s_mutex1); + + /* Signal s_cond twice. */ pthread_cond_signal(&s_cond); pthread_cond_signal(&s_cond); + + /* Join both threads. */ pthread_join(tid1, 0); pthread_join(tid2, 0); + return 0; } |