diff mbox

[RTAPP,V3] add delay param in thread parameters

Message ID 1403518470-13920-1-git-send-email-sanjay.rawat@linaro.org
State New
Headers show

Commit Message

Sanjay Singh Rawat June 23, 2014, 10:14 a.m. UTC
to start thread after a certain amount of time, add delay option
in the json file in microseconds

---

V3: make use of wait_before_start to store the delay param specified
    in task property

V2: this is an update on the previous patch, handling the comments

- make delay as usec instead of using the nano sec structure
- make thread delay & spacing mutually exclusive

this patch is based on 17be4548
---
 src/rt-app.c              | 5 +++--
 src/rt-app_parse_config.c | 3 +++
 2 files changed, 6 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/src/rt-app.c b/src/rt-app.c
index fdde1bd..0b67912 100644
--- a/src/rt-app.c
+++ b/src/rt-app.c
@@ -262,6 +262,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.
 	 */
@@ -457,13 +458,13 @@  int main(int argc, char* argv[])
 	for (i = 0; i < nthreads; i++)
 	{
 		tdata = &opts.threads_data[i];
-		if (opts.spacing > 0 ) {
+		if (!tdata->wait_before_start && (opts.spacing > 0)) {
 			/* start the thread, then it will sleep accordingly
 			 * to its position. We don't sleep here anymore as 
 			 * this would mean that 
 			 * duration = spacing * nthreads + duration */
 			tdata->wait_before_start = opts.spacing * (i+1);
-		} else {
+		} else if (!tdata->wait_before_start && !opts.spacing){
 			tdata->wait_before_start = 0;
 		}
 		tdata->duration = opts.duration;
diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c
index f7f8056..2e9e121 100644
--- a/src/rt-app_parse_config.c
+++ b/src/rt-app_parse_config.c
@@ -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->wait_before_start = get_int_value_from(obj, "delay", TRUE, 0);
 	
 	/* cpu set */
 	cpuset_obj = get_in_object(obj, "cpus", TRUE);