From 8098f92c8c4771c64607444746544d460f503447 Mon Sep 17 00:00:00 2001 From: pithikos Date: Fri, 6 Feb 2015 10:54:22 +0000 Subject: [PATCH] Specifying t secs to wait added --- tests/src/wait.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tests/src/wait.c b/tests/src/wait.c index 6ab86db..846941b 100644 --- a/tests/src/wait.c +++ b/tests/src/wait.c @@ -8,36 +8,38 @@ /* * This program takes 3 arguments: number of jobs to add, * number of threads, - * wait for each thread (1) or all threads at once (0)? + * wait for each thread separetely (1)? + * how long each thread should run * - * Each job is to simply sleep for one second. + * Each job is to simply sleep for given amount of seconds. * * */ -void sleep_1() { - sleep(1); +void sleep_1(int* secs) { + sleep(*secs); } int main(int argc, char *argv[]){ - + char* p; - if (argc != 4){ - puts("This testfile needs excactly three arguments"); + if (argc < 3){ + puts("This testfile needs at least two arguments"); exit(1); } - - - int num_jobs = strtol(argv[1], &p, 10); - int num_threads = strtol(argv[2], &p, 10); - int wait_each_job = strtol(argv[3], &p, 10); + + + int num_jobs = strtol(argv[1], &p, 10); + int num_threads = strtol(argv[2], &p, 10); + int wait_each_job = argv[3] ? strtol(argv[3], &p, 10) : 0; + int sleep_per_thread = argv[4] ? strtol(argv[4], &p, 10) : 1; threadpool thpool = thpool_init(num_threads); - + int n; for (n=0; n