#include <sys/eventfd.h>
 #include <perf/cpumap.h>
 
+#include "../util/mutex.h"
 #include "../util/stat.h"
 #include <subcmd/parse-options.h>
 #include "bench.h"
 /* amount of fds to monitor, per thread */
 static unsigned int nfds = 64;
 
-static pthread_mutex_t thread_lock;
+static struct mutex thread_lock;
 static unsigned int threads_starting;
 static struct stats all_stats[EPOLL_NR_OPS];
-static pthread_cond_t thread_parent, thread_worker;
+static struct cond thread_parent, thread_worker;
 
 struct worker {
        int tid;
        struct timespec ts = { .tv_sec = 0,
                               .tv_nsec = 250 };
 
-       pthread_mutex_lock(&thread_lock);
+       mutex_lock(&thread_lock);
        threads_starting--;
        if (!threads_starting)
-               pthread_cond_signal(&thread_parent);
-       pthread_cond_wait(&thread_worker, &thread_lock);
-       pthread_mutex_unlock(&thread_lock);
+               cond_signal(&thread_parent);
+       cond_wait(&thread_worker, &thread_lock);
+       mutex_unlock(&thread_lock);
 
        /* Let 'em loose */
        do {
        for (i = 0; i < EPOLL_NR_OPS; i++)
                init_stats(&all_stats[i]);
 
-       pthread_mutex_init(&thread_lock, NULL);
-       pthread_cond_init(&thread_parent, NULL);
-       pthread_cond_init(&thread_worker, NULL);
+       mutex_init(&thread_lock);
+       cond_init(&thread_parent);
+       cond_init(&thread_worker);
 
        threads_starting = nthreads;
 
 
        do_threads(worker, cpu);
 
-       pthread_mutex_lock(&thread_lock);
+       mutex_lock(&thread_lock);
        while (threads_starting)
-               pthread_cond_wait(&thread_parent, &thread_lock);
-       pthread_cond_broadcast(&thread_worker);
-       pthread_mutex_unlock(&thread_lock);
+               cond_wait(&thread_parent, &thread_lock);
+       cond_broadcast(&thread_worker);
+       mutex_unlock(&thread_lock);
 
        sleep(nsecs);
        toggle_done(0, NULL, NULL);
        }
 
        /* cleanup & report results */
-       pthread_cond_destroy(&thread_parent);
-       pthread_cond_destroy(&thread_worker);
-       pthread_mutex_destroy(&thread_lock);
+       cond_destroy(&thread_parent);
+       cond_destroy(&thread_worker);
+       mutex_destroy(&thread_lock);
 
        for (i = 0; i < nthreads; i++) {
                unsigned long t[EPOLL_NR_OPS];
 
 #include <perf/cpumap.h>
 
 #include "../util/stat.h"
+#include "../util/mutex.h"
 #include <subcmd/parse-options.h>
 #include "bench.h"
 
 /* amount of fds to monitor, per thread */
 static unsigned int nfds = 64;
 
-static pthread_mutex_t thread_lock;
+static struct mutex thread_lock;
 static unsigned int threads_starting;
 static struct stats throughput_stats;
-static pthread_cond_t thread_parent, thread_worker;
+static struct cond thread_parent, thread_worker;
 
 struct worker {
        int tid;
        int to = nonblocking? 0 : -1;
        int efd = multiq ? w->epollfd : epollfd;
 
-       pthread_mutex_lock(&thread_lock);
+       mutex_lock(&thread_lock);
        threads_starting--;
        if (!threads_starting)
-               pthread_cond_signal(&thread_parent);
-       pthread_cond_wait(&thread_worker, &thread_lock);
-       pthread_mutex_unlock(&thread_lock);
+               cond_signal(&thread_parent);
+       cond_wait(&thread_worker, &thread_lock);
+       mutex_unlock(&thread_lock);
 
        do {
                /*
               getpid(), nthreads, oneshot ? " (EPOLLONESHOT semantics)": "", nfds, nsecs);
 
        init_stats(&throughput_stats);
-       pthread_mutex_init(&thread_lock, NULL);
-       pthread_cond_init(&thread_parent, NULL);
-       pthread_cond_init(&thread_worker, NULL);
+       mutex_init(&thread_lock);
+       cond_init(&thread_parent);
+       cond_init(&thread_worker);
 
        threads_starting = nthreads;
 
 
        do_threads(worker, cpu);
 
-       pthread_mutex_lock(&thread_lock);
+       mutex_lock(&thread_lock);
        while (threads_starting)
-               pthread_cond_wait(&thread_parent, &thread_lock);
-       pthread_cond_broadcast(&thread_worker);
-       pthread_mutex_unlock(&thread_lock);
+               cond_wait(&thread_parent, &thread_lock);
+       cond_broadcast(&thread_worker);
+       mutex_unlock(&thread_lock);
 
        /*
         * At this point the workers should be blocked waiting for read events
                err(EXIT_FAILURE, "pthread_join");
 
        /* cleanup & report results */
-       pthread_cond_destroy(&thread_parent);
-       pthread_cond_destroy(&thread_worker);
-       pthread_mutex_destroy(&thread_lock);
+       cond_destroy(&thread_parent);
+       cond_destroy(&thread_worker);
+       mutex_destroy(&thread_lock);
 
        /* sort the array back before reporting */
        if (randomize)
 
 #include <sys/mman.h>
 #include <perf/cpumap.h>
 
+#include "../util/mutex.h"
 #include "../util/stat.h"
 #include <subcmd/parse-options.h>
 #include "bench.h"
 static int futex_flag = 0;
 
 struct timeval bench__start, bench__end, bench__runtime;
-static pthread_mutex_t thread_lock;
+static struct mutex thread_lock;
 static unsigned int threads_starting;
 static struct stats throughput_stats;
-static pthread_cond_t thread_parent, thread_worker;
+static struct cond thread_parent, thread_worker;
 
 struct worker {
        int tid;
        unsigned int i;
        unsigned long ops = w->ops; /* avoid cacheline bouncing */
 
-       pthread_mutex_lock(&thread_lock);
+       mutex_lock(&thread_lock);
        threads_starting--;
        if (!threads_starting)
-               pthread_cond_signal(&thread_parent);
-       pthread_cond_wait(&thread_worker, &thread_lock);
-       pthread_mutex_unlock(&thread_lock);
+               cond_signal(&thread_parent);
+       cond_wait(&thread_worker, &thread_lock);
+       mutex_unlock(&thread_lock);
 
        do {
                for (i = 0; i < params.nfutexes; i++, ops++) {
               getpid(), params.nthreads, params.nfutexes, params.fshared ? "shared":"private", params.runtime);
 
        init_stats(&throughput_stats);
-       pthread_mutex_init(&thread_lock, NULL);
-       pthread_cond_init(&thread_parent, NULL);
-       pthread_cond_init(&thread_worker, NULL);
+       mutex_init(&thread_lock);
+       cond_init(&thread_parent);
+       cond_init(&thread_worker);
 
        threads_starting = params.nthreads;
        pthread_attr_init(&thread_attr);
        CPU_FREE(cpuset);
        pthread_attr_destroy(&thread_attr);
 
-       pthread_mutex_lock(&thread_lock);
+       mutex_lock(&thread_lock);
        while (threads_starting)
-               pthread_cond_wait(&thread_parent, &thread_lock);
-       pthread_cond_broadcast(&thread_worker);
-       pthread_mutex_unlock(&thread_lock);
+               cond_wait(&thread_parent, &thread_lock);
+       cond_broadcast(&thread_worker);
+       mutex_unlock(&thread_lock);
 
        sleep(params.runtime);
        toggle_done(0, NULL, NULL);
        }
 
        /* cleanup & report results */
-       pthread_cond_destroy(&thread_parent);
-       pthread_cond_destroy(&thread_worker);
-       pthread_mutex_destroy(&thread_lock);
+       cond_destroy(&thread_parent);
+       cond_destroy(&thread_worker);
+       mutex_destroy(&thread_lock);
 
        for (i = 0; i < params.nthreads; i++) {
                unsigned long t = bench__runtime.tv_sec > 0 ?
 
 #include <pthread.h>
 
 #include <signal.h>
+#include "../util/mutex.h"
 #include "../util/stat.h"
 #include <subcmd/parse-options.h>
 #include <linux/compiler.h>
 static struct worker *worker;
 static bool done = false;
 static int futex_flag = 0;
-static pthread_mutex_t thread_lock;
+static struct mutex thread_lock;
 static unsigned int threads_starting;
 static struct stats throughput_stats;
-static pthread_cond_t thread_parent, thread_worker;
+static struct cond thread_parent, thread_worker;
 
 static struct bench_futex_parameters params = {
        .runtime  = 10,
        struct worker *w = (struct worker *) arg;
        unsigned long ops = w->ops;
 
-       pthread_mutex_lock(&thread_lock);
+       mutex_lock(&thread_lock);
        threads_starting--;
        if (!threads_starting)
-               pthread_cond_signal(&thread_parent);
-       pthread_cond_wait(&thread_worker, &thread_lock);
-       pthread_mutex_unlock(&thread_lock);
+               cond_signal(&thread_parent);
+       cond_wait(&thread_worker, &thread_lock);
+       mutex_unlock(&thread_lock);
 
        do {
                int ret;
               getpid(), params.nthreads, params.runtime);
 
        init_stats(&throughput_stats);
-       pthread_mutex_init(&thread_lock, NULL);
-       pthread_cond_init(&thread_parent, NULL);
-       pthread_cond_init(&thread_worker, NULL);
+       mutex_init(&thread_lock);
+       cond_init(&thread_parent);
+       cond_init(&thread_worker);
 
        threads_starting = params.nthreads;
        pthread_attr_init(&thread_attr);
        create_threads(worker, thread_attr, cpu);
        pthread_attr_destroy(&thread_attr);
 
-       pthread_mutex_lock(&thread_lock);
+       mutex_lock(&thread_lock);
        while (threads_starting)
-               pthread_cond_wait(&thread_parent, &thread_lock);
-       pthread_cond_broadcast(&thread_worker);
-       pthread_mutex_unlock(&thread_lock);
+               cond_wait(&thread_parent, &thread_lock);
+       cond_broadcast(&thread_worker);
+       mutex_unlock(&thread_lock);
 
        sleep(params.runtime);
        toggle_done(0, NULL, NULL);
        }
 
        /* cleanup & report results */
-       pthread_cond_destroy(&thread_parent);
-       pthread_cond_destroy(&thread_worker);
-       pthread_mutex_destroy(&thread_lock);
+       cond_destroy(&thread_parent);
+       cond_destroy(&thread_worker);
+       mutex_destroy(&thread_lock);
 
        for (i = 0; i < params.nthreads; i++) {
                unsigned long t = bench__runtime.tv_sec > 0 ?
 
 #include <pthread.h>
 
 #include <signal.h>
+#include "../util/mutex.h"
 #include "../util/stat.h"
 #include <subcmd/parse-options.h>
 #include <linux/compiler.h>
 
 static pthread_t *worker;
 static bool done = false;
-static pthread_mutex_t thread_lock;
-static pthread_cond_t thread_parent, thread_worker;
+static struct mutex thread_lock;
+static struct cond thread_parent, thread_worker;
 static struct stats requeuetime_stats, requeued_stats;
 static unsigned int threads_starting;
 static int futex_flag = 0;
 {
        int ret;
 
-       pthread_mutex_lock(&thread_lock);
+       mutex_lock(&thread_lock);
        threads_starting--;
        if (!threads_starting)
-               pthread_cond_signal(&thread_parent);
-       pthread_cond_wait(&thread_worker, &thread_lock);
-       pthread_mutex_unlock(&thread_lock);
+               cond_signal(&thread_parent);
+       cond_wait(&thread_worker, &thread_lock);
+       mutex_unlock(&thread_lock);
 
        while (1) {
                if (!params.pi) {
        init_stats(&requeued_stats);
        init_stats(&requeuetime_stats);
        pthread_attr_init(&thread_attr);
-       pthread_mutex_init(&thread_lock, NULL);
-       pthread_cond_init(&thread_parent, NULL);
-       pthread_cond_init(&thread_worker, NULL);
+       mutex_init(&thread_lock);
+       cond_init(&thread_parent);
+       cond_init(&thread_worker);
 
        for (j = 0; j < bench_repeat && !done; j++) {
                unsigned int nrequeued = 0, wakeups = 0;
                block_threads(worker, thread_attr, cpu);
 
                /* make sure all threads are already blocked */
-               pthread_mutex_lock(&thread_lock);
+               mutex_lock(&thread_lock);
                while (threads_starting)
-                       pthread_cond_wait(&thread_parent, &thread_lock);
-               pthread_cond_broadcast(&thread_worker);
-               pthread_mutex_unlock(&thread_lock);
+                       cond_wait(&thread_parent, &thread_lock);
+               cond_broadcast(&thread_worker);
+               mutex_unlock(&thread_lock);
 
                usleep(100000);
 
        }
 
        /* cleanup & report results */
-       pthread_cond_destroy(&thread_parent);
-       pthread_cond_destroy(&thread_worker);
-       pthread_mutex_destroy(&thread_lock);
+       cond_destroy(&thread_parent);
+       cond_destroy(&thread_worker);
+       mutex_destroy(&thread_lock);
        pthread_attr_destroy(&thread_attr);
 
        print_summary();
 
 #include "bench.h"
 #include <linux/compiler.h>
 #include "../util/debug.h"
+#include "../util/mutex.h"
 
 #ifndef HAVE_PTHREAD_BARRIER
 int bench_futex_wake_parallel(int argc __maybe_unused, const char **argv __maybe_unused)
 
 static pthread_t *blocked_worker;
 static bool done = false;
-static pthread_mutex_t thread_lock;
-static pthread_cond_t thread_parent, thread_worker;
+static struct mutex thread_lock;
+static struct cond thread_parent, thread_worker;
 static pthread_barrier_t barrier;
 static struct stats waketime_stats, wakeup_stats;
 static unsigned int threads_starting;
 
 static void *blocked_workerfn(void *arg __maybe_unused)
 {
-       pthread_mutex_lock(&thread_lock);
+       mutex_lock(&thread_lock);
        threads_starting--;
        if (!threads_starting)
-               pthread_cond_signal(&thread_parent);
-       pthread_cond_wait(&thread_worker, &thread_lock);
-       pthread_mutex_unlock(&thread_lock);
+               cond_signal(&thread_parent);
+       cond_wait(&thread_worker, &thread_lock);
+       mutex_unlock(&thread_lock);
 
        while (1) { /* handle spurious wakeups */
                if (futex_wait(&futex, 0, NULL, futex_flag) != EINTR)
        init_stats(&waketime_stats);
 
        pthread_attr_init(&thread_attr);
-       pthread_mutex_init(&thread_lock, NULL);
-       pthread_cond_init(&thread_parent, NULL);
-       pthread_cond_init(&thread_worker, NULL);
+       mutex_init(&thread_lock);
+       cond_init(&thread_parent);
+       cond_init(&thread_worker);
 
        for (j = 0; j < bench_repeat && !done; j++) {
                waking_worker = calloc(params.nwakes, sizeof(*waking_worker));
                block_threads(blocked_worker, thread_attr, cpu);
 
                /* make sure all threads are already blocked */
-               pthread_mutex_lock(&thread_lock);
+               mutex_lock(&thread_lock);
                while (threads_starting)
-                       pthread_cond_wait(&thread_parent, &thread_lock);
-               pthread_cond_broadcast(&thread_worker);
-               pthread_mutex_unlock(&thread_lock);
+                       cond_wait(&thread_parent, &thread_lock);
+               cond_broadcast(&thread_worker);
+               mutex_unlock(&thread_lock);
 
                usleep(100000);
 
        }
 
        /* cleanup & report results */
-       pthread_cond_destroy(&thread_parent);
-       pthread_cond_destroy(&thread_worker);
-       pthread_mutex_destroy(&thread_lock);
+       cond_destroy(&thread_parent);
+       cond_destroy(&thread_worker);
+       mutex_destroy(&thread_lock);
        pthread_attr_destroy(&thread_attr);
 
        print_summary();
 
 #include <pthread.h>
 
 #include <signal.h>
+#include "../util/mutex.h"
 #include "../util/stat.h"
 #include <subcmd/parse-options.h>
 #include <linux/compiler.h>
 
 static pthread_t *worker;
 static bool done = false;
-static pthread_mutex_t thread_lock;
-static pthread_cond_t thread_parent, thread_worker;
+static struct mutex thread_lock;
+static struct cond thread_parent, thread_worker;
 static struct stats waketime_stats, wakeup_stats;
 static unsigned int threads_starting;
 static int futex_flag = 0;
 
 static void *workerfn(void *arg __maybe_unused)
 {
-       pthread_mutex_lock(&thread_lock);
+       mutex_lock(&thread_lock);
        threads_starting--;
        if (!threads_starting)
-               pthread_cond_signal(&thread_parent);
-       pthread_cond_wait(&thread_worker, &thread_lock);
-       pthread_mutex_unlock(&thread_lock);
+               cond_signal(&thread_parent);
+       cond_wait(&thread_worker, &thread_lock);
+       mutex_unlock(&thread_lock);
 
        while (1) {
                if (futex_wait(&futex1, 0, NULL, futex_flag) != EINTR)
        init_stats(&wakeup_stats);
        init_stats(&waketime_stats);
        pthread_attr_init(&thread_attr);
-       pthread_mutex_init(&thread_lock, NULL);
-       pthread_cond_init(&thread_parent, NULL);
-       pthread_cond_init(&thread_worker, NULL);
+       mutex_init(&thread_lock);
+       cond_init(&thread_parent);
+       cond_init(&thread_worker);
 
        for (j = 0; j < bench_repeat && !done; j++) {
                unsigned int nwoken = 0;
                block_threads(worker, thread_attr, cpu);
 
                /* make sure all threads are already blocked */
-               pthread_mutex_lock(&thread_lock);
+               mutex_lock(&thread_lock);
                while (threads_starting)
-                       pthread_cond_wait(&thread_parent, &thread_lock);
-               pthread_cond_broadcast(&thread_worker);
-               pthread_mutex_unlock(&thread_lock);
+                       cond_wait(&thread_parent, &thread_lock);
+               cond_broadcast(&thread_worker);
+               mutex_unlock(&thread_lock);
 
                usleep(100000);
 
        }
 
        /* cleanup & report results */
-       pthread_cond_destroy(&thread_parent);
-       pthread_cond_destroy(&thread_worker);
-       pthread_mutex_destroy(&thread_lock);
+       cond_destroy(&thread_parent);
+       cond_destroy(&thread_worker);
+       mutex_destroy(&thread_lock);
        pthread_attr_destroy(&thread_attr);
 
        print_summary();
 
  */
 
 #include <inttypes.h>
-/* For the CLR_() macros */
-#include <pthread.h>
 
 #include <subcmd/parse-options.h>
 #include "../util/cloexec.h"
 #include <linux/zalloc.h>
 
 #include "../util/header.h"
+#include "../util/mutex.h"
 #include <numa.h>
 #include <numaif.h>
 
        u64                     system_time_ns;
        u64                     user_time_ns;
        double                  speed_gbs;
-       pthread_mutex_t         *process_lock;
+       struct mutex            *process_lock;
 };
 
 /* Parameters set by options: */
 struct global_info {
        u8                      *data;
 
-       pthread_mutex_t         startup_mutex;
-       pthread_cond_t          startup_cond;
+       struct mutex            startup_mutex;
+       struct cond             startup_cond;
        int                     nr_tasks_started;
 
-       pthread_mutex_t         start_work_mutex;
-       pthread_cond_t          start_work_cond;
+       struct mutex            start_work_mutex;
+       struct cond             start_work_cond;
        int                     nr_tasks_working;
        bool                    start_work;
 
-       pthread_mutex_t         stop_work_mutex;
+       struct mutex            stop_work_mutex;
        u64                     bytes_done;
 
        struct thread_data      *threads;
        return alloc_data(bytes, MAP_PRIVATE, 0, g->p.init_cpu0,  g->p.thp, g->p.init_random);
 }
 
-/*
- * Return a process-shared (global) mutex:
- */
-static void init_global_mutex(pthread_mutex_t *mutex)
-{
-       pthread_mutexattr_t attr;
-
-       pthread_mutexattr_init(&attr);
-       pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
-       pthread_mutex_init(mutex, &attr);
-}
-
-/*
- * Return a process-shared (global) condition variable:
- */
-static void init_global_cond(pthread_cond_t *cond)
-{
-       pthread_condattr_t attr;
-
-       pthread_condattr_init(&attr);
-       pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
-       pthread_cond_init(cond, &attr);
-}
-
 static int parse_cpu_list(const char *arg)
 {
        p0.cpu_list_str = strdup(arg);
        }
 
        if (g->p.serialize_startup) {
-               pthread_mutex_lock(&g->startup_mutex);
+               mutex_lock(&g->startup_mutex);
                g->nr_tasks_started++;
                /* The last thread wakes the main process. */
                if (g->nr_tasks_started == g->p.nr_tasks)
-                       pthread_cond_signal(&g->startup_cond);
+                       cond_signal(&g->startup_cond);
 
-               pthread_mutex_unlock(&g->startup_mutex);
+               mutex_unlock(&g->startup_mutex);
 
                /* Here we will wait for the main process to start us all at once: */
-               pthread_mutex_lock(&g->start_work_mutex);
+               mutex_lock(&g->start_work_mutex);
                g->start_work = false;
                g->nr_tasks_working++;
                while (!g->start_work)
-                       pthread_cond_wait(&g->start_work_cond, &g->start_work_mutex);
+                       cond_wait(&g->start_work_cond, &g->start_work_mutex);
 
-               pthread_mutex_unlock(&g->start_work_mutex);
+               mutex_unlock(&g->start_work_mutex);
        }
 
        gettimeofday(&start0, NULL);
                val += do_work(thread_data,  g->p.bytes_thread,  0,          1,         l, val);
 
                if (g->p.sleep_usecs) {
-                       pthread_mutex_lock(td->process_lock);
+                       mutex_lock(td->process_lock);
                        usleep(g->p.sleep_usecs);
-                       pthread_mutex_unlock(td->process_lock);
+                       mutex_unlock(td->process_lock);
                }
                /*
                 * Amount of work to be done under a process-global lock:
                 */
                if (g->p.bytes_process_locked) {
-                       pthread_mutex_lock(td->process_lock);
+                       mutex_lock(td->process_lock);
                        val += do_work(process_data, g->p.bytes_process_locked, thread_nr,  g->p.nr_threads,    l, val);
-                       pthread_mutex_unlock(td->process_lock);
+                       mutex_unlock(td->process_lock);
                }
 
                work_done = g->p.bytes_global + g->p.bytes_process +
 
        free_data(thread_data, g->p.bytes_thread);
 
-       pthread_mutex_lock(&g->stop_work_mutex);
+       mutex_lock(&g->stop_work_mutex);
        g->bytes_done += bytes_done;
-       pthread_mutex_unlock(&g->stop_work_mutex);
+       mutex_unlock(&g->stop_work_mutex);
 
        return NULL;
 }
  */
 static void worker_process(int process_nr)
 {
-       pthread_mutex_t process_lock;
+       struct mutex process_lock;
        struct thread_data *td;
        pthread_t *pthreads;
        u8 *process_data;
        int ret;
        int t;
 
-       pthread_mutex_init(&process_lock, NULL);
+       mutex_init(&process_lock);
        set_taskname("process %d", process_nr);
 
        /*
        g->data = setup_shared_data(g->p.bytes_global);
 
        /* Startup serialization: */
-       init_global_mutex(&g->start_work_mutex);
-       init_global_cond(&g->start_work_cond);
-       init_global_mutex(&g->startup_mutex);
-       init_global_cond(&g->startup_cond);
-       init_global_mutex(&g->stop_work_mutex);
+       mutex_init_pshared(&g->start_work_mutex);
+       cond_init_pshared(&g->start_work_cond);
+       mutex_init_pshared(&g->startup_mutex);
+       cond_init_pshared(&g->startup_cond);
+       mutex_init_pshared(&g->stop_work_mutex);
 
        init_thread_data();
 
                 * Wait for all the threads to start up. The last thread will
                 * signal this process.
                 */
-               pthread_mutex_lock(&g->startup_mutex);
+               mutex_lock(&g->startup_mutex);
                while (g->nr_tasks_started != g->p.nr_tasks)
-                       pthread_cond_wait(&g->startup_cond, &g->startup_mutex);
+                       cond_wait(&g->startup_cond, &g->startup_mutex);
 
-               pthread_mutex_unlock(&g->startup_mutex);
+               mutex_unlock(&g->startup_mutex);
 
                /* Wait for all threads to be at the start_work_cond. */
                while (!threads_ready) {
-                       pthread_mutex_lock(&g->start_work_mutex);
+                       mutex_lock(&g->start_work_mutex);
                        threads_ready = (g->nr_tasks_working == g->p.nr_tasks);
-                       pthread_mutex_unlock(&g->start_work_mutex);
+                       mutex_unlock(&g->start_work_mutex);
                        if (!threads_ready)
                                usleep(1);
                }
 
                start = stop;
                /* Start all threads running. */
-               pthread_mutex_lock(&g->start_work_mutex);
+               mutex_lock(&g->start_work_mutex);
                g->start_work = true;
-               pthread_mutex_unlock(&g->start_work_mutex);
-               pthread_cond_broadcast(&g->start_work_cond);
+               mutex_unlock(&g->start_work_mutex);
+               cond_broadcast(&g->start_work_cond);
        } else {
                gettimeofday(&start, NULL);
        }