diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-19 17:31:52 -0400 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-19 17:31:52 -0400 |
commit | f70a290e8a889caa905ab7650c696f2bb299be1a (patch) | |
tree | 56f0886d839499e9f522f189999024b3e86f9be2 /litmus/jobs.c | |
parent | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (diff) | |
parent | 7ef4a793a624c6e66c16ca1051847f75161f5bec (diff) |
Merge branch 'wip-nested-locking' into tegra-nested-lockingwip-nested-locking
Conflicts:
Makefile
include/linux/fs.h
Diffstat (limited to 'litmus/jobs.c')
-rw-r--r-- | litmus/jobs.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/litmus/jobs.c b/litmus/jobs.c new file mode 100644 index 00000000000..7bc75bba863 --- /dev/null +++ b/litmus/jobs.c | |||
@@ -0,0 +1,73 @@ | |||
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 | #include <litmus/trace.h> | ||
9 | |||
10 | static inline void setup_release(struct task_struct *t, lt_t release) | ||
11 | { | ||
12 | /* prepare next release */ | ||
13 | tsk_rt(t)->job_params.release = release; | ||
14 | tsk_rt(t)->job_params.deadline += release + get_rt_period(t); | ||
15 | tsk_rt(t)->job_params.exec_time = 0; | ||
16 | /* update job sequence number */ | ||
17 | tsk_rt(t)->job_params.job_no++; | ||
18 | |||
19 | /* don't confuse Linux */ | ||
20 | t->rt.time_slice = 1; | ||
21 | } | ||
22 | |||
23 | void prepare_for_next_period(struct task_struct *t) | ||
24 | { | ||
25 | BUG_ON(!t); | ||
26 | |||
27 | /* Record lateness before we set up the next job's | ||
28 | * release and deadline. Lateness may be negative. | ||
29 | */ | ||
30 | t->rt_param.job_params.lateness = | ||
31 | (long long)litmus_clock() - | ||
32 | (long long)t->rt_param.job_params.deadline; | ||
33 | |||
34 | setup_release(t, get_release(t) + get_rt_period(t)); | ||
35 | } | ||
36 | |||
37 | void release_at(struct task_struct *t, lt_t start) | ||
38 | { | ||
39 | BUG_ON(!t); | ||
40 | setup_release(t, start); | ||
41 | tsk_rt(t)->completed = 0; | ||
42 | } | ||
43 | |||
44 | |||
45 | /* | ||
46 | * Deactivate current task until the beginning of the next period. | ||
47 | */ | ||
48 | long complete_job(void) | ||
49 | { | ||
50 | lt_t amount; | ||
51 | lt_t now = litmus_clock(); | ||
52 | lt_t exec_time = tsk_rt(current)->job_params.exec_time; | ||
53 | |||
54 | tsk_rt(current)->tot_exec_time += exec_time; | ||
55 | if (lt_before(tsk_rt(current)->max_exec_time, exec_time)) | ||
56 | tsk_rt(current)->max_exec_time = exec_time; | ||
57 | |||
58 | if (is_tardy(current, now)) { | ||
59 | amount = now - get_deadline(current); | ||
60 | if (lt_after(amount, tsk_rt(current)->max_tardy)) | ||
61 | tsk_rt(current)->max_tardy = amount; | ||
62 | tsk_rt(current)->total_tardy += amount; | ||
63 | ++tsk_rt(current)->missed; | ||
64 | } | ||
65 | |||
66 | /* Mark that we do not excute anymore */ | ||
67 | tsk_rt(current)->completed = 1; | ||
68 | /* call schedule, this will return when a new job arrives | ||
69 | * it also takes care of preparing for the next release | ||
70 | */ | ||
71 | schedule(); | ||
72 | return 0; | ||
73 | } | ||