Exemplo n.º 1
0
int set_process(pid_t pid, int policy, struct sched_param_ex *p)
{
	int ret;

	char *msg1="could not set PID %d to %s";
	char *msg2="could not set PID %d to raw policy #%d";

	/* anything other than 0 indicates error */
	if((ret=sched_setscheduler_ex(pid, policy, sizeof(*p), p))) {

                /* la la pointer mismatch .. lala */
		decode_error((CHECK_RANGE_POLICY(policy) ? msg1 : msg2),
			     pid,
			     (CHECK_RANGE_POLICY(policy) ? TAB[policy] : policy)
			    );
		return(ret);
	}
	return(0);
}
Exemplo n.º 2
0
/**
 * set the scheduler internally in the Linux kernel.
 */
static int edf_set_scheduler(resch_task_t *rt, int prio)
{
	struct sched_param sp;
	struct sched_param_ex spx;
	struct timespec ts_period, ts_deadline, ts_runtime;

	jiffies_to_timespec(rt->period, &ts_period);
	jiffies_to_timespec(rt->deadline, &ts_deadline);
	jiffies_to_timespec(usecs_to_jiffies(rt->runtime), &ts_runtime);
	sp.sched_priority = 0;
	spx.sched_priority = 0;
	spx.sched_period = ts_period;
	spx.sched_deadline = ts_deadline;
	spx.sched_runtime = ts_runtime;
	spx.sched_flags = 0;
	if (sched_setscheduler_ex(rt->task, SCHED_DEADLINE, &sp, &spx) < 0) {
		printk(KERN_WARNING "RESCH: edf_set_scheduler() failed.\n");
		printk(KERN_WARNING "RESCH: task#%d (process#%d) priority=%d.\n",
			   rt->rid, rt->task->pid, prio);
		return false;
	}

	rt->prio = prio;

	if (task_has_reserve(rt)) {
		rt->task->dl.flags &= ~SCHED_EXHAUSTIVE;
		rt->task->dl.flags |= SCHED_FCBS;
		/* you can additionally set the following flags, if wanted.
		   rt->task->dl.flags |= SCHED_FCBS_NO_CATCH_UP; */
	}
	else {
		rt->task->dl.flags |= SCHED_EXHAUSTIVE;
		rt->task->dl.flags &= ~SCHED_FCBS;
	}

	return true;
}