diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2014-05-09 05:11:35 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2014-06-03 02:38:40 -0400 |
commit | 4cc5780a04d827e075a383b2c37a7fca304c3607 (patch) | |
tree | 65cd2b416e14fa85e85c8dac6ab024b4f84e9f2a /src/task.c | |
parent | a5df594496740ef2284fdaab8430af84e835ad57 (diff) |
Modernize rt_launch; remove internal API cruft
Switch rt_launch to use a more modern way to launch real-time tasks.
This makes rt_launch more flexible, makes it more similar to rtspin,
and also allows to let us get rid of a chunk of old, inflexible code
in liblitmus that wasn't really serving any useful purpose anymore.
Diffstat (limited to 'src/task.c')
-rw-r--r-- | src/task.c | 58 |
1 files changed, 0 insertions, 58 deletions
@@ -8,64 +8,6 @@ | |||
8 | #include "litmus.h" | 8 | #include "litmus.h" |
9 | #include "internal.h" | 9 | #include "internal.h" |
10 | 10 | ||
11 | static void tperrorx(char* msg) | ||
12 | { | ||
13 | fprintf(stderr, | ||
14 | "Task %d: %s: %m", | ||
15 | gettid(), msg); | ||
16 | exit(-1); | ||
17 | } | ||
18 | |||
19 | /* common launch routine */ | ||
20 | int __launch_rt_task(rt_fn_t rt_prog, void *rt_arg, rt_setup_fn_t setup, | ||
21 | void* setup_arg) | ||
22 | { | ||
23 | int ret; | ||
24 | int rt_task = fork(); | ||
25 | |||
26 | if (rt_task == 0) { | ||
27 | /* we are the real-time task | ||
28 | * launch task and die when it is done | ||
29 | */ | ||
30 | rt_task = gettid(); | ||
31 | ret = setup(rt_task, setup_arg); | ||
32 | if (ret < 0) | ||
33 | tperrorx("could not setup task parameters"); | ||
34 | ret = task_mode(LITMUS_RT_TASK); | ||
35 | if (ret < 0) | ||
36 | tperrorx("could not become real-time task"); | ||
37 | exit(rt_prog(rt_arg)); | ||
38 | } | ||
39 | |||
40 | return rt_task; | ||
41 | } | ||
42 | |||
43 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cluster, | ||
44 | lt_t wcet, lt_t period, unsigned int priority, task_class_t class) | ||
45 | { | ||
46 | struct rt_task params; | ||
47 | init_rt_task_param(¶ms); | ||
48 | params.cpu = domain_to_first_cpu(cluster); | ||
49 | params.period = period; | ||
50 | params.exec_cost = wcet; | ||
51 | params.cls = class; | ||
52 | params.phase = 0; | ||
53 | params.priority = priority; | ||
54 | /* enforce budget for tasks that might not use sleep_next_period() */ | ||
55 | params.budget_policy = QUANTUM_ENFORCEMENT; | ||
56 | |||
57 | return __launch_rt_task(rt_prog, arg, | ||
58 | (rt_setup_fn_t) set_rt_task_param, ¶ms); | ||
59 | } | ||
60 | |||
61 | int create_rt_task(rt_fn_t rt_prog, void *arg, int cluster, | ||
62 | lt_t wcet, lt_t period, unsigned int prio) | ||
63 | { | ||
64 | return __create_rt_task(rt_prog, arg, cluster, wcet, period, | ||
65 | prio, RT_CLASS_HARD); | ||
66 | } | ||
67 | |||
68 | |||
69 | #define SCHED_NORMAL 0 | 11 | #define SCHED_NORMAL 0 |
70 | 12 | ||
71 | int task_mode(int mode) | 13 | int task_mode(int mode) |