Commit ce176805 authored by Philippe Gerum's avatar Philippe Gerum Committed by Jan Kiszka

cobalt/sched: tp: add early parameter checking handler

Move parameter checks from sched_declare() to the new sched_chkparam()
handler, which runs early and unconditionally from
xnsched_set_policy().
Signed-off-by: Philippe Gerum's avatarPhilippe Gerum <rpm@xenomai.org>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent cc87d708
......@@ -163,17 +163,24 @@ static void xnsched_tp_protectprio(struct xnthread *thread, int prio)
thread->cprio = prio;
}
static int xnsched_tp_declare(struct xnthread *thread,
const union xnsched_policy_param *p)
static int xnsched_tp_chkparam(struct xnthread *thread,
const union xnsched_policy_param *p)
{
struct xnsched *sched = thread->sched;
struct xnsched_tp *tp = &sched->tp;
struct xnsched_tp *tp = &thread->sched->tp;
if (tp->gps == NULL ||
p->tp.prio < XNSCHED_TP_MIN_PRIO ||
p->tp.prio > XNSCHED_TP_MAX_PRIO)
return -EINVAL;
return 0;
}
static int xnsched_tp_declare(struct xnthread *thread,
const union xnsched_policy_param *p)
{
struct xnsched *sched = thread->sched;
list_add_tail(&thread->tp_link, &sched->tp.threads);
return 0;
......@@ -434,6 +441,7 @@ struct xnsched_class xnsched_class_tp = {
.sched_tick = NULL,
.sched_rotate = NULL,
.sched_migrate = xnsched_tp_migrate,
.sched_chkparam = xnsched_tp_chkparam,
.sched_setparam = xnsched_tp_setparam,
.sched_getparam = xnsched_tp_getparam,
.sched_trackprio = xnsched_tp_trackprio,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment