How is sleep using cpu resources?
Does it use 100% or 0% of cpu when you sleep your script. Can you explain?
As far as i know it increases load average, but how does it use CPU?
How is sleep using cpu resources?
Does it use 100% or 0% of cpu when you sleep your script. Can you explain?
As far as i know it increases load average, but how does it use CPU?
The way that sleep
works is OS-dependent, because the PHP function sleep
calls into the appropriate runtime function to actually do what it says on the tin.
For Windows, that function is SleepEx
. For other operating systems it is the POSIX function sleep
. In both cases, the documentation for those functions clearly states that the sleeping thread is ineligible for running during the sleep period and therefore cannot consume CPU resources even if it wanted to.