summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.c9
-rw-r--r--mutex.c15
-rw-r--r--os/os-linux.h1
-rw-r--r--os/os-solaris.h1
4 files changed, 23 insertions, 3 deletions
diff --git a/init.c b/init.c
index a8acdc04..3142d8ca 100644
--- a/init.c
+++ b/init.c
@@ -214,6 +214,15 @@ static int fixup_options(struct thread_data *td)
{
struct thread_options *o = &td->o;
+#ifndef FIO_HAVE_PSHARED_MUTEX
+ if (!td->o.use_thread) {
+ log_info("fio: this platform does not support process shared"
+ " mutexes, forcing use of threads. Use the 'thread'"
+ " option to get rid of this warning.\n");
+ td->o.use_thread = 1;
+ }
+#endif
+
#ifndef FIO_HAVE_CPU_AFFINITY
if (td->o.gtod_cpu) {
log_err("fio: platform must support CPU affinity for"
diff --git a/mutex.c b/mutex.c
index 7d072186..5beaa08f 100644
--- a/mutex.c
+++ b/mutex.c
@@ -22,7 +22,7 @@ struct fio_mutex *fio_mutex_init(int value)
struct fio_mutex *mutex = NULL;
pthread_mutexattr_t attr;
pthread_condattr_t cond;
- int fd, ret;
+ int fd, ret, mflag;
fd = mkstemp(mutex_name);
if (fd < 0) {
@@ -48,19 +48,28 @@ struct fio_mutex *fio_mutex_init(int value)
mutex->mutex_fd = fd;
mutex->value = value;
+ /*
+ * Not all platforms support process shared mutexes (FreeBSD)
+ */
+#ifdef FIO_HAVE_PSHARED_MUTEX
+ mflag = PTHREAD_PROCESS_SHARED;
+#else
+ mflag = PTHREAD_PROCESS_PRIVATE;
+#endif
+
ret = pthread_mutexattr_init(&attr);
if (ret) {
log_err("pthread_mutexattr_init: %s\n", strerror(ret));
goto err;
}
- ret = pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
+ ret = pthread_mutexattr_setpshared(&attr, mflag);
if (ret) {
log_err("pthread_mutexattr_setpshared: %s\n", strerror(ret));
goto err;
}
pthread_condattr_init(&cond);
- pthread_condattr_setpshared(&cond, PTHREAD_PROCESS_SHARED);
+ pthread_condattr_setpshared(&cond, mflag);
pthread_cond_init(&mutex->cond, &cond);
ret = pthread_mutex_init(&mutex->lock, &attr);
diff --git a/os/os-linux.h b/os/os-linux.h
index 03d2450c..a2a9b249 100644
--- a/os/os-linux.h
+++ b/os/os-linux.h
@@ -28,6 +28,7 @@
#define FIO_HAVE_STRSEP
#define FIO_HAVE_FALLOCATE
#define FIO_HAVE_POSIXAIO_FSYNC
+#define FIO_HAVE_PSHARED_MUTEX
#define OS_MAP_ANON MAP_ANONYMOUS
diff --git a/os/os-solaris.h b/os/os-solaris.h
index 51c0ff4b..35148d2d 100644
--- a/os/os-solaris.h
+++ b/os/os-solaris.h
@@ -10,6 +10,7 @@
#define FIO_HAVE_FALLOCATE
#define FIO_HAVE_POSIXAIO_FSYNC
#define FIO_HAVE_CPU_AFFINITY
+#define FIO_HAVE_PSHARED_MUTEX
#define OS_MAP_ANON MAP_ANON
#define OS_RAND_MAX 2147483648UL