summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/tutorial.txt5
-rw-r--r--src/rt-app.c20
-rw-r--r--src/rt-app_parse_config.c3
-rw-r--r--src/rt-app_types.h1
4 files changed, 29 insertions, 0 deletions
diff --git a/doc/tutorial.txt b/doc/tutorial.txt
index 6dc9a44..100a2df 100644
--- a/doc/tutorial.txt
+++ b/doc/tutorial.txt
@@ -217,6 +217,11 @@ number of loop thanks to the ns per loop value (see calibration). This way of
working enables to emulate a load with a duration that will vary with the
frequency or the compute capacity of the CPU.
+* runtime : Integer. The duration is define in usec. Similar to the
+run event, it emulates the execution of a load. Unlike run, runtime
+runs for a specific amount of time irrespective of the compute
+capacity of the CPU or the frequency.
+
* sleep : Integer. Emulate the sleep of a task. The duration is defined in
usec.
diff --git a/src/rt-app.c b/src/rt-app.c
index 679d39a..5283ac7 100644
--- a/src/rt-app.c
+++ b/src/rt-app.c
@@ -274,6 +274,26 @@ static int run_event(event_data_t *event, int dry_run,
*duration += timespec_to_usec(&t_end);
}
break;
+ case rtapp_runtime:
+ {
+ struct timespec t_start, t_end;
+ int64_t diff_ns;
+
+ log_debug("runtime %d ", event->duration);
+ clock_gettime(CLOCK_MONOTONIC, &t_start);
+
+ do {
+ /* Do work for 32usec */
+ *perf += loadwait(32);
+
+ clock_gettime(CLOCK_MONOTONIC, &t_end);
+ diff_ns = timespec_sub_to_ns(&t_end, &t_start);
+ } while ((diff_ns / 1000) < event->duration);
+
+ t_end = timespec_sub(&t_end, &t_start);
+ *duration += timespec_to_usec(&t_end);
+ }
+ break;
case rtapp_timer:
{
struct timespec t_period, t_now;
diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c
index 99b0e5e..c59b562 100644
--- a/src/rt-app_parse_config.c
+++ b/src/rt-app_parse_config.c
@@ -348,6 +348,8 @@ parse_thread_event_data(char *name, struct json_object *obj,
if (!strncmp(name, "sleep", strlen("sleep")))
data->type = rtapp_sleep;
+ else if (!strncmp(name, "runtime", strlen("runtime")))
+ data->type = rtapp_runtime;
else
data->type = rtapp_run;
@@ -558,6 +560,7 @@ static char *events[] = {
"broad",
"sync",
"sleep",
+ "runtime",
"run",
"timer",
"suspend",
diff --git a/src/rt-app_types.h b/src/rt-app_types.h
index 2ce9c9d..57fb80d 100644
--- a/src/rt-app_types.h
+++ b/src/rt-app_types.h
@@ -67,6 +67,7 @@ typedef enum resource_t
rtapp_resume,
rtapp_mem,
rtapp_iorun,
+ rtapp_runtime,
} resource_t;
struct _rtapp_mutex {