1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #include "test.h"
- static pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER;
- static int washere = 0;
- static void * func(void * arg)
- {
- assert(pthread_rwlock_tryrdlock(&rwlock1) == 0);
- assert(pthread_rwlock_unlock(&rwlock1) == 0);
- washere = 1;
- return 0;
- }
- int pthread_test_rwlock5()
- {
- pthread_t t;
- rwlock1 = PTHREAD_RWLOCK_INITIALIZER;
- assert(pthread_rwlock_rdlock(&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;
- }
|