diff mbox

[1/3,v3] example: timer: warn if timeout less than resolution

Message ID 1447169760-15258-2-git-send-email-ivan.khoronzhuk@linaro.org
State Superseded
Headers show

Commit Message

Ivan Khoronzhuk Nov. 10, 2015, 3:35 p.m. UTC
The period shouldn't be less than timer resolution. If it's less
there is no guarantee about timeout accuracy, it can be executed
right after setting it or after up to timer resolution timeout or
even be set late, in which case application will be stopped with
error. So it's better to warn user that timeout is less then
resolution instead of silence.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 example/timer/odp_timer_test.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Ola Liljedahl Nov. 18, 2015, 5:16 p.m. UTC | #1
On 10 November 2015 at 15:35, Ivan Khoronzhuk
<ivan.khoronzhuk@linaro.org> wrote:
> The period shouldn't be less than timer resolution. If it's less
> there is no guarantee about timeout accuracy, it can be executed
> right after setting it or after up to timer resolution timeout or
> even be set late, in which case application will be stopped with
> error. So it's better to warn user that timeout is less then
> resolution instead of silence.
>
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Reviewed-by: Ola Liljedahl <ola.liljedahl@linaro.org>

> ---
>  example/timer/odp_timer_test.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
> index 94619e4..aee01c8 100644
> --- a/example/timer/odp_timer_test.c
> +++ b/example/timer/odp_timer_test.c
> @@ -311,6 +311,9 @@ static void parse_args(int argc, char *argv[], test_args_t *args)
>                         break;
>                 }
>         }
> +
> +       if (args->period_us < args->resolution_us)
> +               printf("\n\tWarn: timeout is set less then resolution\n");
You could also warn if the timeout is not an (integer) multiple of the
resolution but that is less of a problem.

>  }
>
>
> --
> 1.9.1
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index 94619e4..aee01c8 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -311,6 +311,9 @@  static void parse_args(int argc, char *argv[], test_args_t *args)
 			break;
 		}
 	}
+
+	if (args->period_us < args->resolution_us)
+		printf("\n\tWarn: timeout is set less then resolution\n");
 }