On 19 January 2017 at 09:34, Maxim Uvarov <maxim.uva...@linaro.org> wrote:

> Core 0 might be not available and app should
> ask for available core before pinning to it.
> https://bugs.linaro.org/show_bug.cgi?id=2806
>
> Signed-off-by: Maxim Uvarov <maxim.uva...@linaro.org>
>

Reviewed-by: Mike Holmes <mike.hol...@linaro.org>



> ---
>  example/hello/odp_hello.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/example/hello/odp_hello.c b/example/hello/odp_hello.c
> index 6d114eea..dba34954 100644
> --- a/example/hello/odp_hello.c
> +++ b/example/hello/odp_hello.c
> @@ -61,6 +61,7 @@ int main(int argc, char *argv[])
>         pid_t pid;
>         cpu_set_t cpu_set;
>         int i;
> +       odp_cpumask_t mask;
>
>         memset(&opt, 0, sizeof(opt));
>         opt.cpu = 0;
> @@ -70,6 +71,15 @@ int main(int argc, char *argv[])
>                 return -1;
>
>         pid = getpid();
> +
> +       if (odp_init_global(&inst, NULL, NULL)) {
> +               printf("Global init failed.\n");
> +               return -1;
> +       }
> +
> +       odp_cpumask_default_control(&mask, 0);
> +       opt.cpu = odp_cpumask_first(&mask);
> +
>         CPU_ZERO(&cpu_set);
>         CPU_SET(opt.cpu, &cpu_set);
>
> @@ -78,11 +88,6 @@ int main(int argc, char *argv[])
>                 return -1;
>         }
>
> -       if (odp_init_global(&inst, NULL, NULL)) {
> -               printf("Global init failed.\n");
> -               return -1;
> -       }
> -
>         if (odp_init_local(inst, ODP_THREAD_CONTROL)) {
>                 printf("Local init failed.\n");
>                 return -1;
> --
> 2.11.0.295.gd7dffce
>
>


-- 
Mike Holmes
Program Manager - Linaro Networking Group
Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"

Reply via email to