From 3a93be89020f88d030ff3f0d769753b9d7ac8b92 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 30 Jul 2015 07:36:01 -0600 Subject: [PATCH] Add strictly limit check: The current sporadic scheduler cannot handler duties > 50% --- sched/sched/sched_setparam.c | 7 +++++++ sched/sched/sched_setscheduler.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/sched/sched/sched_setparam.c b/sched/sched/sched_setparam.c index 42bfe06303d..fa355c884ae 100644 --- a/sched/sched/sched_setparam.c +++ b/sched/sched/sched_setparam.c @@ -163,8 +163,15 @@ int sched_setparam(pid_t pid, FAR const struct sched_param *param) /* The replenishment period must be greater than or equal to the * budget period. */ +#if 1 + /* REVISIT: In the current implementation, the budget cannot exceed + * half the duty. + */ + if (repl_ticks < (2 * budget_ticks)) +#else if (repl_ticks < budget_ticks) +#endif { errcode = EINVAL; goto errout_with_lock; diff --git a/sched/sched/sched_setscheduler.c b/sched/sched/sched_setscheduler.c index 34c5750939b..841d9eb1659 100644 --- a/sched/sched/sched_setscheduler.c +++ b/sched/sched/sched_setscheduler.c @@ -209,8 +209,15 @@ int sched_setscheduler(pid_t pid, int policy, /* The replenishment period must be greater than or equal to the * budget period. */ +#if 1 + /* REVISIT: In the current implementation, the budget cannot + * exceed half the duty. + */ + if (repl_ticks < (2 * budget_ticks)) +#else if (repl_ticks < budget_ticks) +#endif { errcode = EINVAL; goto errout_with_irq;