Post #572183
2026-02-23 10:49 UTC
RE: https://phpc.social/@flowcontrol/116087650104683820
Not only can it return earlier, it can also return later.
Technically, `sleep()` tells the kernel “don’t schedule me until at least X time has passed”. The kernel puts the task into an interruptible sleep state and removes it from the run queue. A timer expiry marks it runnable again, and then the scheduler will run it when it gets CPU time, which can be a bit later depending on load and priority. It can also wake early if a signal interrupts the sleep.
Replies (1)
-
@flowcontrol@phpc.social 2026-02-23 10:50
If it returns early, `sleep()` returns the amount of seconds left to sleep, see https://www.php.net/sleep (besides on Windows)