diff options
Diffstat (limited to 'helper/test/linux/process.c')
-rw-r--r-- | helper/test/linux/process.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/helper/test/linux/process.c b/helper/test/linux/process.c index e08ef8686..54614a695 100644 --- a/helper/test/linux/process.c +++ b/helper/test/linux/process.c @@ -1,17 +1,17 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2015-2018 Linaro Limited */ -#include <odph_debug.h> #include <odp_api.h> +#include <odp/helper/odph_api.h> #include <odp/helper/linux/pthread.h> #include <odp/helper/linux/process.h> +#include <string.h> + #define NUMBER_WORKERS 16 /* 0 = max */ -static void *worker_fn(void *arg ODPH_UNUSED) +static void *worker_fn(void *arg ODP_UNUSED) { /* depend on the odp helper to call odp_init_local */ printf("Worker thread on CPU %d\n", odp_cpu_id()); @@ -20,7 +20,7 @@ static void *worker_fn(void *arg ODPH_UNUSED) } /* Create additional dataplane processes */ -int main(int argc ODPH_UNUSED, char *argv[] ODPH_UNUSED) +int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED) { odp_cpumask_t cpu_mask; int num_workers; @@ -56,9 +56,10 @@ int main(int argc ODPH_UNUSED, char *argv[] ODPH_UNUSED) cpu = odp_cpumask_first(&cpu_mask); printf("the first CPU: %i\n", cpu); - /* reserve cpu 0 for the control plane so remove it from - * the default mask */ - odp_cpumask_clr(&cpu_mask, 0); + /* If possible, remove CPU 0 from the default mask to reserve it for the + * control plane. */ + if (num_workers > 1) + odp_cpumask_clr(&cpu_mask, 0); num_workers = odp_cpumask_count(&cpu_mask); (void)odp_cpumask_to_str(&cpu_mask, cpumaskstr, sizeof(cpumaskstr)); printf("new cpu mask: %s\n", cpumaskstr); @@ -79,10 +80,20 @@ int main(int argc ODPH_UNUSED, char *argv[] ODPH_UNUSED) if (ret == 0) { /* Child process */ worker_fn(NULL); + + if (odp_term_local() < 0) { + ODPH_ERR("Error: ODP local term failed.\n"); + exit(EXIT_FAILURE); + } } else { /* Parent process */ odph_linux_process_wait_n(proc, num_workers); + if (odp_term_local()) { + ODPH_ERR("Error: ODP local term failed.\n"); + exit(EXIT_FAILURE); + } + if (odp_term_global(instance)) { ODPH_ERR("Error: ODP global term failed.\n"); exit(EXIT_FAILURE); |