Linux Perf
rwsem.c
Go to the documentation of this file.
1 #include "util.h"
2 #include "rwsem.h"
3 
4 int init_rwsem(struct rw_semaphore *sem)
5 {
6  return pthread_rwlock_init(&sem->lock, NULL);
7 }
8 
9 int exit_rwsem(struct rw_semaphore *sem)
10 {
11  return pthread_rwlock_destroy(&sem->lock);
12 }
13 
14 int down_read(struct rw_semaphore *sem)
15 {
16  return perf_singlethreaded ? 0 : pthread_rwlock_rdlock(&sem->lock);
17 }
18 
19 int up_read(struct rw_semaphore *sem)
20 {
21  return perf_singlethreaded ? 0 : pthread_rwlock_unlock(&sem->lock);
22 }
23 
24 int down_write(struct rw_semaphore *sem)
25 {
26  return perf_singlethreaded ? 0 : pthread_rwlock_wrlock(&sem->lock);
27 }
28 
29 int up_write(struct rw_semaphore *sem)
30 {
31  return perf_singlethreaded ? 0 : pthread_rwlock_unlock(&sem->lock);
32 }
pthread_rwlock_t lock
Definition: rwsem.h:7
int up_write(struct rw_semaphore *sem)
Definition: rwsem.c:29
int down_read(struct rw_semaphore *sem)
Definition: rwsem.c:14
int exit_rwsem(struct rw_semaphore *sem)
Definition: rwsem.c:9
int init_rwsem(struct rw_semaphore *sem)
Definition: rwsem.c:4
bool perf_singlethreaded
Definition: util.c:28
int down_write(struct rw_semaphore *sem)
Definition: rwsem.c:24
int up_read(struct rw_semaphore *sem)
Definition: rwsem.c:19