lkml.org 
[lkml]   [2003]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[patch] setscheduler fix
From
Date
Here is my patch. It is the same idea as Joe's. Is there a better fix?

Basically, the problem is that setscheduler() does not set need_resched
when needed. There are two basic cases where this is needed:

- the task is running, but now it is no longer the highest
priority task on the rq
- the task is not running, but now it is the highest
priority task on the rq

In either case, we need to set need_resched to invoke the scheduler.

Patch is against 2.5.72. Comments?

Robert Love


setschedule() needs to force a reschedule in some situations.

kernel/sched.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletion(-)


diff -urN linux-2.5.72/kernel/sched.c linux/kernel/sched.c
--- linux-2.5.72/kernel/sched.c 2003-06-16 21:20:20.000000000 -0700
+++ linux/kernel/sched.c 2003-06-17 13:44:15.509894276 -0700
@@ -1691,6 +1691,7 @@
{
struct sched_param lp;
int retval = -EINVAL;
+ int oldprio;
prio_array_t *array;
unsigned long flags;
runqueue_t *rq;
@@ -1757,12 +1758,24 @@
retval = 0;
p->policy = policy;
p->rt_priority = lp.sched_priority;
+ oldprio = p->prio;
if (policy != SCHED_NORMAL)
p->prio = MAX_USER_RT_PRIO-1 - p->rt_priority;
else
p->prio = p->static_prio;
- if (array)
+ if (array) {
__activate_task(p, task_rq(p));
+ /*
+ * Reschedule if we are currently running on this runqueue and
+ * our priority decreased, or if we are not currently running on
+ * this runqueue and our priority is higher than the current's
+ */
+ if (rq->curr == p) {
+ if (p->prio > oldprio)
+ resched_task(rq->curr);
+ } else if (p->prio < rq->curr->prio)
+ resched_task(rq->curr);
+ }

out_unlock:
task_rq_unlock(rq, &flags);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:36    [W:0.263 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site