The runtime event emulates the execution of a load for a specific amount of time irrespective of the compute capacity of the CPU it is run on or the frequency. ---
Changes since v1:
- Change runtime granularity to 10usec - Reorder run and runtime in run_event() and in the tutorial.txt
doc/tutorial.txt | 5 +++++ src/rt-app.c | 20 ++++++++++++++++++++ src/rt-app_parse_config.c | 3 +++ src/rt-app_types.h | 1 + 4 files changed, 29 insertions(+)
diff --git a/doc/tutorial.txt b/doc/tutorial.txt index 6dc9a44..4435dad 100644 --- a/doc/tutorial.txt +++ b/doc/tutorial.txt @@ -210,6 +210,11 @@ complete "phases" object will be executed. The default value is -1. events are simple action that will be performed by the thread or on the thread. They have to be listed by execution order.
+* 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. + * run : Integer. Emulate the execution of a load. The duration is defined in usec but the run event will effectively run a number of time a loop that waste cpu cycles. When the run event is executed, the duration is transformed in a diff --git a/src/rt-app.c b/src/rt-app.c index 679d39a..5a6f4f3 100644 --- a/src/rt-app.c +++ b/src/rt-app.c @@ -263,6 +263,26 @@ static int run_event(event_data_t *event, int dry_run, nanosleep(&sleep, NULL); } 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 10usec */ + *perf += loadwait(10); + + 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_run: { struct timespec t_start, t_end; 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 {