Re: schedule()

Nigel Gamble (nigel@nrg.org)
Tue, 26 Feb 2002 16:56:24 -0800 (PST)


On Tue, 26 Feb 2002, Jeff Garzik wrote:
> "Richard B. Johnson" wrote:
> >
> > I just read on this list that:
> >
> > while(something)
> > {
> > current->policy |= SCHED_YIELD;
> > schedule();
> > }
> >
> > Will no longer be allowed in a kernel module! If this is true, how
> > do I loop, waiting for a bit in a port, without wasting CPU time?
>
> Call yield() or better yet, schedule_timeout()

Yes, please use schedule_timeout() if at all possible, or make sure that
the loop will only ever execute for a few 100us at most.

One thing to bear in mind is that using yield() will waste CPU time if
the code is ever called by a real-time process (unless it is a SCHED_RR
process with other runnable SCHED_RR processes at the same priority),
because there will be no other process that the scheduler is allowed to
run, so the RT process will just be chosen to run again, with no delay.

We really need high resolution timers, so that schedule_timeout() can be
used for delays of less than one jiffy.

Nigel Gamble nigel@nrg.org
Mountain View, CA, USA. http://www.nrg.org/

-
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/