Pages

2010-09-08

Linux: Making some delays at the kernel context

To make some delays in the kernel context there are two solutions.

First, busy-waiting (for two seconds):
unsigned long timeout = jiffies + (2*HZ);
while (time_before(jiffies, timeout)) continue;
Or we can use sleep-waiting (better):
unsigned long timeout = jiffies + (2*HZ);
schedule_timeout(timeout);
Also, we have the msleep() function for sleeping in milliseconds, udelay() for microseconds delays and ndelay() for nanoseconds delays. We should include the header file <asm/delay.h>

No comments:

Post a Comment