From ce65232cf5039798045767c65f2110f3b2a8ffd0 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 30 Oct 2015 15:50:12 +0000 Subject: [PATCH] benchmarks/gem_wait: Remove pthread_cancel() Apparently the pthread shim on Android doesn't have pthread cancellation, so use the plain old volatile to terminate the CPU hogs. Signed-off-by: Chris Wilson --- benchmarks/gem_wait.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/benchmarks/gem_wait.c b/benchmarks/gem_wait.c index 912ffadc..6ebee50a 100644 --- a/benchmarks/gem_wait.c +++ b/benchmarks/gem_wait.c @@ -246,14 +246,14 @@ static void waiter(int child) close(fd); } +static volatile int done; + static void *thread(void *arg) { - uint64_t *c = arg; + volatile uint64_t *c = arg; - pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); - - while (1) - __sync_fetch_and_add(c, 1); + while (!done) + ++*c; return NULL; } @@ -272,12 +272,13 @@ static int run(int num_waiters) waiter(child); igt_waitchildren(); + done = 1; + for (int n = 0; n < num_cpus; n++) + pthread_join(threads[n], NULL); + count = 0; - for (int n = 0; n < num_cpus; n++) { - pthread_cancel(threads[n]); - __sync_synchronize(); + for (int n = 0; n < num_cpus; n++) count += counters[8*n]; - } printf("%llu\n", (long long unsigned)count); return 0;