> -----Original Message-----
> From: ext Ola Liljedahl [mailto:ola.liljed...@linaro.org]
> Sent: Tuesday, December 23, 2014 3:18 PM
> To: Savolainen, Petri (NSN - FI/Espoo)
> Cc: ext Bill Fischofer; Mike Holmes; lng-odp-forward
> Subject: Re: [lng-odp] [PATCH v2 2/3] example: odp_timer_test: remove use
> of odp_schdule_one
> 
> On 23 December 2014 at 10:51, Savolainen, Petri (NSN - FI/Espoo)
> <petri.savolai...@nsn.com> wrote:
> >
> >
> >> -----Original Message-----
> >> From: ext Ola Liljedahl [mailto:ola.liljed...@linaro.org]
> >> Sent: Monday, December 22, 2014 4:23 PM
> >> To: Savolainen, Petri (NSN - FI/Espoo)
> >> Cc: ext Bill Fischofer; Mike Holmes; lng-odp-forward
> >> Subject: Re: [lng-odp] [PATCH v2 2/3] example: odp_timer_test: remove
> use
> >> of odp_schdule_one
> >>
> >> On 22 December 2014 at 14:10, Savolainen, Petri (NSN - FI/Espoo)
> >> <petri.savolai...@nsn.com> wrote:
> >> >
> >> >
> >> > Because the thread will exit the schedule loop, it has to pause first
> >> and
> >> > then run sched loop until the potential per thread local scheduler
> cache
> >> is
> >> > empty (see under).
> >> In this specific case, the example terminates when the specified
> >> number of timeouts have been received and processed. There is no need
> >> to pause the scheduler and drain any prescheduled buffers because when
> >> the remain counter reaches zero, all threads are done and should
> >> terminate.
> >>
> >> This is a timer example, not a scheduler example. For a scheduler
> >> example, we should demonstrate the proper usage of
> >> odp_scheduler_pause() and resume.
> >
> >
> > A throughput optimized scheduler may have pre-scheduled multiple buffers
> (incl tmo notifications) to a thread local cache. Scheduler expects the
> thread to continue process new buffers infinitely. Only way for
> application to tell it's going to take a pause on processing those is
> odp_schedule_pause() call. If application would not do that (and drain any
> remaining buffers) those queues pre-scheduled to the thread would suffer a
> long delay (or even deadlock if the thread exits).
> >
> > So it's an issue any thread need to handle before exiting the schedule
> loop. Also in the test would hang if one thread exits and fails to process
> all pre-scheduled timeouts. Other threads would wait infinitely those
> missing tmos.
> I understand all of this and this is how a proper scheduler example
> should work. But this example attempts to be a simplified timer
> example. When the specified number of timeouts have been received, the
> worker threads and the whole program terminates (and this is
> definitively completely artificial from a networking perspective). Yes
> we don't don't do this in a way that's nice to the scheduler but this
> isn't really the scope of this example IMO.
>

Sure this can be split into two examples (timer and schedule pause). Still 
those threads would need to synchronize so that all timeouts are received and 
after the last one each thread exits gracefully (without program 
hang/crash/memory leak).

-Petri

> If the timer example can't just be a simplified timer example perhaps
> we should put a bullet in it?
> 
> >
> >
> > -Petri
> >
> >
> >>
> >>
> >> >
> >> >
> >> >
> >> > -Petri
> >> >
> >> >
> >> >
> >> >                int done = 0;
> >> >
> >> >
> >> >
> >> >                while (1) {
> >> >
> >> >                               odp_timeout_t tmo;
> >> >
> >> >
> >> >
> >> >                               if (done)
> >> >
> >> > buf = odp_schedule(&queue, ODP_SCHED_NO_WAIT);
> >> >
> >> >                               else
> >> >
> >> >                                              buf =
> odp_schedule(&queue,
> >> > ODP_SCHED_WAIT);
> >> >
> >> >
> >> >
> >> >                               if (buf == ODP_BUFFER_INVALID)
> >> >
> >> >                                              break;
> >> >
> >> >
> >> >
> >> >                               tmo  = odp_timeout_from_buffer(buf);
> >> >
> >> >                               tick = odp_timeout_tick(tmo);
> >> >
> >> >
> >> >
> >> >                               EXAMPLE_DBG("  [%i] timeout, tick
> >> > %"PRIu64"\n", thr, tick);
> >> >
> >> >
> >> >
> >> >                               odp_buffer_free(buf);
> >> >
> >> >
> >> >
> >> >                               num--;
> >> >
> >> >
> >> >
> >> >                               if (num == 0) {
> >> >
> >> >                                              odp_schedule_pause();
> >> >
> >> >                                              done = 1;
> >> >
> >> >                                              continue;
> >> >
> >> > }
> >> >
> >> >
> >> >
> >> >                               tick += period;
> >> >
> >> >
> >> >
> >> >                               odp_timer_absolute_tmo(test_timer,
> tick,
> >> >
> >> >
> >> queue,
> >> > ODP_BUFFER_INVALID);
> >> >
> >> >                }
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > From: lng-odp-boun...@lists.linaro.org
> >> > [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of ext Bill
> >> Fischofer
> >> > Sent: Friday, December 19, 2014 10:38 PM
> >> > To: Mike Holmes
> >> > Cc: lng-odp-forward
> >> > Subject: Re: [lng-odp] [PATCH v2 2/3] example: odp_timer_test: remove
> >> use of
> >> > odp_schdule_one
> >> >
> >> >
> >> >
> >> > Typo in the title (odp_schdule_one).  Presumably Maxim can fix during
> >> merge?
> >> >
> >> >
> >> >
> >> > On Fri, Dec 19, 2014 at 2:34 PM, Mike Holmes <mike.hol...@linaro.org>
> >> wrote:
> >> >
> >> > Signed-off-by: Mike Holmes <mike.hol...@linaro.org>
> >> > ---
> >> >  example/timer/odp_timer_test.c | 2 +-
> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/example/timer/odp_timer_test.c
> >> b/example/timer/odp_timer_test.c
> >> > index 0d6e31a..6d2609a 100644
> >> > --- a/example/timer/odp_timer_test.c
> >> > +++ b/example/timer/odp_timer_test.c
> >> > @@ -84,7 +84,7 @@ static void test_abs_timeouts(int thr, test_args_t
> >> *args)
> >> >         while (1) {
> >> >                 odp_timeout_t tmo;
> >> >
> >> > -               buf = odp_schedule_one(&queue, ODP_SCHED_WAIT);
> >> > +               buf = odp_schedule(&queue, ODP_SCHED_WAIT);
> >> >
> >> >                 tmo  = odp_timeout_from_buffer(buf);
> >> >                 tick = odp_timeout_tick(tmo);
> >> > --
> >> > 2.1.0
> >> >
> >> >
> >> > _______________________________________________
> >> > lng-odp mailing list
> >> > lng-odp@lists.linaro.org
> >> > http://lists.linaro.org/mailman/listinfo/lng-odp
> >> >
> >> >
> >> > _______________________________________________
> >> > lng-odp mailing list
> >> > lng-odp@lists.linaro.org
> >> > http://lists.linaro.org/mailman/listinfo/lng-odp
> >> >
_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to