On 17 November 2016 at 12:42, Juri Lelli juri.lelli@arm.com wrote:
On 14/11/16 17:08, Vincent Guittot wrote:
On 11 November 2016 at 10:17, Juri Lelli juri.lelli@arm.com wrote:
Add a new phase called 'delay' with which the initial starting time of a task can be delayed. Parameter is expressed in usec.
Could you add a description of the command in the tutorial.txt document ?
Sure, will do.
Usage is:
"phases": { "p0": { "delay": 1500000
}, ... other phases ...
}
This delay seems to be more a thread's properties than a event : It should be called only once in a dedicated phase You should better parse it and set t_first in the parse_thread_data
I agree. Something like this then?
yes, your proposal below looks ok
"tasks" : { "thread0" : { "instance" : 1, "loop" : -1, "delay" : 1000000, "run" : 10000, "timer" : { "ref" : "unique", "period" : 100000 } }, "thread1" : { "instance" : 1, "loop" : -1, "delay" : 500000, "run" : 10000, "timer" : { "ref" : "unique", "period" : 100000 } } },
Which is implemented by (after reverting previous patch):
--->8--- From 958e172ddfb2f942b49cd649240b69e0d356dc03 Mon Sep 17 00:00:00 2001 From: Juri Lelli juri.lelli@arm.com Date: Thu, 17 Nov 2016 11:35:13 +0000 Subject: [PATCH] rt-app: add delay thread property
Add a new thread property called 'delay' with which the initial starting time of a thread con be delayed. Parameter is expressed in usec.
Usage is:
"tasks" : { "thread0" : { ... "delay" : 1000000, ... } }
Signed-off-by: Juri Lelli juri.lelli@arm.com
src/rt-app.c | 10 ++++++++++ src/rt-app_parse_config.c | 5 +++++ src/rt-app_types.h | 2 ++ 3 files changed, 17 insertions(+)
diff --git a/src/rt-app.c b/src/rt-app.c index 76ae11ce8f7f..9c66e9fabad9 100644 --- a/src/rt-app.c +++ b/src/rt-app.c @@ -612,6 +612,16 @@ void *thread_body(void *arg) } } #endif
if (data->delay > 0) {
struct timespec delay = usec_to_timespec(data->delay);
log_debug("initial delay %d ", data->delay);
t_first = timespec_add(&t_first, &delay);
clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &t_first,
NULL);
}
i = j = loop = idx = 0; while (continue_running && (i != data->loop)) {
diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c index c59b56290bbf..b0f302e2ba25 100644 --- a/src/rt-app_parse_config.c +++ b/src/rt-app_parse_config.c @@ -689,6 +689,11 @@ parse_thread_data(char *name, struct json_object *obj, int index, } log_info(PIN "key: cpus %s", data->cpuset_str);
/* initial delay */
data->delay = get_int_value_from(obj, "delay", TRUE, 0);
if (data->delay < 0)
data->delay = 0;
/* Get phases */ phases_obj = get_in_object(obj, "phases", TRUE); if (phases_obj) {
diff --git a/src/rt-app_types.h b/src/rt-app_types.h index 5a1d87c24e78..60bd1e85d671 100644less --- a/src/rt-app_types.h +++ b/src/rt-app_types.h @@ -149,6 +149,8 @@ typedef struct _thread_data_t { char sched_policy_descr[RTAPP_POLICY_DESCR_LENGTH]; int sched_prio;
unsigned long delay;
#ifdef DLSCHED struct sched_attr dl_params;
#endif
2.10.0