From c74a787450df525f7f5238876e34b8d5f50d1cac Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 9 Sep 2008 18:18:26 +0000 Subject: [PATCH] Added more comments. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8594 --- drd/tests/pth_inconsistent_cond_wait.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drd/tests/pth_inconsistent_cond_wait.c b/drd/tests/pth_inconsistent_cond_wait.c index 2a1e71924e..06c476b0ec 100644 --- a/drd/tests/pth_inconsistent_cond_wait.c +++ b/drd/tests/pth_inconsistent_cond_wait.c @@ -37,21 +37,33 @@ int main(int argc, char** argv) 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; } -- 2.47.2