Commit | Line | Data |
---|---|---|
07739b57 JA |
1 | #ifndef FIO_MUTEX_H |
2 | #define FIO_MUTEX_H | |
3 | ||
4 | #include <pthread.h> | |
5 | ||
cdd18ad8 | 6 | struct fio_mutex { |
07739b57 JA |
7 | pthread_mutex_t lock; |
8 | pthread_cond_t cond; | |
64d4d313 | 9 | int value; |
4d4e80f2 | 10 | int waiters; |
07739b57 JA |
11 | }; |
12 | ||
d7df1d13 JA |
13 | struct fio_rwlock { |
14 | pthread_rwlock_t lock; | |
15 | }; | |
16 | ||
521da527 JA |
17 | enum { |
18 | FIO_MUTEX_LOCKED = 0, | |
19 | FIO_MUTEX_UNLOCKED = 1, | |
20 | }; | |
21 | ||
cdd18ad8 JA |
22 | extern struct fio_mutex *fio_mutex_init(int); |
23 | extern void fio_mutex_remove(struct fio_mutex *); | |
d7df1d13 | 24 | extern void fio_mutex_up(struct fio_mutex *); |
af4bab56 | 25 | extern void fio_mutex_down(struct fio_mutex *); |
656b1393 | 26 | extern int fio_mutex_down_timeout(struct fio_mutex *, unsigned int); |
9c5b5290 | 27 | |
d7df1d13 JA |
28 | extern void fio_rwlock_read(struct fio_rwlock *); |
29 | extern void fio_rwlock_write(struct fio_rwlock *); | |
30 | extern void fio_rwlock_unlock(struct fio_rwlock *); | |
31 | extern struct fio_rwlock *fio_rwlock_init(void); | |
32 | extern void fio_rwlock_remove(struct fio_rwlock *); | |
4d4e80f2 | 33 | |
07739b57 | 34 | #endif |