t/run-fio-tests.py: Accept a wider range of IOPS values
[fio.git] / pshared.c
index 74812ede35ecc0ecf51f09b9c3a444ca4563110c..e671c87f86bf4f7601192f4ea5b1887d1ad13f12 100644 (file)
--- a/pshared.c
+++ b/pshared.c
@@ -21,6 +21,15 @@ int cond_init_pshared(pthread_cond_t *cond)
                return ret;
        }
 #endif
+
+#ifdef CONFIG_PTHREAD_CONDATTR_SETCLOCK
+       ret = pthread_condattr_setclock(&cattr, CLOCK_MONOTONIC);
+       if (ret) {
+               log_err("pthread_condattr_setclock: %s\n", strerror(ret));
+               return ret;
+       }
+#endif
+
        ret = pthread_cond_init(cond, &cattr);
        if (ret) {
                log_err("pthread_cond_init: %s\n", strerror(ret));
@@ -30,7 +39,7 @@ int cond_init_pshared(pthread_cond_t *cond)
        return 0;
 }
 
-int mutex_init_pshared(pthread_mutex_t *mutex)
+int mutex_init_pshared_with_type(pthread_mutex_t *mutex, int type)
 {
        pthread_mutexattr_t mattr;
        int ret;
@@ -42,7 +51,7 @@ int mutex_init_pshared(pthread_mutex_t *mutex)
        }
 
        /*
-        * Not all platforms support process shared mutexes (FreeBSD)
+        * Not all platforms support process shared mutexes (NetBSD/OpenBSD)
         */
 #ifdef CONFIG_PSHARED
        ret = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
@@ -51,6 +60,14 @@ int mutex_init_pshared(pthread_mutex_t *mutex)
                return ret;
        }
 #endif
+       if (type) {
+               ret = pthread_mutexattr_settype(&mattr, type);
+               if (ret) {
+                       log_err("pthread_mutexattr_settype: %s\n",
+                               strerror(ret));
+                       return ret;
+               }
+       }
        ret = pthread_mutex_init(mutex, &mattr);
        if (ret) {
                log_err("pthread_mutex_init: %s\n", strerror(ret));
@@ -60,6 +77,11 @@ int mutex_init_pshared(pthread_mutex_t *mutex)
        return 0;
 }
 
+int mutex_init_pshared(pthread_mutex_t *mutex)
+{
+       return mutex_init_pshared_with_type(mutex, 0);
+}
+
 int mutex_cond_init_pshared(pthread_mutex_t *mutex, pthread_cond_t *cond)
 {
        int ret;