最佳答案
我很快就把它放在一起了。它从任务切换中打印出最小和最大的“干扰”……
#include <sys/time.h>
#include <stdio.h>
double seconds()
{
timeval t;
gettimeofday(&t, NULL);
return t.tv_sec + t.tv_usec / 1000000.0;
}
int main()
{
double min = 999999999, max = 0;
while (true)
{
double c = -(seconds() - seconds());
if (c < min)
{
min = c;
printf("%f\n", c);
fflush(stdout);
}
if (c > max)
{
max = c;
printf("%f\n", c);
fflush(stdout);
}
}
return 0;
}
关于linux - Linux 中进程的 CPU 争用(等待时间),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3239118/