summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rt-app.c12
-rw-r--r--src/rt-app_parse_config.c2
-rw-r--r--src/rt-app_types.h1
3 files changed, 8 insertions, 7 deletions
diff --git a/src/rt-app.c b/src/rt-app.c
index 3cd601d..d2945e1 100644
--- a/src/rt-app.c
+++ b/src/rt-app.c
@@ -174,6 +174,12 @@ static int run_event(event_data_t *event, int dry_run,
log_debug("timer %d ", event->duration);
t_period = usec_to_timespec(event->duration);
+
+ if (rdata->res.timer.init == 0) {
+ rdata->res.timer.init = 1;
+ clock_gettime(CLOCK_MONOTONIC, &rdata->res.timer.t_next);
+ }
+
rdata->res.timer.t_next = timespec_add(&rdata->res.timer.t_next, &t_period);
clock_gettime(CLOCK_MONOTONIC, &t_now);
if (timespec_lower(&t_now, &rdata->res.timer.t_next))
@@ -678,12 +684,6 @@ int main(int argc, char* argv[])
/* Sync timer resources with start time */
clock_gettime(CLOCK_MONOTONIC, &t_start);
- for (i = 0; i < nresources; i++) {
- rdata = &opts.resources[i];
- if (rdata->type == rtapp_timer)
- rdata->res.timer.t_next = t_start;
- }
-
/* Start the use case */
for (i = 0; i < nthreads; i++) {
tdata = &opts.threads_data[i];
diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c
index 2572afb..3fdf5f5 100644
--- a/src/rt-app_parse_config.c
+++ b/src/rt-app_parse_config.c
@@ -179,7 +179,7 @@ static int init_mutex_resource(rtapp_resource_t *data, const rtapp_options_t *op
static int init_timer_resource(rtapp_resource_t *data, const rtapp_options_t *opts)
{
log_info(PIN3 "Init: %s timer", data->name);
- clock_gettime(CLOCK_MONOTONIC, &data->res.timer.t_next);
+ data->res.timer.init = 0;
}
static int init_cond_resource(rtapp_resource_t *data, const rtapp_options_t *opts)
diff --git a/src/rt-app_types.h b/src/rt-app_types.h
index cefb3a6..1075f64 100644
--- a/src/rt-app_types.h
+++ b/src/rt-app_types.h
@@ -83,6 +83,7 @@ struct _rtapp_signal {
struct _rtapp_timer {
struct timespec t_next;
+ int init;
};
/* Shared resources */