Linux 有人能解释一下什么是cpu统计中的最佳时间吗?
我知道用户时间和系统时间之间的区别。然而,我不太确定这段美好的时光。我以前知道nice time是nice pr中使用的时间,但当我做一个实验时,我发现在我将使用100%CPU的程序(无限循环执行加载项Java)重新设置为19后,nice time并没有增长。所以,我很困惑Linux 有人能解释一下什么是cpu统计中的最佳时间吗?,linux,system,Linux,System,我知道用户时间和系统时间之间的区别。然而,我不太确定这段美好的时光。我以前知道nice time是nice pr中使用的时间,但当我做一个实验时,我发现在我将使用100%CPU的程序(无限循环执行加载项Java)重新设置为19后,nice time并没有增长。所以,我很困惑
total=user+sys+idle
或
total=user+sys+nice+idle
甚至
total=user+sys+nice+idle+iowait+…
(整行)
哪个是正确的?Mpstat(1)读取/proc/stat
。潜入内核源代码树,我发现一个文件kernel/sched/cputime.c
,取自Linux 3.11.7源代码,其中似乎包含更新/proc/stat
中反映的内容的相关位:
/*
* Account user cpu time to a process.
* @p: the process that the cpu time gets accounted to
* @cputime: the cpu time spent in user space since the last update
* @cputime_scaled: cputime scaled by cpu frequency
*/
void account_user_time(struct task_struct *p, cputime_t cputime,
cputime_t cputime_scaled)
{
int index;
/* Add user time to process. */
p->utime += cputime;
p->utimescaled += cputime_scaled;
account_group_user_time(p, cputime);
index = (TASK_NICE(p) > 0) ? CPUTIME_NICE : CPUTIME_USER;
/* Add user time to cpustat. */
task_group_account_field(p, index, (__force u64) cputime);
/* Account for user time used */
acct_account_cputime(p);
}
这提示运行niced任务所花费的时间不包括在显示运行用户模式任务所花费时间的列中(行索引=
似乎与此相关)。Mpstat(1)读取/proc/stat
。潜入内核源代码树,我发现一个文件kernel/sched/cputime.c
,取自Linux 3.11.7源代码,其中似乎包含更新/proc/stat
中反映的内容的相关位:
/*
* Account user cpu time to a process.
* @p: the process that the cpu time gets accounted to
* @cputime: the cpu time spent in user space since the last update
* @cputime_scaled: cputime scaled by cpu frequency
*/
void account_user_time(struct task_struct *p, cputime_t cputime,
cputime_t cputime_scaled)
{
int index;
/* Add user time to process. */
p->utime += cputime;
p->utimescaled += cputime_scaled;
account_group_user_time(p, cputime);
index = (TASK_NICE(p) > 0) ? CPUTIME_NICE : CPUTIME_USER;
/* Add user time to cpustat. */
task_group_account_field(p, index, (__force u64) cputime);
/* Account for user time used */
acct_account_cputime(p);
}
这提示运行niced任务所花费的时间不包括在显示运行用户模式任务所花费的时间的列中(行
索引=
似乎与此相关).我想这回答了你的问题:@davek我不知道用户时间中是否包含美好时光?我想这回答了你的问题:@davek我不知道用户时间中是否包含美好时光?是的,我转向内核源代码,最后找到了cat/proc/stat打印出来的所有10列的含义。。。谢谢是的,我转向内核源代码,最后找到了cat/proc/stat打印出来的所有10列的含义。。。谢谢