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 <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2015-10-30 15:50:12 +00:00
parent 9024a72d29
commit ce65232cf5

View File

@ -246,14 +246,14 @@ static void waiter(int child)
close(fd); close(fd);
} }
static volatile int done;
static void *thread(void *arg) static void *thread(void *arg)
{ {
uint64_t *c = arg; volatile uint64_t *c = arg;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); while (!done)
++*c;
while (1)
__sync_fetch_and_add(c, 1);
return NULL; return NULL;
} }
@ -272,12 +272,13 @@ static int run(int num_waiters)
waiter(child); waiter(child);
igt_waitchildren(); igt_waitchildren();
done = 1;
for (int n = 0; n < num_cpus; n++)
pthread_join(threads[n], NULL);
count = 0; count = 0;
for (int n = 0; n < num_cpus; n++) { for (int n = 0; n < num_cpus; n++)
pthread_cancel(threads[n]);
__sync_synchronize();
count += counters[8*n]; count += counters[8*n];
}
printf("%llu\n", (long long unsigned)count); printf("%llu\n", (long long unsigned)count);
return 0; return 0;