diff options
Diffstat (limited to 'include/litmus/budget.h')
-rw-r--r-- | include/litmus/budget.h | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/include/litmus/budget.h b/include/litmus/budget.h index 8e426a71f03d..08d5e0970d1d 100644 --- a/include/litmus/budget.h +++ b/include/litmus/budget.h | |||
@@ -4,6 +4,8 @@ | |||
4 | #include <linux/hrtimer.h> | 4 | #include <linux/hrtimer.h> |
5 | #include <linux/semaphore.h> | 5 | #include <linux/semaphore.h> |
6 | 6 | ||
7 | #include <litmus/binheap.h> | ||
8 | |||
7 | struct enforcement_timer | 9 | struct enforcement_timer |
8 | { | 10 | { |
9 | raw_spinlock_t lock; | 11 | raw_spinlock_t lock; |
@@ -15,17 +17,22 @@ typedef void (*scheduled_t)(struct task_struct* t); | |||
15 | typedef void (*blocked_t)(struct task_struct* t); | 17 | typedef void (*blocked_t)(struct task_struct* t); |
16 | typedef void (*preempt_t)(struct task_struct* t); | 18 | typedef void (*preempt_t)(struct task_struct* t); |
17 | typedef void (*sleep_t)(struct task_struct* t); | 19 | typedef void (*sleep_t)(struct task_struct* t); |
20 | typedef void (*wakeup_t)(struct task_struct* t); | ||
18 | typedef enum hrtimer_restart (*exhausted_t)(struct task_struct* t); | 21 | typedef enum hrtimer_restart (*exhausted_t)(struct task_struct* t); |
19 | typedef void (*exit_t)(struct task_struct* t); | 22 | typedef void (*exit_t)(struct task_struct* t); |
20 | typedef void (*inherit_t)(struct task_struct* t, struct task_struct* prio_inh); | 23 | typedef void (*inherit_t)(struct task_struct* t, struct task_struct* prio_inh); |
21 | typedef void (*disinherit_t)(struct task_struct* t, struct task_struct* prio_inh); | 24 | typedef void (*disinherit_t)(struct task_struct* t, struct task_struct* prio_inh); |
22 | 25 | ||
26 | typedef void (*enter_top_m_t)(struct task_struct* t); | ||
27 | typedef void (*exit_top_m_t)(struct task_struct* t); | ||
28 | |||
23 | struct budget_tracker_ops | 29 | struct budget_tracker_ops |
24 | { | 30 | { |
25 | scheduled_t on_scheduled; /* called from litmus_schedule(). */ | 31 | scheduled_t on_scheduled; /* called from litmus_schedule(). */ |
26 | blocked_t on_blocked; /* called from plugin::schedule() */ | 32 | blocked_t on_blocked; /* called from plugin::schedule() */ |
27 | preempt_t on_preempt; /* called from plugin::schedule() */ | 33 | preempt_t on_preempt; /* called from plugin::schedule() */ |
28 | sleep_t on_sleep; /* called from plugin::schedule() */ | 34 | sleep_t on_sleep; /* called from plugin::schedule() */ |
35 | wakeup_t on_wakeup; | ||
29 | 36 | ||
30 | exit_t on_exit; /* task exiting rt mode */ | 37 | exit_t on_exit; /* task exiting rt mode */ |
31 | 38 | ||
@@ -33,6 +40,9 @@ struct budget_tracker_ops | |||
33 | 40 | ||
34 | inherit_t on_inherit; | 41 | inherit_t on_inherit; |
35 | disinherit_t on_disinherit; | 42 | disinherit_t on_disinherit; |
43 | |||
44 | enter_top_m_t on_enter_top_m; | ||
45 | exit_top_m_t on_exit_top_m; | ||
36 | }; | 46 | }; |
37 | 47 | ||
38 | struct budget_tracker | 48 | struct budget_tracker |
@@ -40,13 +50,17 @@ struct budget_tracker | |||
40 | struct enforcement_timer timer; | 50 | struct enforcement_timer timer; |
41 | const struct budget_tracker_ops* ops; | 51 | const struct budget_tracker_ops* ops; |
42 | unsigned long flags; | 52 | unsigned long flags; |
53 | |||
54 | struct binheap_node top_m_node; | ||
55 | lt_t suspend_timestamp; | ||
43 | }; | 56 | }; |
44 | 57 | ||
45 | /* budget tracker flags */ | 58 | /* budget tracker flags */ |
46 | enum BT_FLAGS | 59 | enum BT_FLAGS |
47 | { | 60 | { |
48 | BTF_BUDGET_EXHAUSTED = 0, | 61 | BTF_BUDGET_EXHAUSTED = 0, |
49 | BTF_SIG_BUDGET_SENT = 1, | 62 | BTF_SIG_BUDGET_SENT = 1, |
63 | BTF_IS_TOP_M = 2, | ||
50 | }; | 64 | }; |
51 | 65 | ||
52 | /* Functions for simple DRAIN_SIMPLE policy common | 66 | /* Functions for simple DRAIN_SIMPLE policy common |
@@ -66,16 +80,38 @@ void simple_on_exit(struct task_struct* t); | |||
66 | * | 80 | * |
67 | * Limitation: Quantum budget tracking is unsupported. | 81 | * Limitation: Quantum budget tracking is unsupported. |
68 | */ | 82 | */ |
69 | void sobliv_on_scheduled(struct task_struct* t); | 83 | //void sobliv_on_scheduled(struct task_struct* t); |
70 | void sobliv_on_blocked(struct task_struct* t); | 84 | void sobliv_on_blocked(struct task_struct* t); |
71 | void sobliv_on_sleep(struct task_struct* t); | 85 | void sobliv_on_wakeup(struct task_struct* t); |
86 | //void sobliv_on_sleep(struct task_struct* t); | ||
87 | //void sobliv_on_preempt(struct task_struct* t); | ||
72 | /* Use the DRAIN_SIMPLE implementations */ | 88 | /* Use the DRAIN_SIMPLE implementations */ |
73 | #define sobliv_on_preempt simple_on_preempt | ||
74 | #define sobliv_on_exit simple_on_exit | 89 | #define sobliv_on_exit simple_on_exit |
75 | void sobliv_on_inherit(struct task_struct* t, struct task_struct* prio_inh); | 90 | void sobliv_on_inherit(struct task_struct* t, struct task_struct* prio_inh); |
76 | void sobliv_on_disinherit(struct task_struct* t, struct task_struct* prio_inh); | 91 | void sobliv_on_disinherit(struct task_struct* t, struct task_struct* prio_inh); |
92 | void sobliv_on_enter_top_m(struct task_struct* t); | ||
93 | void sobliv_on_exit_top_m(struct task_struct* t); | ||
94 | |||
77 | void sobliv_revaluate_task(struct task_struct* t); | 95 | void sobliv_revaluate_task(struct task_struct* t); |
78 | 96 | ||
97 | #define budget_state_machine(t, evt) \ | ||
98 | do { \ | ||
99 | if (get_budget_timer(t).ops && \ | ||
100 | get_budget_timer(t).ops->evt != NULL) { \ | ||
101 | get_budget_timer(t).ops->evt(t); \ | ||
102 | } \ | ||
103 | }while(0) | ||
104 | |||
105 | #define budget_state_machine2(a, b, evt) \ | ||
106 | do { \ | ||
107 | if (get_budget_timer(a).ops && \ | ||
108 | get_budget_timer(b).ops && \ | ||
109 | get_budget_timer(a).ops->evt != NULL && \ | ||
110 | get_budget_timer(b).ops->evt != NULL) {\ | ||
111 | get_budget_timer(a).ops->evt(a, b); \ | ||
112 | } \ | ||
113 | }while(0) | ||
114 | |||
79 | 115 | ||
80 | void init_budget_tracker(struct budget_tracker* bt, | 116 | void init_budget_tracker(struct budget_tracker* bt, |
81 | const struct budget_tracker_ops* ops); | 117 | const struct budget_tracker_ops* ops); |