From patchwork Mon Jun 23 05:57:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanjay Singh Rawat X-Patchwork-Id: 32319 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 99D4020369 for ; Mon, 23 Jun 2014 05:58:00 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id n16sf40642643oag.10 for ; Sun, 22 Jun 2014 22:57:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=J/cpBmBusahT/Aen0mGcXKmb5iCkc26FNFkkiMhTtnQ=; b=fzJzWNpQfVTsJk8vAmaThIEAUDMF9O7Wi+kYMi4xAy2Yq3KvZWo25nSmPDBIFVqK4q HQURrKpa1/z1AfBmfzz/p2AsPJv3/GzqAlhRG30joDVC88jMM9EpWM6mSrbRuxbPDAK1 MtItsJD2MgUVsekqyWxKA+7ws3I7/Wsbj+bDGr06wGlfm/JziodflsMXyZ2TTp/Ss12y eZDPdXnqz8LK52Ii24DG2I1l+yXd1hn3456uSXQoHF4jdjdGjdFLKkbwDvfj6P+kSNSV mnMiLof/pnzXrtWjlcPGESMJZKjSiY59o/cE6OPUtiNhYoqFQ+meGUr+FZVbna4J1MgB enAQ== X-Gm-Message-State: ALoCoQn96JfrKKAyVufmRjGKCKLWTeSQ10Fj853PS4pVZTaQcH0Nmg4i2mN3sDhajcWVmJrLhIrz X-Received: by 10.42.229.194 with SMTP id jj2mr7897285icb.18.1403503079345; Sun, 22 Jun 2014 22:57:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.104.177 with SMTP id a46ls513104qgf.7.gmail; Sun, 22 Jun 2014 22:57:59 -0700 (PDT) X-Received: by 10.52.118.99 with SMTP id kl3mr14647786vdb.18.1403503079273; Sun, 22 Jun 2014 22:57:59 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id fj4si5018873vcb.24.2014.06.22.22.57.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 22 Jun 2014 22:57:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id il7so5410508vcb.40 for ; Sun, 22 Jun 2014 22:57:59 -0700 (PDT) X-Received: by 10.58.12.73 with SMTP id w9mr469215veb.13.1403503079190; Sun, 22 Jun 2014 22:57:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp107486vcb; Sun, 22 Jun 2014 22:57:58 -0700 (PDT) X-Received: by 10.66.66.135 with SMTP id f7mr26134961pat.22.1403503078366; Sun, 22 Jun 2014 22:57:58 -0700 (PDT) Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by mx.google.com with ESMTPS id pi1si20281612pbb.62.2014.06.22.22.57.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 22 Jun 2014 22:57:58 -0700 (PDT) Received-SPF: pass (google.com: domain of sanjay.rawat@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Received: by mail-pa0-f41.google.com with SMTP id fb1so5470278pad.0 for ; Sun, 22 Jun 2014 22:57:58 -0700 (PDT) X-Received: by 10.68.125.164 with SMTP id mr4mr25696089pbb.27.1403503077915; Sun, 22 Jun 2014 22:57:57 -0700 (PDT) Received: from srawat-Latitude-E6420.LGE.NET ([203.247.149.152]) by mx.google.com with ESMTPSA id zn9sm87714885pac.31.2014.06.22.22.57.54 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 22 Jun 2014 22:57:57 -0700 (PDT) From: Sanjay Singh Rawat To: vincent.guittot@linaro.org, christian.muller@linaro.org Cc: Sanjay Singh Rawat Subject: [PATCH RTAPP] add delay param in thread parameters Date: Mon, 23 Jun 2014 11:27:36 +0530 Message-Id: <1403503056-11192-1-git-send-email-sanjay.rawat@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sanjay.rawat@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.220.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , to start thread after a certain amount of time, add delay option in the json file in microseconds --- this is an update on the previous patch, handling the comments - make delay as usec instead of using the nano sec structure - make thread delay & spacing mutually exclusive this patch is based on 17be4548 --- src/rt-app.c | 9 ++++++++- src/rt-app_parse_config.c | 5 ++++- src/rt-app_types.h | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/rt-app.c b/src/rt-app.c index fdde1bd..de5fe7b 100644 --- a/src/rt-app.c +++ b/src/rt-app.c @@ -250,7 +250,13 @@ void *thread_body(void *arg) } } - if (data->wait_before_start > 0) { + /* thread start delay */ + if (data->delay) { + log_notice("[%d] delaying thread for %d usec\n",data->ind, + data->delay); + usleep(data->delay); + } + else if (data->wait_before_start > 0) { log_notice("[%d] Waiting %ld usecs... ", data->ind, data->wait_before_start); clock_gettime(CLOCK_MONOTONIC, &t); @@ -262,6 +268,7 @@ void *thread_body(void *arg) NULL); log_notice("[%d] Starting...", data->ind); } + /* if we know the duration we can calculate how many periods we will * do at most, and the log to memory, instead of logging to file. */ diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c index f7f8056..bc8ca94 100644 --- a/src/rt-app_parse_config.c +++ b/src/rt-app_parse_config.c @@ -326,7 +326,7 @@ static void parse_thread_data(char *name, struct json_object *obj, int idx, thread_data_t *data, const rtapp_options_t *opts) { - long exec, period, dline; + long exec, period, dline, delay; char *policy; char def_policy[RTAPP_POLICY_DESCR_LENGTH]; struct array_list *cpuset; @@ -389,6 +389,9 @@ parse_thread_data(char *name, struct json_object *obj, int idx, exit(EXIT_INV_CONFIG); } data->deadline = usec_to_timespec(dline); + + /* delay */ + data->delay = get_int_value_from(obj, "delay", TRUE, 0); /* cpu set */ cpuset_obj = get_in_object(obj, "cpus", TRUE); diff --git a/src/rt-app_types.h b/src/rt-app_types.h index 30f2020..adf0b3c 100644 --- a/src/rt-app_types.h +++ b/src/rt-app_types.h @@ -81,7 +81,7 @@ typedef struct _thread_data_t { int duration; cpu_set_t *cpuset; char *cpuset_str; - unsigned long wait_before_start; + unsigned long wait_before_start, delay; struct timespec min_et, max_et; struct timespec period, deadline; struct timespec main_app_start;