From patchwork Thu Jan 15 10:06:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 43155 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 71EAA240BA for ; Thu, 15 Jan 2015 10:07:01 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id gd6sf7439697lab.0 for ; Thu, 15 Jan 2015 02:07:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=M8x7II/LANfq7mtxptmpxNoVxbnnBiuB8twJePyUbp4=; b=IcNp6e75D203TOaF1cYdFIviUk6+5SFbJhYlAaRwECnG6W3/FH8YABsDhYOPa8MAQK MWagT4vSBHrXrxTdJO/cl2ExpeEDKGTX7oEs9Nt2OPvoiC3t+nL2U3isWlcbYE1O9rhG gAxcOmfZW6AfmfOjefF/rUDnGUSjl+2HvE2h1Li6aMqBrH6M4bLARK8dYbf5EovekMSd 6eS5IXUCxjPAxknVPUThpaxn+zx/zmU/3p9aBVTbuMuY8imNpSQFYQjFaVPcO5te3mNj +J4yMkkTucplUVK0q4twcRzk7c0YzELpAisbXrYKSpOKV6za3FAFuD/+2mmB1reUn6e4 VdgA== X-Gm-Message-State: ALoCoQl3PubyzrO2wgDcBOA454moC/yV8rmsiqcJhkLcXBb0Chon7o+nraNuqxKub+tEn0/mLYTE X-Received: by 10.152.180.227 with SMTP id dr3mr375842lac.0.1421316420340; Thu, 15 Jan 2015 02:07:00 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.229 with SMTP id e5ls169829laa.105.gmail; Thu, 15 Jan 2015 02:07:00 -0800 (PST) X-Received: by 10.152.88.44 with SMTP id bd12mr2687834lab.88.1421316420200; Thu, 15 Jan 2015 02:07:00 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id jv7si911104lab.124.2015.01.15.02.07.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Jan 2015 02:07:00 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so12688841lab.8 for ; Thu, 15 Jan 2015 02:07:00 -0800 (PST) X-Received: by 10.152.5.226 with SMTP id v2mr8879870lav.34.1421316420021; Thu, 15 Jan 2015 02:07:00 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1979654lbb; Thu, 15 Jan 2015 02:06:59 -0800 (PST) X-Received: by 10.229.240.130 with SMTP id la2mr14747392qcb.9.1421316418681; Thu, 15 Jan 2015 02:06:58 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id c9si1353831qam.45.2015.01.15.02.06.57 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 15 Jan 2015 02:06:58 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YBhKJ-0004N9-Az; Thu, 15 Jan 2015 10:06:55 +0000 Received: from mail-la0-f52.google.com ([209.85.215.52]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YBhKD-0004N4-Sc for lng-odp@lists.linaro.org; Thu, 15 Jan 2015 10:06:50 +0000 Received: by mail-la0-f52.google.com with SMTP id hs14so12717320lab.11 for ; Thu, 15 Jan 2015 02:06:44 -0800 (PST) X-Received: by 10.112.130.34 with SMTP id ob2mr8917921lbb.78.1421316404053; Thu, 15 Jan 2015 02:06:44 -0800 (PST) Received: from macmini.lan (78-82-118-111.tn.glocalnet.net. [78.82.118.111]) by mx.google.com with ESMTPSA id vl1sm418176lbb.21.2015.01.15.02.06.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Jan 2015 02:06:43 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Thu, 15 Jan 2015 11:06:33 +0100 Message-Id: <1421316393-31827-1-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: timers patch Subject: [lng-odp] [PATCH] example: odp_timer_test.c: bug 1068 - odp_timer_test aborts X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ola.liljedahl@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Since the scheduler does not guarantee fairness in scheduling, threads must time out and check if the example is still running. If this is the case, just restart the scheduler loop (not the whole example loop which may have other side effects, e.g. resetting timers with some random tick value), otherwise break out of the example loop which will terminate the example. Signed-off-by: Ola Liljedahl Signed-off-by: Signed-off-by: Signed-off-by: --- (This document/code contribution attached is provided under the terms of agreement LES-LTM-21309) example/timer/odp_timer_test.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index 5de499b..dfd6c70 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -126,13 +126,22 @@ static void test_abs_timeouts(int thr, test_args_t *args) } /* Get the next expired timeout */ - /* Use 1.5 second timeout for scheduler */ - uint64_t sched_tmo = odp_schedule_wait_time(1500000000ULL); - buf = odp_schedule(&queue, sched_tmo); - /* Check if odp_schedule() timed out, possibly there are no - * remaining timeouts to receive */ + /* We invoke the scheduler in a loop with a timeout because + * we are not guaranteed to receive any more timeouts. The + * scheduler isn't guaranteeing fairness when scheduling + * buffers to threads */ + do { + /* Use 1.5 second timeout for scheduler */ + uint64_t sched_tmo = + odp_schedule_wait_time(1500000000ULL); + buf = odp_schedule(&queue, sched_tmo); + /* Check if odp_schedule() timed out, possibly there + * are no remaining timeouts to receive */ + } while (buf == ODP_BUFFER_INVALID && + (int)odp_atomic_load_u32(&remain) > 0); + if (buf == ODP_BUFFER_INVALID) - continue; /* Re-check the remain counter */ + break; /* No more timeouts */ if (odp_buffer_type(buf) != ODP_BUFFER_TYPE_TIMEOUT) { /* Not a default timeout buffer */ EXAMPLE_ABORT("Unexpected buffer type (%u) received\n",