Linux Process Sleep and Wakeup: Preventing Lost Wakeups with Correct State Ordering
This article explains Linux process states (TASK_RUNNING, TASK_INTERRUPTIBLE, TASK_UNINTERRUPTIBLE), the schedule() and wake_up_process() mechanisms, the lost wakeup race condition that occurs when a process checks a condition before setting its sleep state, and the correct pattern used in the Linux kernel—setting the state to interruptible before condition checking and looping with schedule()—to avoid indefinite sleep.
