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

Jens Axboe (axboe@image.dk)
Wed, 1 Dec 1999 15:03:53 +0000


On Wed, Dec 01 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 );
>
> since it is too long and blocks the whole cpu from doing sensible stuff.
>
> static void jiffy_sleep(u_int time)
> {
> current->state = TASK_INTERRUPTIBLE;
> current->timeout = jiffies + time;
> schedule();
> }
>
> Is this still applicable and racecondition-save?

Not in an interrupt context. Basically you can't sleep or
schedule inside an interrupt handler. How long do you need
to wait?

-- 
*  Jens Axboe <axboe@image.dk>
*  Linux CD-ROM Maintainer
*  http://www.kernel.dk

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