Waiting and Scheduling in Driver Code
Drivers constantly need to wait: a few microseconds for a chip to settle, a millisecond before retrying, or a callback in one second to check a timeout. The kernel distinguishes busy-waiting, which burns the processor and is the only option in atomic context, from sleeping, which is correct everywhere else, and gives a high-resolution timer for callbacks. Kernel Rust wraps durations in a type with explicit units so microseconds and milliseconds cannot be confused, and the sleep helper picks the right underlying mechanism for the length you asked for. Getting this wrong in C means either a machine that stutters or a chip read before it was ready.
Questions this Concept answers
- Why does kernel Rust wrap durations in a type that carries explicit units?
This Concept is waiting for its first lesson!
Drivers constantly need to wait: a few microseconds for a chip to settle, a millisecond before retrying, or a callback in one second to check a timeout. The kernel distinguishes busy-waiting, which burns the processor and is the only option in atomic context, from sleeping, which is correct everywhere else, and gives a high-resolution timer for callbacks. Kernel Rust wraps durations in a type with explicit units so microseconds and milliseconds cannot be confused, and the sleep helper picks the right underlying mechanism for the length you asked for. Getting this wrong in C means either a machine that stutters or a chip read before it was ready.
Are you a teacher? Sign in to start contributing.
Sign In