From: Vincent Guittot vincent.guittot@linaro.org
when we have sync dependency between threads, we don't need to sleep when waiting for the next period. We will wait on the 1st resource that blocked
Signed-off-by: Vincent Guittot vincent.guittot@linaro.org --- src/rt-app.c | 2 +- src/rt-app_parse_config.c | 3 +++ src/rt-app_types.h | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/rt-app.c b/src/rt-app.c index 90afe7f..5384149 100644 --- a/src/rt-app.c +++ b/src/rt-app.c @@ -503,7 +503,7 @@ void *thread_body(void *arg) }
clock_gettime(CLOCK_MONOTONIC, &t_now); - if (timespec_lower(&t_now, &t_next)) + if (data->sleep && timespec_lower(&t_now, &t_next)) clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &t_next, NULL);
i++; diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c index 30a331c..97302a7 100644 --- a/src/rt-app_parse_config.c +++ b/src/rt-app_parse_config.c @@ -517,6 +517,9 @@ parse_thread_data(char *name, struct json_object *obj, int idx, /* delay */ data->wait_before_start = get_int_value_from(obj, "delay", TRUE, 0);
+ /* sleep */ + data->sleep = get_bool_value_from(obj, "sleep", TRUE, 1); + /* cpu set */ cpuset_obj = get_in_object(obj, "cpus", TRUE); if (cpuset_obj) { diff --git a/src/rt-app_types.h b/src/rt-app_types.h index dbec836..94a6aad 100644 --- a/src/rt-app_types.h +++ b/src/rt-app_types.h @@ -115,7 +115,7 @@ typedef struct _thread_data_t { struct timespec min_et, max_et; struct timespec period, deadline; struct timespec main_app_start; - int loop; + int loop, sleep;
FILE *log_handler; policy_t sched_policy;