> -----Original Message-----
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of
> ext Ivan Khoronzhuk
> Sent: Monday, September 07, 2015 11:51 AM
> To: lng-odp@lists.linaro.org
> Subject: [lng-odp] [Patch] linux-generic: odp_schedule: fix
> odp_schdule_wait_time
> 
> The resolution of schedule time can be more than 1ns. As result
> can happen that 1ns corresponds 0 ticks of timer counter, but if
> passed 1ns it's obvious that user wanted to schedule at least once.
> Currently it can lead to wait forever, as 0 corresponds to
> ODP_SCHED_WAIT, it can block program flow at all.
> 
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronz...@linaro.org>
> ---
> 
> Prerequisit for this patch was taken from:
> "[lng-odp] [Patch] validation: scheduler: increase time check"
> https://lists.linaro.org/pipermail/lng-odp/2015-August/014738.html
> 
>  platform/linux-generic/odp_schedule.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-
> generic/odp_schedule.c
> index c6619e5..05497de 100644
> --- a/platform/linux-generic/odp_schedule.c
> +++ b/platform/linux-generic/odp_schedule.c
> @@ -646,10 +646,13 @@ void odp_schedule_resume(void)
> 
>  uint64_t odp_schedule_wait_time(uint64_t ns)
>  {
> -     if (ns <= ODP_SCHED_NO_WAIT)
> -             ns = ODP_SCHED_NO_WAIT + 1;
> +     uint64_t time;
> 
> -     return odp_time_ns_to_cycles(ns);
> +     time = odp_time_ns_to_cycles(ns);
> +     if (!time)
> +             time = ODP_SCHED_NO_WAIT;
> +
> +     return time;
>  }



I think it's better to change (implementation specific) WAIT/NO_WAIT values 
like this.


plat/schedule_types.h

#define ODP_SCHED_WAIT     UINT64_MAX
#define ODP_SCHED_NO_WAIT  0


... and avoid any conversion in the common case (WAIT/NO_WAIT). It will not 
matter, if 1 ns is rounded to 0 == NO_WAIT.


uint64_t odp_schedule_wait_time(uint64_t ns)
{
        if (ns == ODP_SCHED_WAIT || ns == ODP_SCHED_NO_WAIT)
                return ns;

        return odp_time_ns_to_cycles(ns);
}

-Petri

_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to