From patchwork Fri Oct 30 22:52:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 55863 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp120867lbr; Fri, 30 Oct 2015 15:53:39 -0700 (PDT) X-Received: by 10.50.66.229 with SMTP id i5mr828091igt.5.1446245618888; Fri, 30 Oct 2015 15:53:38 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k92si9592361iod.64.2015.10.30.15.53.17; Fri, 30 Oct 2015 15:53:38 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id 2AC0E62C62; Fri, 30 Oct 2015 22:53:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id A726861C66; Fri, 30 Oct 2015 22:53:12 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 86F3F61C68; Fri, 30 Oct 2015 22:53:10 +0000 (UTC) Received: from mail-lf0-f47.google.com (mail-lf0-f47.google.com [209.85.215.47]) by lists.linaro.org (Postfix) with ESMTPS id 8753961BC1 for ; Fri, 30 Oct 2015 22:53:09 +0000 (UTC) Received: by lfbn126 with SMTP id n126so41351165lfb.2 for ; Fri, 30 Oct 2015 15:53:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=u/VEwZy1DiSeCMM5atz/KPYAqA/v7Iu5Rgrhh0dSDTg=; b=CHeNMxJ5rEXAX3RGdq0D8Y5o8LNf5kcq5XdOb45NXdSI3jA0IL4qLfd762ehqaQDvb NAWqkEQcigaRDZqdQVFyLpbmovkdo0JtCx/DeVGlCpsPSPD9s8q931oKjGwng0z4HIIK EsWgq5x/pqDdfXrbO7C+DTrlL+ZSxYPLOzfqTj+Nuj2BloMFN2/VAJt1S3qRTKJV5sy8 1WCoMnr5ttfCwfHCMgyGlkjbzhckRI3taEepzP+UTBycTk6S5XI2JH4k6FIKWckpqTW8 3ZY71N6J+GDi6/bUuI869s/delSaDf0Q/77DGrDNaacRtMSbB9qPI8De7zajRRz5hlZ+ t9ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=u/VEwZy1DiSeCMM5atz/KPYAqA/v7Iu5Rgrhh0dSDTg=; b=I7XenZthwykWJ2cJbqeio/Djf1vur/RsXfhPj2s3ZQAff/ccUSVIQ/Yo4JwpJ3TWST RqhGHuwzMVC1tQ3vDPaFQO0ZcV1Mjizk8tIUePvRhzO9Gtgtz99/kDbHUkCl8CgtgAo+ yL67Cda259I3cC1TYD8Vo9ildBTZREZON4M7Jam8tl3vQGKDIfJbGqKI/7CpngGg34sJ zj5iAv4GyEMPiwM9FE6HjynQH80uH6rU7Wf9nb1/KxksR0SivpUFeg3DhrXKNIALLulx zEiml8pr4YgeW7O9pVmtjaYdkxZysApYgTWo5ZCZn6tyOKVeSR57ReVBZGPCziS+3Udr UD6Q== X-Gm-Message-State: ALoCoQmxI4+YMBABJCYK/2M6qwCg3AuKgTE2Z4pTSnBqAEraA/SdnsIIGEATlWKEsWRfXboKXK1S X-Received: by 10.25.205.193 with SMTP id d184mr3372334lfg.72.1446245588367; Fri, 30 Oct 2015 15:53:08 -0700 (PDT) Received: from localhost.localdomain ([212.90.60.8]) by smtp.gmail.com with ESMTPSA id so5sm1412867lbb.43.2015.10.30.15.53.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Oct 2015 15:53:07 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Sat, 31 Oct 2015 00:52:54 +0200 Message-Id: <1446245574-31181-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: timers patch Subject: [lng-odp] [PATCH] example: timer: don't set timeout less than resolution X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" The period cannot be less than timer resolution. Also the timer accuracy is +- 1 tick, that means if period is [1;2) of tick the timer can expire right after setting, but it doesn't break the algorithm, so I didn't limit period to be more than 2*resolution. Signed-off-by: Ivan Khoronzhuk --- example/timer/odp_timer_test.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index 94619e4..e081daf 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -252,7 +252,7 @@ static void print_usage(void) * @param argv Argument vector * @param args Test arguments */ -static void parse_args(int argc, char *argv[], test_args_t *args) +static int parse_args(int argc, char *argv[], test_args_t *args) { int opt; int long_index; @@ -311,6 +311,12 @@ static void parse_args(int argc, char *argv[], test_args_t *args) break; } } + + if (args->period_us > args->resolution_us) + return 0; + + EXAMPLE_ERR("Error: period must be more then timer resolution\n"); + return -1; } @@ -371,7 +377,10 @@ int main(int argc, char *argv[]) } memset(gbls, 0, sizeof(test_globals_t)); - parse_args(argc, argv, &gbls->args); + if (parse_args(argc, argv, &gbls->args)) { + EXAMPLE_ERR("Error: Argumets are incorrect.\n"); + return -1; + } memset(thread_tbl, 0, sizeof(thread_tbl));