projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update OS support line
[fio.git]
/
mutex.c
diff --git
a/mutex.c
b/mutex.c
index 34b3324ca7d395f49e1579390ba2f60322dd2ba1..88044f3a818753feb374bc0370e545fb2095d248 100644
(file)
--- a/
mutex.c
+++ b/
mutex.c
@@
-11,6
+11,7
@@
#include "mutex.h"
#include "arch/arch.h"
#include "os/os.h"
#include "mutex.h"
#include "arch/arch.h"
#include "os/os.h"
+#include "helpers.h"
void fio_mutex_remove(struct fio_mutex *mutex)
{
void fio_mutex_remove(struct fio_mutex *mutex)
{
@@
-32,6
+33,14
@@
struct fio_mutex *fio_mutex_init(int value)
return NULL;
}
return NULL;
}
+#ifdef FIO_HAVE_FALLOCATE
+ ret = posix_fallocate(fd, 0, sizeof(struct fio_mutex));
+ if (ret > 0) {
+ fprintf(stderr, "posix_fallocate mutex failed: %s\n", strerror(ret));
+ goto err;
+ }
+#endif
+
if (ftruncate(fd, sizeof(struct fio_mutex)) < 0) {
perror("ftruncate mutex");
goto err;
if (ftruncate(fd, sizeof(struct fio_mutex)) < 0) {
perror("ftruncate mutex");
goto err;
@@
-64,15
+73,18
@@
struct fio_mutex *fio_mutex_init(int value)
log_err("pthread_mutexattr_init: %s\n", strerror(ret));
goto err;
}
log_err("pthread_mutexattr_init: %s\n", strerror(ret));
goto err;
}
+#ifdef FIO_HAVE_PSHARED_MUTEX
ret = pthread_mutexattr_setpshared(&attr, mflag);
if (ret) {
log_err("pthread_mutexattr_setpshared: %s\n", strerror(ret));
goto err;
}
ret = pthread_mutexattr_setpshared(&attr, mflag);
if (ret) {
log_err("pthread_mutexattr_setpshared: %s\n", strerror(ret));
goto err;
}
+#endif
pthread_condattr_init(&cond);
pthread_condattr_init(&cond);
+#ifdef FIO_HAVE_PSHARED_MUTEX
pthread_condattr_setpshared(&cond, mflag);
pthread_condattr_setpshared(&cond, mflag);
- pthread_condattr_setclock(&cond, CLOCK_MONOTONIC);
+#endif
pthread_cond_init(&mutex->cond, &cond);
ret = pthread_mutex_init(&mutex->lock, &attr);
pthread_cond_init(&mutex->cond, &cond);
ret = pthread_mutex_init(&mutex->lock, &attr);
@@
-95,7
+107,7
@@
int fio_mutex_down_timeout(struct fio_mutex *mutex, unsigned int seconds)
struct timespec t;
int ret = 0;
struct timespec t;
int ret = 0;
- clock_gettime(CLOCK_
MONOTONIC
, &t);
+ clock_gettime(CLOCK_
REALTIME
, &t);
t.tv_sec += seconds;
pthread_mutex_lock(&mutex->lock);
t.tv_sec += seconds;
pthread_mutex_lock(&mutex->lock);