mutex-perf/mutexperf.c
/* Simply acquiring and releasing a lock, without any contention. */
Simply acquiring and releasing a lock, without any contention.
Simply acquiring and releasing a lock without any contention .
__attribute__((unused))
static void lock_unlock(struct test_results *res)
{
    pthread_mutex_t mutex;
    pthread_mutex_init(&mutex, NULL);
    res->start = now_usecs();
    for (int i = res->reps; i--;) {
        pthread_mutex_lock(&mutex);
        pthread_mutex_unlock(&mutex);
    }
    res->stop = now_usecs();
    pthread_mutex_destroy(&mutex);
}
__attribute__ ( ( unused ) ) static void lock_unlock ( struct test_results * res ) { pthread_mutex_t mutex ; pthread_mutex_init ( & mutex , NULL ) ; res -> start = now_usecs ( ) ; for ( int i = res -> reps ; i -- ; ) { pthread_mutex_lock ( & mutex ) ; pthread_mutex_unlock ( & mutex ) ; } res -> stop = now_usecs ( ) ; pthread_mutex_destroy ( & mutex ) ; }
Simply acquiring and releasing a lock, without any contention.
Simply acquiring and releasing a lock without any contention .