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

cobalt/sched: sporadic: 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 e3411d4c
......@@ -290,11 +290,9 @@ static void xnsched_sporadic_protectprio(struct xnthread *thread, int prio)
thread->cprio = prio;
}
static int xnsched_sporadic_declare(struct xnthread *thread,
const union xnsched_policy_param *p)
static int xnsched_sporadic_chkparam(struct xnthread *thread,
const union xnsched_policy_param *p)
{
struct xnsched_sporadic_data *pss;
if (p->pss.low_prio != -1 &&
(p->pss.low_prio < XNSCHED_SPORADIC_MIN_PRIO ||
p->pss.low_prio > XNSCHED_SPORADIC_MAX_PRIO))
......@@ -319,6 +317,14 @@ static int xnsched_sporadic_declare(struct xnthread *thread,
if (p->pss.max_repl < 1 || p->pss.max_repl > MAX_REPLENISH)
return -EINVAL;
return 0;
}
static int xnsched_sporadic_declare(struct xnthread *thread,
const union xnsched_policy_param *p)
{
struct xnsched_sporadic_data *pss;
pss = xnmalloc(sizeof(*pss));
if (pss == NULL)
return -ENOMEM;
......@@ -535,6 +541,7 @@ struct xnsched_class xnsched_class_sporadic = {
.sched_tick = NULL,
.sched_rotate = NULL,
.sched_migrate = NULL,
.sched_chkparam = xnsched_sporadic_chkparam,
.sched_setparam = xnsched_sporadic_setparam,
.sched_getparam = xnsched_sporadic_getparam,
.sched_trackprio = xnsched_sporadic_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