diff options
Diffstat (limited to 'test/core/support/cpu_test.c')
-rw-r--r-- | test/core/support/cpu_test.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/test/core/support/cpu_test.c b/test/core/support/cpu_test.c index fa83878a15..a5c52442ad 100644 --- a/test/core/support/cpu_test.c +++ b/test/core/support/cpu_test.c @@ -69,18 +69,18 @@ struct cpu_test { gpr_mu mu; int nthreads; - gpr_uint32 ncores; + uint32_t ncores; int is_done; gpr_cv done_cv; - int *used; /* is this core used? */ - int r; /* random number */ + int *used; /* is this core used? */ + unsigned r; /* random number */ }; static void worker_thread(void *arg) { struct cpu_test *ct = (struct cpu_test *)arg; - gpr_uint32 cpu; - int r = 12345678; - int i, j; + uint32_t cpu; + unsigned r = 12345678; + unsigned i, j; for (i = 0; i < 1000 / GRPC_TEST_SLOWDOWN_FACTOR; i++) { /* run for a bit - just calculate something random. */ for (j = 0; j < 1000000 / GRPC_TEST_SLOWDOWN_FACTOR; j++) { @@ -90,7 +90,13 @@ static void worker_thread(void *arg) { GPR_ASSERT(cpu < ct->ncores); gpr_mu_lock(&ct->mu); ct->used[cpu] = 1; + for (j = 0; j < ct->ncores; j++) { + if (!ct->used[j]) break; + } gpr_mu_unlock(&ct->mu); + if (j == ct->ncores) { + break; /* all cpus have been used - no further use in running this test */ + } } gpr_mu_lock(&ct->mu); ct->r = r; /* make it look like we care about r's value... */ @@ -103,7 +109,7 @@ static void worker_thread(void *arg) { } static void cpu_test(void) { - gpr_uint32 i; + uint32_t i; int cores_seen = 0; struct cpu_test ct; gpr_thd_id thd; |