Commit e71ee1c6 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 ac62dc9c
......@@ -140,6 +140,33 @@ 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
* __xnthread_set_schedparam() -> xnsched_set_policy(),
* exclusively.
*
* The scheduling class implementation should do the necessary
* housekeeping to comply with the new settings.
* thread->base_class is up to date before the call is made,
* and should be considered for the new weighted priority
* calculation. On the contrary, thread->sched_class should
* NOT be referred to by this handler.
*
* sched_setparam() is NEVER involved in PI or PP
* management. However it must deny a priority update if it
* contradicts an ongoing boost for @a thread. This is
* typically what the xnsched_set_effective_priority() helper
* does for such handler.
*
* @param thread Affected thread.
* @param p New base policy settings.
*
* @return True if the effective priority was updated
* (thread->cprio).
*/
void (*sched_setparam)(struct xnthread *thread,
const union xnsched_policy_param *p);
void (*sched_getparam)(struct xnthread *thread,
......@@ -494,6 +521,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)
......
......@@ -380,6 +380,10 @@ int xnsched_set_policy(struct xnthread *thread,
{
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