Wait Queues¶
Purpose¶
Wait queues allow a driver to put a process to sleep until a condition becomes true.
Common APIs¶
init_waitqueue_head(&dev->wq);
wait_event_interruptible(dev->wq, condition);
wake_up_interruptible(&dev->wq);
Typical Read Path¶
Return Behavior¶
| Situation | Typical Result |
|---|---|
| Condition becomes true | Continue read path |
| Interrupted by signal | Return error, often -ERESTARTSYS |
| Non-blocking mode | Do not wait; return -EAGAIN |
Common Pitfalls¶
Warning
The wakeup function only wakes sleeping tasks. The waiting condition must still become true.
Warning
Always check the condition after wakeup.