First, busy-waiting (for two seconds):
unsigned long timeout = jiffies + (2*HZ);Or we can use sleep-waiting (better):
while (time_before(jiffies, timeout)) continue;
unsigned long timeout = jiffies + (2*HZ);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>
schedule_timeout(timeout);
No comments:
Post a Comment