From: Roland Dreier Date: Wed, 7 Oct 2009 20:01:42 +0000 (+0200) Subject: Fix problem with mutexes and MONOTONIC clock X-Git-Tag: fio-1.34.2~3 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=666bf1234912c3790ff1e6204596891c6ef7180c;hp=b767c7f8e3fd8efff51debe39149c65028cf963d Fix problem with mutexes and MONOTONIC clock With the latest fio git tree, I get: fio: job startup hung? exiting. on startup, and it looks like the latest commit, 69a852f5 ("Fix wrong clock source in mutex") breaks things for me (Ubuntu 9.10 beta). My system seems to use CLOCK_REALTIME for pthread_cond_timedwait() by default. The cleanest solution seems to be to explicitly set which clock to use in pthread_cond_timedwait() via pthread_condattr_setclock() when initializing the condition variable, although I'm not sure how portable this is away from modern Linux (ie do all platforms that fio cares about have pthread_condattr_setclock()?). Signed-off-by: Roland Dreier Signed-off-by: Jens Axboe --- diff --git a/mutex.c b/mutex.c index a4474374..ab7dc704 100644 --- a/mutex.c +++ b/mutex.c @@ -72,6 +72,7 @@ struct fio_mutex *fio_mutex_init(int value) pthread_condattr_init(&cond); pthread_condattr_setpshared(&cond, mflag); + pthread_condattr_setclock(&cond, CLOCK_MONOTONIC); pthread_cond_init(&mutex->cond, &cond); ret = pthread_mutex_init(&mutex->lock, &attr);