source: src/benchmark/mutex/pthreads.c @ f54a0ab

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since f54a0ab was f54a0ab, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Added benchmarks for mutex routines

  • Property mode set to 100644
File size: 381 bytes
Line 
1#include <pthread.h>
2#include <stdio.h>
3
4#include "bench.h"
5
6volatile unsigned long int counter = 0;
7
8pthread_mutex_t mutex;
9
10void __attribute__((noinline)) call() {
11         pthread_mutex_lock  (&mutex);
12         counter++;
13         pthread_mutex_unlock(&mutex);
14}
15
16int main(int argc, char* argv[]) {
17        BENCH(
18                for (size_t i = 0; i < n; i++) {
19                        call();
20                },
21                result
22        )
23
24        printf("%llu\n", result);
25}
Note: See TracBrowser for help on using the repository browser.