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

Andreas Schuldei (schuldei@andrive.de)
Wed, 1 Dec 1999 14:48:26 +0100


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.

Back in 1996 eberhard moenkemaier wrote in this list:

----

/*
* * kernel mode waiting, time unit is jiffy (10 ms)
* */
static void jiffy_sleep(u_int time)
{
current->state = TASK_INTERRUPTIBLE;
current->timeout = jiffies + time;
schedule();
}

The task gets re-scheduled if the time has elapsed.
Calling it with 0 gives an indefinite short time, just allowing
other kernel mode tasks to get the CPU. }

---

Is this still applicable and racecondition-save?

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