blob: bdfc41004d38b3c5704d8888b701d28f93e3af56 (
plain) (
tree)
|
|
/* 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)
{
/* Shift all tasks that are actually daemons that inherit
* priority to be released immediatly. They need to be ready to run
* at _all_ times.
*/
if (unlikely(is_persistent(t))) {
release = litmus_clock();
}
/* 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;
clear_bit(RT_JOB_SIG_BUDGET_SENT, &t->rt_param.job_params.flags);
/* update job sequence number */
t->rt_param.job_params.job_no++;
/* don't confuse Linux */
t->rt.time_slice = 1;
}
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;
}
|