X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=mutex.c;h=9ee3bd838cb1ae801b71f2604f94441264130343;hb=5fe4c88681360025fa4662c3898edd33f0d7585c;hp=466e20ed1111ea0cad675165b8eea9ab298a7ef2;hpb=72242057a25b59d01b3d4e1343c94cc7ac354950;p=fio.git diff --git a/mutex.c b/mutex.c index 466e20ed..9ee3bd83 100644 --- a/mutex.c +++ b/mutex.c @@ -15,7 +15,7 @@ #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) @@ -162,14 +162,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)