Commit 4aa8dcc0 authored by Philippe Gerum's avatar Philippe Gerum Committed by Jan Kiszka

cobalt/sched: add per-policy handler for early parameter checking

We need policy-specific scheduling parameters to be checked early and
unconditionally before applying them in xnsched_setparam(), even if
the current scheduling policy does not change for the target thread
(i.e. sched_declare() is not called).
Signed-off-by: Philippe Gerum's avatarPhilippe Gerum <rpm@xenomai.org>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent 654bb06d
......@@ -138,6 +138,8 @@ struct xnsched_class {
const union xnsched_policy_param *p);
void (*sched_migrate)(struct xnthread *thread,
struct xnsched *sched);
int (*sched_chkparam)(struct xnthread *thread,
const union xnsched_policy_param *p);
/**
* Set base scheduling parameters. This routine is indirectly
* called upon a change of base scheduling settings through
......@@ -513,6 +515,16 @@ static inline void xnsched_tick(struct xnsched *sched)
sched_class->sched_tick(sched);
}
static inline int xnsched_chkparam(struct xnsched_class *sched_class,
struct xnthread *thread,
const union xnsched_policy_param *p)
{
if (sched_class->sched_chkparam)
return sched_class->sched_chkparam(thread, p);
return 0;
}
static inline int xnsched_declare(struct xnsched_class *sched_class,
struct xnthread *thread,
const union xnsched_policy_param *p)
......
......@@ -434,6 +434,10 @@ int xnsched_set_policy(struct xnthread *thread,
bool effective;
int ret;
ret = xnsched_chkparam(sched_class, thread, p);
if (ret)
return ret;
/*
* Declaring a thread to a new scheduling class may fail, so
* we do that early, while the thread is still a member of the
......
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