If the scheduler expects threads to process buffers indefinitely then perhaps that's what threads should do. ODP is constructing both a set of APIs as well as recommendations for how applications should be structured for optimal scalability and portability. Applications that choose not to follow these recommendations may incur additional overhead, but that's their choice. The notion that worker threads need to keep changing their mind about what their task is seems very strange.
Beyond that, it's the responsibility of the ODP implementation to manage orderly thread termination in a graceful manner. If a thread calls odp_term_local() then any "prestaged" events need to be rescheduled to other threads by the implementation. It's unacceptable to deadlock in such situations as a result of resource leaks like this. On Tue, Dec 23, 2014 at 3:51 AM, Savolainen, Petri (NSN - FI/Espoo) < [email protected]> wrote: > > > > > -----Original Message----- > > From: ext Ola Liljedahl [mailto:[email protected]] > > 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) > > <[email protected]> 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. > > > -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: [email protected] > > > [mailto:[email protected]] 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 <[email protected]> > > wrote: > > > > > > Signed-off-by: Mike Holmes <[email protected]> > > > --- > > > 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 > > > [email protected] > > > http://lists.linaro.org/mailman/listinfo/lng-odp > > > > > > > > > _______________________________________________ > > > lng-odp mailing list > > > [email protected] > > > http://lists.linaro.org/mailman/listinfo/lng-odp > > > >
_______________________________________________ lng-odp mailing list [email protected] http://lists.linaro.org/mailman/listinfo/lng-odp
