lkml.org 
[lkml]   [2001]   [May]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe:
Date
From
>     while(!!time_before(jiffies, timer))
> {
> if(!!(*event & mask))
> {
> stat = 0;
> break;
> }
> schedule();

You want to yield as well otherwise you may just spin anyway

> Both of these procedures schedule() while waiting for something to
> happen. The wait can be very long (1 second) so I don't want to
> just spin eating CPU cycles. I have to give the CPU to somebody.

So use a timer


void tick_tick_boom(unsigned long l)
{
struct my_device *d = (struct my_device *)l;

if(its_still_busy(d))
{
d->timer_count--;
if(d->timer_count)
{
/* Try again until timer_count hits zero */
add_timer(&t->timer, jiffies+1);
return;
}
else
{
/* Lose some .. */
d->event_status = TIMEOUT;
}
}
else
{
/* Win some .. */
d->event_status = OK;
}
/* Wake up the invoker */
wake_up(&d->timer_wait);
}

-
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 12:52    [W:0.044 / U:0.384 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site