pthread_rwlock_unlock 示例代码: #include <pthread.h>#include<stdio.h>#include<unistd.h>staticintcounter;staticpthread_rwlock_t rwlock;void*th_write(void*arg) {intt, i;for(i=0; i<5; i++) { pthread_rwlock_wrlock(&rwlock); t=counter; usleep(100); printf("Write Thread(%x) counter=%d...
TEST(pthread, pthread_rwlock_smoke) {pthread_rwlock_tl; ASSERT_EQ(0, pthread_rwlock_init(&l,NULL));// Single read lockASSERT_EQ(0, pthread_rwlock_rdlock(&l)); ASSERT_EQ(0, pthread_rwlock_unlock(&l));// Multiple read lockASSERT_EQ(0, pthread_rwlock_rdlock(&l)); ASSERT_EQ(0, pt...
pthread_rwlock_tryrdlock pthread_rwlock_trywrlock pthread_rwlock_unlock ⽰例代码:#include <pthread.h> #include <stdio.h> #include <unistd.h> static int counter;static pthread_rwlock_t rwlock;void *th_write(void *arg){ int t, i;for (i=0; i<5; i++) { pthread_rwlock_wrlock(&...