X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=mutex.h;h=49a66e361bc52ed7c09328578dc4a912ec1c4e83;hp=483e5f45369e9979b4ee43697ae00416fe87cc26;hb=d7213923067aa49922962a469a691c3ec951064d;hpb=07739b57f09886b41323c605b0dbda7d2c12522b diff --git a/mutex.h b/mutex.h index 483e5f45..49a66e36 100644 --- a/mutex.h +++ b/mutex.h @@ -3,17 +3,32 @@ #include -struct fio_sem { +struct fio_mutex { pthread_mutex_t lock; pthread_cond_t cond; - unsigned int value; + int value; + int waiters; +}; + +struct fio_rwlock { + pthread_rwlock_t lock; +}; - char sem_name[32]; +enum { + FIO_MUTEX_LOCKED = 0, + FIO_MUTEX_UNLOCKED = 1, }; -extern struct fio_sem *fio_sem_init(int); -extern void fio_sem_remove(struct fio_sem *); -extern inline void fio_sem_down(struct fio_sem *); -extern inline void fio_sem_up(struct fio_sem *sem); +extern struct fio_mutex *fio_mutex_init(int); +extern void fio_mutex_remove(struct fio_mutex *); +extern void fio_mutex_up(struct fio_mutex *); +extern void fio_mutex_down(struct fio_mutex *); +extern int fio_mutex_down_timeout(struct fio_mutex *, unsigned int); + +extern void fio_rwlock_read(struct fio_rwlock *); +extern void fio_rwlock_write(struct fio_rwlock *); +extern void fio_rwlock_unlock(struct fio_rwlock *); +extern struct fio_rwlock *fio_rwlock_init(void); +extern void fio_rwlock_remove(struct fio_rwlock *); #endif