X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=helper_thread.c;h=f031df4de508855120d41268dd32f6f05049a508;hp=c14296fb51a2d8be73dea42fd793c66b97743fb4;hb=9bbefaa2056e8551805bbf8915adbc81cedd68e8;hpb=f9e5b5ee74e8282199eda9318865ffdc7645a384 diff --git a/helper_thread.c b/helper_thread.c index c14296fb..f031df4d 100644 --- a/helper_thread.c +++ b/helper_thread.c @@ -110,12 +110,8 @@ static void *helper_thread_main(void *data) msec_to_next_event = DISK_UTIL_MSEC; if (since_du >= DISK_UTIL_MSEC) msec_to_next_event -= (since_du - DISK_UTIL_MSEC); - } else { - if (since_du >= DISK_UTIL_MSEC) - msec_to_next_event = DISK_UTIL_MSEC - (DISK_UTIL_MSEC - since_du); - else - msec_to_next_event = DISK_UTIL_MSEC; - } + } else + msec_to_next_event = DISK_UTIL_MSEC - since_du; if (hd->do_stat) { hd->do_stat = 0; @@ -142,38 +138,17 @@ int helper_thread_create(struct fio_mutex *startup_mutex, struct sk_out *sk_out) { struct helper_data *hd; int ret; - pthread_condattr_t cattr; - pthread_mutexattr_t mattr; hd = smalloc(sizeof(*hd)); setup_disk_util(); hd->sk_out = sk_out; - ret = pthread_mutexattr_init(&mattr); - if (ret) { - log_err("pthread_mutexattr_init: %s\n", strerror(ret)); - return 1; - } - ret = pthread_condattr_init(&cattr); - if (ret) { - log_err("pthread_condattr_init: %s\n", strerror(ret)); - return 1; - } -#ifdef FIO_HAVE_PSHARED_MUTEX - ret = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED); - if (ret) { - log_err("pthread_mutexattr_setpshared: %s\n", strerror(ret)); - return 1; - } - ret = pthread_condattr_setpshared(&cattr, PTHREAD_PROCESS_SHARED); - if (ret) { - log_err("pthread_mutexattr_setpshared: %s\n", strerror(ret)); + + ret = mutex_cond_init_pshared(&hd->lock, &hd->cond); + if (ret) return 1; - } -#endif - pthread_cond_init(&hd->cond, &cattr); - pthread_mutex_init(&hd->lock, &mattr); + hd->startup_mutex = startup_mutex; ret = pthread_create(&hd->thread, NULL, helper_thread_main, hd);