aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/pgm.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2013-09-27 13:19:57 -0400
committerGlenn Elliott <gelliott@cs.unc.edu>2013-09-27 13:55:14 -0400
commit97c8136fe53b81b1b44dc1b9528d2723d9032dcf (patch)
tree464e79f46ba0c8bf01fbd21489340b374bb38e0a /litmus/pgm.c
parentee3539ec754976c2303905de2ef87fef3395b518 (diff)
PGM release/deadline adjustment.
Adds code that adjusts a jobs release and deadline according to when the job receives the necessary PGM tokens.
Diffstat (limited to 'litmus/pgm.c')
-rw-r--r--litmus/pgm.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/litmus/pgm.c b/litmus/pgm.c
new file mode 100644
index 000000000000..f8b857de8118
--- /dev/null
+++ b/litmus/pgm.c
@@ -0,0 +1,54 @@
1/* litmus/pgm.c - common pgm control code
2 */
3
4#include <linux/sched.h>
5#include <litmus/litmus.h>
6#include <litmus/pgm.h>
7
8/* Only readjust release/deadline if difference is over a given threshold.
9 It's a weak method for accounting overheads. Ideally, we'd know the last
10 time t was woken up by its last predecessor, rather than having to look
11 at 'now'. */
12#define ADJUSTMENT_THRESH_US 200
13
14void setup_pgm_release(struct task_struct* t)
15{
16 /* approximate time last predecessor gave us tokens */
17 lt_t now = litmus_clock();
18
19 TRACE_TASK(t, "is starting a new PGM job: waiting:%d satisfied:%d\n",
20 tsk_rt(t)->ctrl_page->pgm_waiting, tsk_rt(t)->ctrl_page->pgm_satisfied);
21
22 BUG_ON(!tsk_rt(t)->ctrl_page->pgm_waiting || !tsk_rt(t)->ctrl_page->pgm_satisfied);
23
24 tsk_rt(t)->ctrl_page->pgm_waiting = 0;
25 tsk_rt(t)->ctrl_page->pgm_satisfied = 0;
26
27 /* Adjust release time if we got the last tokens after release of this job.
28 This is possible since PGM jobs are early-released. Don't shift our
29 deadline if we got the tokens earlier than expected. */
30 if (now > tsk_rt(t)->job_params.release) {
31 long long diff = now - tsk_rt(t)->job_params.release;
32 if (diff > ADJUSTMENT_THRESH_US) {
33 lt_t adj_deadline = now + get_rt_relative_deadline(t);
34
35 TRACE_TASK(t, "adjusting PGM release time from (r = %llu, d = %llu) "
36 "to (r = %llu, d = %llu)\n",
37 tsk_rt(t)->job_params.release, tsk_rt(t)->job_params.deadline,
38 now, adj_deadline);
39
40 tsk_rt(t)->job_params.release = now;
41 tsk_rt(t)->job_params.deadline = adj_deadline;
42 tsk_rt(t)->job_params.exec_time = 0; /* reset budget */
43 }
44 else {
45 TRACE_TASK(t, "adjustment falls below threshold. %lld < %lld\n",
46 diff, ADJUSTMENT_THRESH_US);
47 }
48 }
49 else {
50 TRACE_TASK(t, "got tokens early--no need to adjust release. "
51 "cur time = %llu, release time = %llu\n",
52 now, tsk_rt(t)->job_params.release);
53 }
54}