summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Guittot <vincent.guittot@linaro.org>2014-12-10 17:35:19 +0100
committerVincent Guittot <vincent.guittot@linaro.org>2014-12-15 14:48:14 +0100
commit9fcfe5cc7bb639e238cfe7fba99ac0dda9c7c286 (patch)
tree2dff7af1bf72470def48572b0813f4b05202b565
parent2562d00e0d0b73d046e9a97ab40758281acc29c9 (diff)
rt-app: use per instance timer
when we instantiate a thread which contains timer events, the same timers will be used for all instances and the instance will be woken up sequentially. Create a special value named "unique" for the "ref" key of timer. During the creation of the event, the timer ref value will be replaced by a unique value so each instance will use its own timer instead of sharing the same timer Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
-rw-r--r--doc/examples/example2.json2
-rw-r--r--src/rt-app_parse_config.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/doc/examples/example2.json b/doc/examples/example2.json
index a1d9746..ff142c9 100644
--- a/doc/examples/example2.json
+++ b/doc/examples/example2.json
@@ -8,7 +8,7 @@
"instance" : 1,
"loop" : -1,
"run" : 1000,
- "timer" : { "ref" : "tick", "period" : 10000 }
+ "timer" : { "ref" : "unique", "period" : 10000 }
}
}
}
diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c
index e062f79..b77a408 100644
--- a/src/rt-app_parse_config.c
+++ b/src/rt-app_parse_config.c
@@ -300,6 +300,7 @@ parse_thread_event_data(char *name, struct json_object *obj,
event_data_t *data, const rtapp_options_t *opts)
{
rtapp_resource_t *rdata, *ddata;
+ char unique_name[22];
char *ref;
int i;
@@ -394,6 +395,10 @@ parse_thread_event_data(char *name, struct json_object *obj,
if (!strncmp(name, "timer", strlen("timer"))) {
ref = get_string_value_from(obj, "ref", TRUE, "unknown");
+ if (!strcmp(ref, "unique")) {
+ snprintf(unique_name, sizeof(unique_name), "timer%lx", (long)(data));
+ ref = unique_name;
+ }
i = get_resource_index(ref, rtapp_timer, opts);
data->res = i;