blob: ecfaf4cd477ab956e1bbbd3611670936c60c2842 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/* litmus/jobs.c - common job control code
*/
#include <linux/sched.h>
#include <litmus/litmus.h>
#include <litmus/jobs.h>
//static inline void setup_release(struct task_struct *t, lt_t release)
void setup_release(struct task_struct *t, lt_t release)
{
/* prepare next release */
t->rt_param.job_params.release = release;
t->rt_param.job_params.deadline = release + get_rt_relative_deadline(t);
t->rt_param.job_params.exec_time = 0;
/* kludge - TODO: Move this to budget.h/.c */
if (t->rt_param.budget.ops)
bt_flags_reset(t);
/* update job sequence number */
t->rt_param.job_params.job_no++;
/* don't confuse Linux */
t->rt.time_slice = 1;
TRACE_TASK(t, "preparing for next job: %d\n", t->rt_param.job_params.job_no);
}
void prepare_for_next_period(struct task_struct *t)
{
BUG_ON(!t);
/* Record lateness before we set up the next job's
* release and deadline. Lateness may be negative.
*/
t->rt_param.job_params.lateness =
(long long)litmus_clock() -
(long long)t->rt_param.job_params.deadline;
setup_release(t, get_release(t) + get_rt_period(t));
}
void release_at(struct task_struct *t, lt_t start)
{
BUG_ON(!t);
setup_release(t, start);
t->rt_param.completed = 0;
}
/*
* Deactivate current task until the beginning of the next period.
*/
long complete_job(void)
{
/* Mark that we do not excute anymore */
tsk_rt(current)->completed = 1;
/* call schedule, this will return when a new job arrives
* it also takes care of preparing for the next release
*/
schedule();
return 0;
}
#if defined(CONFIG_REALTIME_AUX_TASKS) || defined(CONFIG_LITMUS_NVIDIA)
void hide_from_workers(struct task_struct *t, worker_visibility_t *wv)
{
#ifdef CONFIG_REALTIME_AUX_TASKS
if (tsk_rt(t)->has_aux_tasks) {
if (wv) {
wv->aux_hide = tsk_rt(t)->hide_from_aux_tasks;
wv->do_aux_restore = 1;
}
tsk_rt(t)->hide_from_aux_tasks = 1;
}
#endif
#ifdef CONFIG_LITMUS_NVIDIA
if (tsk_rt(t)->held_gpus) {
if (wv) {
wv->gpu_hide = tsk_rt(t)->hide_from_gpu;
wv->do_gpu_restore = 1;
}
tsk_rt(t)->hide_from_gpu = 1;
}
#endif
}
void show_to_workers(struct task_struct *t, worker_visibility_t *wv)
{
if (wv) {
#ifdef CONFIG_REALTIME_AUX_TASKS
if (wv->do_aux_restore)
tsk_rt(t)->hide_from_aux_tasks = wv->aux_hide;
#endif
#ifdef CONFIG_LITMUS_NVIDIA
if (wv->do_gpu_restore)
tsk_rt(t)->hide_from_gpu = wv->gpu_hide;
#endif
}
else {
#ifdef CONFIG_REALTIME_AUX_TASKS
if (tsk_rt(t)->has_aux_tasks)
tsk_rt(t)->hide_from_aux_tasks = 0;
#endif
#ifdef CONFIG_LITMUS_NVIDIA
if (tsk_rt(t)->held_gpus)
tsk_rt(t)->hide_from_gpu = 0;
#endif
}
}
#endif
|