diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-06-25 01:27:07 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-08-07 03:46:49 -0400 |
commit | 543810eb67bea9c3046ecb58388493bca39fe796 (patch) | |
tree | cf65010367e53dfbd3e39a9eb6e89dacf92348f3 /litmus/jobs.c | |
parent | 1412c8b72e192a14b8dd620f58a75f55a5490783 (diff) |
Add LITMUS^RT core implementation
This patch adds the core of LITMUS^RT:
- library functionality (heaps, rt_domain, prioritization, etc.)
- budget enforcement logic
- job management
- system call backends
- virtual devices (control page, etc.)
- scheduler plugin API (and dummy plugin)
This code compiles, but is not yet integrated with the rest of Linux.
Diffstat (limited to 'litmus/jobs.c')
-rw-r--r-- | litmus/jobs.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/litmus/jobs.c b/litmus/jobs.c new file mode 100644 index 000000000000..89a0810415fa --- /dev/null +++ b/litmus/jobs.c | |||
@@ -0,0 +1,55 @@ | |||
1 | /* litmus/jobs.c - common job control code | ||
2 | */ | ||
3 | |||
4 | #include <linux/sched.h> | ||
5 | |||
6 | #include <litmus/litmus.h> | ||
7 | #include <litmus/jobs.h> | ||
8 | |||
9 | static inline void setup_release(struct task_struct *t, lt_t release) | ||
10 | { | ||
11 | /* prepare next release */ | ||
12 | t->rt_param.job_params.release = release; | ||
13 | t->rt_param.job_params.deadline = release + get_rt_relative_deadline(t); | ||
14 | t->rt_param.job_params.exec_time = 0; | ||
15 | |||
16 | /* update job sequence number */ | ||
17 | t->rt_param.job_params.job_no++; | ||
18 | } | ||
19 | |||
20 | void prepare_for_next_period(struct task_struct *t) | ||
21 | { | ||
22 | BUG_ON(!t); | ||
23 | |||
24 | /* Record lateness before we set up the next job's | ||
25 | * release and deadline. Lateness may be negative. | ||
26 | */ | ||
27 | t->rt_param.job_params.lateness = | ||
28 | (long long)litmus_clock() - | ||
29 | (long long)t->rt_param.job_params.deadline; | ||
30 | |||
31 | setup_release(t, get_release(t) + get_rt_period(t)); | ||
32 | tsk_rt(t)->dont_requeue = 0; | ||
33 | } | ||
34 | |||
35 | void release_at(struct task_struct *t, lt_t start) | ||
36 | { | ||
37 | BUG_ON(!t); | ||
38 | setup_release(t, start); | ||
39 | tsk_rt(t)->completed = 0; | ||
40 | } | ||
41 | |||
42 | |||
43 | /* | ||
44 | * Deactivate current task until the beginning of the next period. | ||
45 | */ | ||
46 | long complete_job(void) | ||
47 | { | ||
48 | /* Mark that we do not excute anymore */ | ||
49 | tsk_rt(current)->completed = 1; | ||
50 | /* call schedule, this will return when a new job arrives | ||
51 | * it also takes care of preparing for the next release | ||
52 | */ | ||
53 | schedule(); | ||
54 | return 0; | ||
55 | } | ||