[英]In the Linux kernel, what does it mean for a process to be “whole”?
此代码来自Linux头文件中的文件/fs/proc/array.c
. int whole
参数是什么意思? 我想知道为什么有时你需要从sig_struct
累积min_flt
和maj_flt
,有时候可以直接从task_struct
读取它们的值
346 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
347 struct pid *pid, struct task_struct *task, int whole)
...
406 /* add up live thread stats at the group level */
407 if (whole) {
408 struct task_struct *t = task;
409 do {
410 min_flt += t->min_flt;
411 maj_flt += t->maj_flt;
412 gtime = cputime_add(gtime, t->gtime);
413 t = next_thread(t);
414 } while (t != task);
415
416 min_flt += sig->min_flt;
417 maj_flt += sig->maj_flt;
418 thread_group_times(task, &utime, &stime);
419 gtime = cputime_add(gtime, sig->gtime);
420 }
...
431 if (!whole) {
432 min_flt = task->min_flt;
433 maj_flt = task->maj_flt;
434 task_times(task, &utime, &stime);
435 gtime = task->gtime;
436 }
“whole”只是一个参数名称,在这种情况下,它似乎表示“整个线程组的do_task_stat
”。
do_task_stat
是仅在/fs/proc/array.c
中使用的静态函数。它在两个地方使用: proc_tid_stat
(TID是“线程ID”)和proc_tgid_stat
(TGID是“线程组ID”)。
有关线程组的详细说明,请参阅Linux - 线程和进程 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.