睡眠如何吃 CPU php [英] How sleep eats CPU php

查看:51
本文介绍了睡眠如何吃 CPU php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

睡眠如何使用 cpu 资源?

当您休眠脚本时,它使用 100% 还是 0% 的 cpu.你可以解释吗?

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

据我所知它增加了平均负载,但它如何使用 CPU?

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

推荐答案

sleep 的工作方式是依赖于操作系统的,因为 PHP 函数 sleep 调用适当的运行时函数以实际执行它在罐头上所说的.

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.

对于 Windows,该函数是 SleepEx.对于其他操作系统是POSIX函数sleep.在这两种情况下,这些函数的文档都明确指出,休眠线程在休眠期间没有资格运行,因此即使想要也无法消耗 CPU 资源.

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.

这篇关于睡眠如何吃 CPU php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆