diff options
author | Giacomo Bagnoli <g.bagnoli@asidev.com> | 2010-03-10 14:05:20 +0100 |
---|---|---|
committer | Giacomo Bagnoli <g.bagnoli@asidev.com> | 2010-03-10 14:05:20 +0100 |
commit | 5ab5ad4409688f0771fccc9585c1a5b49ff6bc34 (patch) | |
tree | 4f6ec6a5ff098d79d752e10e0ba02fa88c738ad3 /src | |
parent | b953328f046108a7ddf5e06486a39444a47338e7 (diff) |
Finished support for sched_deadline, to be tested
Diffstat (limited to 'src')
-rw-r--r-- | src/rt-app.c | 34 | ||||
-rw-r--r-- | src/rt-app_args.c | 43 | ||||
-rw-r--r-- | src/rt-app_args.h | 3 | ||||
-rw-r--r-- | src/rt-app_utils.c | 6 | ||||
-rw-r--r-- | src/rt-app_utils.h | 3 |
5 files changed, 76 insertions, 13 deletions
diff --git a/src/rt-app.c b/src/rt-app.c index 1a4659c..64661d0 100644 --- a/src/rt-app.c +++ b/src/rt-app.c @@ -77,6 +77,9 @@ void *thread_body(void *arg) qres_time_t prev_abs_used_budget = 0; qres_time_t abs_used_budget; #endif +#ifdef DLSCHED + pid_t tid; +#endif int ret, i = 0; int j; /* set scheduling policy and print pretty info on stdout */ @@ -141,6 +144,37 @@ posixrtcommon: break; #endif +#ifdef DLSCHED + case deadline: + tid = gettid(); + log_info("[%d] using %s policy for tid %d", data->ind, + data->sched_policy_descr, tid); + data->dl_params.sched_priority = data->sched_prio; + data->dl_params.sched_runtime = data->max_et; + data->dl_params.sched_deadline = data->period; + data->dl_params.sched_period = data->period; + data->dl_params.sched_flags = SCHED_BWRECL_RT; + + ret = sched_setscheduler_ex(tid, SCHED_DEADLINE, + sizeof(struct sched_param_ex), + &data->dl_params); + if (ret != 0) { + log_critical("[%d] sched_setscheduler_ex" + "returned %d", data->ind, ret); + exit(EXIT_FAILURE); + } + + log_info("[%d] starting thread with period: %lu, exec: %lu," + "deadline: %lu, priority: %d", + data->ind, + timespec_to_usec(&data->period), + timespec_to_usec(&data->min_et), + timespec_to_usec(&data->deadline), + data->sched_prio + ); + break; +#endif + default: log_error("Unknown scheduling policy %d", data->sched_policy); diff --git a/src/rt-app_args.c b/src/rt-app_args.c index e1eef67..b649bd7 100644 --- a/src/rt-app_args.c +++ b/src/rt-app_args.c @@ -37,14 +37,21 @@ usage (const char* msg) #ifdef AQUOSA printf("-q, --qos\t:\tcreate AQuoSA reservation\n"); printf("-g, --frag\t:\tfragment for the reservation\n\n"); - printf("POLICY: f=SCHED_FIFO, r=SCHED_RR, o=SCHED_OTHER, q=AQuoSA\n"); +#else +#endif + printf("\nPOLICY: f=SCHED_FIFO, r=SCHED_RR, o=SCHED_OTHER"); +#ifdef DLSCHED + printf(", d=SCHED_DEADLINE"); +#endif +#ifdef AQUOSA + printf(", q=AQuoSA\n"); printf("when using AQuoSA scheduling, priority is used as" " percent increment \nfor budget over exec time\n"); #else - printf("\nPOLICY: f=SCHED_FIFO, r=SCHED_RR, o=SCHED_OTHER\n"); + printf("\n"); #endif - printf("AFFINITY: comma-separated cpu index (starting from 0)"); - printf(" i.e. 0,2,3 for first, third and fourth CPU\n"); + printf("AFFINITY: comma-separated cpu index (starting from 0)\n"); + printf("\ti.e. 0,2,3 for first, third and fourth CPU\n"); if (msg != NULL) printf("\n%s\n", msg); @@ -57,11 +64,11 @@ parse_thread_args(char *arg, struct thread_data *tdata, policy_t def_policy) { char *str = strdup(arg); char *token; - long period, exec, deadline; + long period, exec, dline; char tmp[256]; int i = 0; int cpu; - deadline = 0; + dline = 0; token = strtok(str, ":"); tdata->sched_prio = DEFAULT_THREAD_PRIORITY; @@ -99,6 +106,11 @@ parse_thread_args(char *arg, struct thread_data *tdata, policy_t def_policy) tdata->sched_policy = aquosa; else #endif +#ifdef DLSCHED + if (strcmp(token,"d") == 0) + tdata->sched_policy = deadline; + else +#endif if (strcmp(token,"f") == 0) tdata->sched_policy = fifo; else if (strcmp(token,"r") == 0) @@ -129,16 +141,16 @@ parse_thread_args(char *arg, struct thread_data *tdata, policy_t def_policy) i++; break; case 5: - deadline = strtol(token, NULL, 10); - if (deadline < exec) + dline = strtol(token, NULL, 10); + if (dline < exec) usage ("Deadline cannot be less than " "execution time"); - if (deadline > period) + if (dline > period) usage ("Deadline cannot be greater than " "period"); - if (deadline <= 0 ) + if (dline <= 0 ) usage ("Cannot set negative deadline"); - tdata->deadline = usec_to_timespec(deadline); + tdata->deadline = usec_to_timespec(dline); i++; break; } @@ -149,7 +161,7 @@ parse_thread_args(char *arg, struct thread_data *tdata, policy_t def_policy) exit(EXIT_FAILURE); } - if (deadline == 0) + if (dline == 0) tdata->deadline = tdata->period; /* set cpu affinity mask */ @@ -166,7 +178,7 @@ parse_thread_args(char *arg, struct thread_data *tdata, policy_t def_policy) } else tdata->cpuset_str = strdup("-"); - // descriptive name for policy + /* descriptive name for policy */ switch(tdata->sched_policy) { case rr: @@ -183,6 +195,11 @@ parse_thread_args(char *arg, struct thread_data *tdata, policy_t def_policy) sprintf(tdata->sched_policy_descr, "AQuoSA"); break; #endif +#ifdef DLSCHED + case deadline: + sprintf(tdata->sched_policy_descr, "SCHED_DEADLINE"); + break; +#endif } free(str); diff --git a/src/rt-app_args.h b/src/rt-app_args.h index 6e2e6e8..c434723 100644 --- a/src/rt-app_args.h +++ b/src/rt-app_args.h @@ -28,6 +28,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include <sched.h> #include "rt-app_types.h" #include "rt-app_utils.h" +#ifdef DLSCHED +#include "dl_syscalls.h" +#endif #define DEFAULT_THREAD_PRIORITY 10 diff --git a/src/rt-app_utils.c b/src/rt-app_utils.c index c24ae87..42afd66 100644 --- a/src/rt-app_utils.c +++ b/src/rt-app_utils.c @@ -133,3 +133,9 @@ log_timing(FILE *handler, timing_point_t *t) fprintf(handler, "\n"); } +pid_t +gettid(void) +{ + return syscall(__NR_gettid); +} + diff --git a/src/rt-app_utils.h b/src/rt-app_utils.h index ba3cf50..29af5e3 100644 --- a/src/rt-app_utils.h +++ b/src/rt-app_utils.h @@ -95,6 +95,9 @@ timespec_lower(struct timespec *what, struct timespec *than); void log_timing(FILE *handler, timing_point_t *t); +pid_t +gettid(void); + #endif // _TIMESPEC_UTILS_H_ /* vim: set ts=8 noexpandtab shiftwidth=8: */ |