123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #include "test.h"
- static pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER;
- static int washere = 0;
- static void * func(void * arg)
- {
- assert(pthread_rwlock_trywrlock(&rwlock1) == EBUSY);
- washere = 1;
- return 0;
- }
- int pthread_test_rwlock3()
- {
- pthread_t t;
- rwlock1 = PTHREAD_RWLOCK_INITIALIZER;
- assert(pthread_rwlock_wrlock(&rwlock1) == 0);
- assert(pthread_create(&t, NULL, func, NULL) == 0);
- pte_osThreadSleep(2000);
- assert(pthread_rwlock_unlock(&rwlock1) == 0);
- assert(washere == 1);
- assert(pthread_join(t, NULL) == 0);
- assert(pthread_rwlock_destroy(&rwlock1) == 0);
- return 0;
- }
|