X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=mutex.c;h=53f9651a9887538be42addc8db55a5969bd7b974;hp=466e20ed1111ea0cad675165b8eea9ab298a7ef2;hb=f672ef67527a27eb2bbc59aa6041a42d88a00838;hpb=72242057a25b59d01b3d4e1343c94cc7ac354950 diff --git a/mutex.c b/mutex.c index 466e20ed..53f9651a 100644 --- a/mutex.c +++ b/mutex.c @@ -15,13 +15,18 @@ #include "arch/arch.h" #include "os/os.h" #include "helpers.h" -#include "time.h" +#include "fio_time.h" #include "gettime.h" -void fio_mutex_remove(struct fio_mutex *mutex) +void __fio_mutex_remove(struct fio_mutex *mutex) { assert(mutex->magic == FIO_MUTEX_MAGIC); pthread_cond_destroy(&mutex->cond); +} + +void fio_mutex_remove(struct fio_mutex *mutex) +{ + __fio_mutex_remove(mutex); munmap((void *) mutex, sizeof(*mutex)); } @@ -162,14 +167,19 @@ void fio_mutex_down(struct fio_mutex *mutex) void fio_mutex_up(struct fio_mutex *mutex) { + int do_wake = 0; + assert(mutex->magic == FIO_MUTEX_MAGIC); pthread_mutex_lock(&mutex->lock); read_barrier(); if (!mutex->value && mutex->waiters) - pthread_cond_signal(&mutex->cond); + do_wake = 1; mutex->value++; pthread_mutex_unlock(&mutex->lock); + + if (do_wake) + pthread_cond_signal(&mutex->cond); } void fio_rwlock_write(struct fio_rwlock *lock)