$linuxjunkies
>

wait queue

also: sleep queue

A kernel data structure that holds processes blocked waiting for a specific event or resource to become available, allowing the kernel to efficiently wake them when the event occurs.

A wait queue is a list maintained by the Linux kernel that tracks processes (or threads) that are temporarily blocked and waiting for some condition to be satisfied. Rather than continuously checking if the condition is met, processes are placed into a sleep state on the wait queue and awakened only when the event they're waiting for actually occurs.

Wait queues are commonly used for I/O operations, synchronization primitives, and resource availability. For example, when a process reads from a file descriptor that has no data yet, it's added to a wait queue. When data arrives, the kernel wakes processes on that queue so they can continue execution.

Kernel code declares wait queues using structures like wait_queue_head_t and uses functions such as wait_event() to put processes to sleep and wake_up() to signal waiting processes. This mechanism is more efficient than busy-waiting or polling, as it avoids wasting CPU cycles.

Related terms