How to sleep eating php processor

How to sleep using processor resources?

Does it use 100% or 0% of the processor when you sleep the script. Can you explain?

As far as I know, it increases the average load, but how does it use the CPU?

+6
source share
1 answer

The way sleep works depends on the OS, because the PHP sleep function calls the corresponding runtime function to actually do what it says to tin.

For Windows, this feature is SleepEx . For other operating systems, this is the POSIX sleep function. In both cases, the documentation for these functions clearly states that the sleeping thread is not suitable for work during the waiting period and therefore cannot consume CPU resources, even if it wants to.

+14
source

Source: https://habr.com/ru/post/944214/


All Articles