summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuri Lelli <juri.lelli@arm.com>2016-11-17 11:35:13 +0000
committerJuri Lelli <juri.lelli@arm.com>2016-11-25 08:21:18 +0000
commit74820a3998053e424e9f198d8770f10fa30b32ce (patch)
tree2327377e12277e109d8ca90859ed5d8b959af938
parent9415c2e4a5b3f18655577a3fa789d39b2c2d6d38 (diff)
rt-app: add delay thread property
Add a new thread property called 'delay' with which the initial starting time of a thread can be delayed. Parameter is expressed in usec. Usage is: "tasks" : { "thread0" : { ... "delay" : 1000000, ... } } Signed-off-by: Juri Lelli <juri.lelli@arm.com> Acked-by: Vincent Guittot <vincent.guittot@linaro.org>
-rw-r--r--doc/tutorial.txt3
-rw-r--r--src/rt-app.c10
-rw-r--r--src/rt-app_parse_config.c5
-rw-r--r--src/rt-app_types.h2
4 files changed, 20 insertions, 0 deletions
diff --git a/doc/tutorial.txt b/doc/tutorial.txt
index bb6734c..dfcc405 100644
--- a/doc/tutorial.txt
+++ b/doc/tutorial.txt
@@ -200,6 +200,9 @@ class. Default value is period. The unit is usec.
* cpus: Array of Integer. Define the CPU affinity of the thread. Default
value is all CPUs of the system. An example : "cpus" : [0, 2, 3]
+* delay: Integer. Initial delay before a thread starts execution. The unit
+is usec.
+
* phases: Object. The phases object described TBF
If there is only 1 phase, the sequence of events can be directly put in the
diff --git a/src/rt-app.c b/src/rt-app.c
index e3aece8..2627d58 100644
--- a/src/rt-app.c
+++ b/src/rt-app.c
@@ -611,6 +611,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 c59b562..b0f302e 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 ae088f0..8998320 100644
--- 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