* How to schedule idle_task?
@ 2003-08-08 15:44 Feng Pan
2003-08-08 21:18 ` Herbert Pötzl
2003-08-08 22:13 ` George Anzinger
0 siblings, 2 replies; 3+ messages in thread
From: Feng Pan @ 2003-08-08 15:44 UTC (permalink / raw)
To: linux-kernel
Hi,
I am trying to force idle_task in schedule() but could not get it to work.
Here is my requirement: I would like the scheduler to prevent any task
with low priority (meaning lower than a cutoff point) from being scheduled
to run, even if there are no high priority tasks running (when this
happens, idle_task should be scheduled to run). They (the low priority
tasks) have to wait until their dynamic priorities boosted to be able to
run.
So here is what I added to schedule():
/*
* Default process to select..
*/
next = idle_task(this_cpu);
c = -1000;
list_for_each(tmp, &runqueue_head) {
p = list_entry(tmp, struct task_struct, run_list);
if (can_schedule(p, this_cpu)) {
int weight = goodness(p, this_cpu, prev->active_mm);
if (weight > c)
c = weight, next = p;
}
}
// This is what I added:
if((c > 2) && (c < CUTOFF_PRIORITY)) {
//printk("LOW PRIORITY PROCESS (%d)\n", c);
next = idle_task(this_cpu);
}
// End
/* Do we need to re-calculate counters? */
if (unlikely(!c))
...
...
...
The problem is that once the idle_task is forced to run, no other tasks
can be scheduled again, and the system hangs, even if there is another
high priority task running. And if I uncomment the printk statement, the
message is printed repeatly.
So the question is, how do I do this properly so that high priority tasks
can still run?
btw, the kernel version is 2.4.21
Thanks
Feng
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to schedule idle_task?
2003-08-08 15:44 How to schedule idle_task? Feng Pan
@ 2003-08-08 21:18 ` Herbert Pötzl
2003-08-08 22:13 ` George Anzinger
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Pötzl @ 2003-08-08 21:18 UTC (permalink / raw)
To: Feng Pan; +Cc: linux-kernel
On Fri, Aug 08, 2003 at 11:44:28AM -0400, Feng Pan wrote:
> Hi,
>
> I am trying to force idle_task in schedule() but could not get it to work.
> Here is my requirement: I would like the scheduler to prevent any task
> with low priority (meaning lower than a cutoff point) from being scheduled
> to run, even if there are no high priority tasks running (when this
> happens, idle_task should be scheduled to run). They (the low priority
> tasks) have to wait until their dynamic priorities boosted to be able to
> run.
hmm, why not simply _not_scheduling_ the tasks you do
not want to be scheduled? (sounds weird?)
in the scheduler, you basically decide which task
is the chosen one, if you decide to exclude some tasks
from that decision, they will not run (be scheduled)
HTH,
Herbert
> So here is what I added to schedule():
>
> /*
> * Default process to select..
> */
> next = idle_task(this_cpu);
> c = -1000;
> list_for_each(tmp, &runqueue_head) {
> p = list_entry(tmp, struct task_struct, run_list);
> if (can_schedule(p, this_cpu)) {
> int weight = goodness(p, this_cpu, prev->active_mm);
> if (weight > c)
> c = weight, next = p;
> }
> }
>
>
> // This is what I added:
>
> if((c > 2) && (c < CUTOFF_PRIORITY)) {
> //printk("LOW PRIORITY PROCESS (%d)\n", c);
> next = idle_task(this_cpu);
> }
>
>
> // End
>
> /* Do we need to re-calculate counters? */
> if (unlikely(!c))
> ...
> ...
> ...
>
>
> The problem is that once the idle_task is forced to run, no other tasks
> can be scheduled again, and the system hangs, even if there is another
> high priority task running. And if I uncomment the printk statement, the
> message is printed repeatly.
>
> So the question is, how do I do this properly so that high priority tasks
> can still run?
>
> btw, the kernel version is 2.4.21
>
> Thanks
>
> Feng
>
>
> -
> 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/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to schedule idle_task?
2003-08-08 15:44 How to schedule idle_task? Feng Pan
2003-08-08 21:18 ` Herbert Pötzl
@ 2003-08-08 22:13 ` George Anzinger
1 sibling, 0 replies; 3+ messages in thread
From: George Anzinger @ 2003-08-08 22:13 UTC (permalink / raw)
To: fp38660; +Cc: linux-kernel
Feng Pan wrote:
> Hi,
>
> I am trying to force idle_task in schedule() but could not get it to work.
> Here is my requirement: I would like the scheduler to prevent any task
> with low priority (meaning lower than a cutoff point) from being scheduled
> to run, even if there are no high priority tasks running (when this
> happens, idle_task should be scheduled to run). They (the low priority
> tasks) have to wait until their dynamic priorities boosted to be able to
> run.
>
> So here is what I added to schedule():
>
> /*
> * Default process to select..
> */
> next = idle_task(this_cpu);
> c = -1000;
> list_for_each(tmp, &runqueue_head) {
> p = list_entry(tmp, struct task_struct, run_list);
> if (can_schedule(p, this_cpu)) {
> int weight = goodness(p, this_cpu, prev->active_mm);
> if (weight > c)
> c = weight, next = p;
> }
> }
>
>
> // This is what I added:
>
> if((c > 2) && (c < CUTOFF_PRIORITY)) {
> //printk("LOW PRIORITY PROCESS (%d)\n", c);
> next = idle_task(this_cpu);
> }
>
>
> // End
>
> /* Do we need to re-calculate counters? */
> if (unlikely(!c))
> ...
> ...
> ...
>
>
> The problem is that once the idle_task is forced to run, no other tasks
> can be scheduled again, and the system hangs, even if there is another
> high priority task running. And if I uncomment the printk statement, the
> message is printed repeatly.
>
> So the question is, how do I do this properly so that high priority tasks
> can still run?
Not to endorse what you are doing, but, the recalc will not be done
until all the current times expire and you have put a floor on them
ever expiring so the recalc will never be done...
SCHED_SPORADIC is not that simple.. :)
--
George Anzinger george@mvista.com
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-08-13 19:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-08 15:44 How to schedule idle_task? Feng Pan
2003-08-08 21:18 ` Herbert Pötzl
2003-08-08 22:13 ` George Anzinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox