diff options
Diffstat (limited to 'pthread.c')
-rw-r--r-- | pthread.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -236,7 +236,7 @@ int test_pthread(void) TEST(r, pthread_mutex_destroy(&mtx), 0, "%d != %d"); TEST(r, pthread_cond_destroy(&cond), 0, "%d != %d"); - + /* Condition variables with multiple waiters */ TEST(r, pthread_mutex_init(&mtx, 0), 0, "%d != %d"); TEST(r, pthread_cond_init(&cond, 0), 0, "%d != %d"); TEST(r, pthread_mutex_lock(&mtx), 0, "%d != %d"); @@ -262,6 +262,25 @@ int test_pthread(void) TEST(r, pthread_mutex_destroy(&mtx), 0, "%d != %d"); TEST(r, pthread_cond_destroy(&cond), 0, "%d != %d"); + /* Condition variables with broadcast signals */ + TEST(r, pthread_mutex_init(&mtx, 0), 0, "%d != %d"); + TEST(r, pthread_cond_init(&cond, 0), 0, "%d != %d"); + TEST(r, pthread_mutex_lock(&mtx), 0, "%d != %d"); + foo[0] = 1; + TEST(r, pthread_create(&td1, 0, start8, (void *[]){ &cond, &mtx, foo }), 0, "%d != %d"); + TEST(r, pthread_create(&td2, 0, start8, (void *[]){ &cond, &mtx, foo }), 0, "%d != %d"); + TEST(r, pthread_create(&td3, 0, start8, (void *[]){ &cond, &mtx, foo }), 0, "%d != %d"); + TEST(r, pthread_mutex_unlock(&mtx), 0, "%d != %d"); + nanosleep(&(struct timespec){.tv_nsec=1000000}, 0); + TEST(r, pthread_mutex_lock(&mtx), 0, "%d != %d"); + foo[0] = 0; + TEST(r, pthread_mutex_unlock(&mtx), 0, "%d != %d"); + TEST(r, pthread_cond_broadcast(&cond), 0, "%d != %d"); + TEST(r, pthread_join(td1, 0), 0, "%d != %d"); + TEST(r, pthread_join(td2, 0), 0, "%d != %d"); + TEST(r, pthread_join(td3, 0), 0, "%d != %d"); + TEST(r, pthread_mutex_destroy(&mtx), 0, "%d != %d"); + TEST(r, pthread_cond_destroy(&cond), 0, "%d != %d"); return err; } |