RE: Q: waiting for a short time and not beeing a resource hog

Bret Indrelee (bindrelee@sbs-cp.com)
Wed, 1 Dec 1999 10:04:01 -0600


Ingo Molnar [mailto:mingo@chiara.csoma.elte.hu] wrote:
> On Wed, 1 Dec 1999, Andreas Schuldei wrote:
>
> > I want to wait for a short time in a driver after I got an interrupt
> > that data arrived.
> >
> > I do not like the
> >
> > while( (jiffies-time_start) < 1 );
>
> you probably want to use schedule_timeout(deltajiffies). You must make
> sure that you can reschedule at that point.

If he is running in a bottom half or an interrupt handler, this wouldn't
work. No task context to sleep on.

Depending on the definition of short, it may be easier to just put the code
to execute on the tq_scheduler task queue. That will give a short delay
between the interrupt or bottom half that will usually be less than a tick.

As I understand it, putting it on the tq_scheduler queue makes it run after
all the other bottom halves but before the scheduler switches tasks.
According to the documentation I've got it is even safe to use
schedule_timeout() from there, although I'm not sure that is a good idea.

-Bret

-------------------------------------------------------------
SBS Technologies, Connectivity Products
... solutions for real-time connectivity

Bret Indrelee, Engineer
SBS Technologies, Inc., Connectivity Products
1284 Corporate Center Drive, St. Paul MN 55121
Direct: (651) 905-4731
Main: (651) 905-4700 Fax: (651) 905-4701
E-mail: bindrelee@sbs-cp.com http://www.sbs.com
-------------------------------------------------------------

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