@@ -250,7 +250,13 @@ void *thread_body(void *arg)
}
}
- if (data->wait_before_start > 0) {
+ /* thread start delay */
+ if (data->delay) {
+ log_notice("[%d] delaying thread for %d usec\n",data->ind,
+ data->delay);
+ usleep(data->delay);
+ }
+ else if (data->wait_before_start > 0) {
log_notice("[%d] Waiting %ld usecs... ", data->ind,
data->wait_before_start);
clock_gettime(CLOCK_MONOTONIC, &t);
@@ -262,6 +268,7 @@ void *thread_body(void *arg)
NULL);
log_notice("[%d] Starting...", data->ind);
}
+
/* if we know the duration we can calculate how many periods we will
* do at most, and the log to memory, instead of logging to file.
*/
@@ -326,7 +326,7 @@ static void
parse_thread_data(char *name, struct json_object *obj, int idx,
thread_data_t *data, const rtapp_options_t *opts)
{
- long exec, period, dline;
+ long exec, period, dline, delay;
char *policy;
char def_policy[RTAPP_POLICY_DESCR_LENGTH];
struct array_list *cpuset;
@@ -389,6 +389,9 @@ parse_thread_data(char *name, struct json_object *obj, int idx,
exit(EXIT_INV_CONFIG);
}
data->deadline = usec_to_timespec(dline);
+
+ /* delay */
+ data->delay = get_int_value_from(obj, "delay", TRUE, 0);
/* cpu set */
cpuset_obj = get_in_object(obj, "cpus", TRUE);
@@ -81,7 +81,7 @@ typedef struct _thread_data_t {
int duration;
cpu_set_t *cpuset;
char *cpuset_str;
- unsigned long wait_before_start;
+ unsigned long wait_before_start, delay;
struct timespec min_et, max_et;
struct timespec period, deadline;
struct timespec main_app_start;