Without further ado, let's take a look at a table that quickly summarizes the available (to us module authors) non-blocking or atomic *delay() kernel APIs; they're meant to be used in any kind of atomic or interrupt context where you cannot block or sleep (or invoke schedule()):
API | Comment |
ndelay(ns); | Delay for ns nanoseconds. |
udelay(us); | Delay for us microseconds. |
mdelay(ms); | Delay for ms milliseconds. |
Table 5.1 – The *delay() non-blocking APIs
There are a few points to note regarding these APIs, their internal implementation, and their usage:
- Always include the <linux/delay.h> header when using these macros/APIs.
- You are expected to call an appropriate routine based on the time you must delay for; for example, if you need to perform an atomic non-blocking delay of, say, 30 milliseconds, you should call mdelay(30) and not udelay(30*1000). The kernel...