问题描述
#include <stdio.h>
#include <time.h>
int main()
{
struct timespec stReq;
stReq.tv_sec = 0;
stReq.tv_nsec = 1;
while(1)
{
nanosleep(&stReq,NULL);
printf("hello,world\n");
}
return 0;
}
运行此进度时,%cpu
显示的top
列大约只有2%
。
为什么这么低?
解决方法
- 因为该程序无所事事
- 您的系统具有足够好的cpu内核。
- 它将在cpu的哪一部分显示2%?我们,sy,id,wa,st?