There's no concept of "main thread". All threads need to call init_local(), 
which should increment ODP thread count. Term_local() decrements the count and 
when that reach zero it returns (0) that this was the last one. Any thread can 
call init_global() (be the first one) and any can call term_global (if it's the 
last one).

-Petri

> -----Original Message-----
> From: EXT Nicolas Morey-Chaisemartin [mailto:[email protected]]
> Sent: Wednesday, October 21, 2015 11:00 AM
> To: Savolainen, Petri (Nokia - FI/Espoo); [email protected]
> Subject: Re: [lng-odp] [PATCH] helper: linux: do not call odp_term_global
> on thread exit
> 
> Shouldn't the main thread be the one to call odp_term_global ?
> The main thread is not counted in the thread global struct.
> 
> Nicolas
> 
> On 10/21/2015 09:54 AM, Savolainen, Petri (Nokia - FI/Espoo) wrote:
> > The last ODP thread should call term global. Local term returns which
> thread was the last one. As long as you leave one thread not terminated,
> you can create and term threads multiple times. Global term is called only
> when you have 0 ODP threads left.
> >
> > -Petri
> >
> >
> >> -----Original Message-----
> >> From: lng-odp [mailto:[email protected]] On Behalf Of EXT
> >> Nicolas Morey-Chaisemartin
> >> Sent: Wednesday, October 21, 2015 10:16 AM
> >> To: [email protected]
> >> Subject: [lng-odp] [PATCH] helper: linux: do not call odp_term_global on
> >> thread exit
> >>
> >> Remove the call to odp_term_global when a thread returns.
> >> This causes some serious side effects (and bugs) when thread are
> >> created and joined "dynamically".
> >>
> >> Signed-off-by: Nicolas Morey-Chaisemartin <[email protected]>
> >> ---
> >>  helper/linux.c | 2 --
> >>  1 file changed, 2 deletions(-)
> >>
> >> diff --git a/helper/linux.c b/helper/linux.c
> >> index 3d3b6b8..af1da17 100644
> >> --- a/helper/linux.c
> >> +++ b/helper/linux.c
> >> @@ -36,8 +36,6 @@ static void *odp_run_start_routine(void *arg)
> >>    int ret = odp_term_local();
> >>    if (ret < 0)
> >>            ODPH_ERR("Local term failed\n");
> >> -  else if (ret == 0 && odp_term_global())
> >> -          ODPH_ERR("Global term failed\n");
> >>
> >>    return ret_ptr;
> >>  }
> >> --
> >> 2.6.1.3.g8d02103
> >>
> >> _______________________________________________
> >> lng-odp mailing list
> >> [email protected]
> >> https://lists.linaro.org/mailman/listinfo/lng-odp

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to