Skip to contentSkip to conversation

sys_sysinfo()'s bug in reporting the number of processes

DISCUSSION Anton Lavrentiev 1 participant 1 message Feb 26, 2002

lore
Share & tools
lore
#0 lore raw

Dear Linux Developers:

I've noticed discrepancy in the number of processes returned by sysinfo() syscall versus the number of processes listed by 'ps'. The problem traced down to the following line of code in kernel/info.c:

val.proc = nr_task-1;

as if the idle task is taken into account in 'nr_tasks', However, since kernel 2.2 the comment to (and the usage of) 'nr_task' explicitly states that the idle task is not anymore counted in this variable. From kernel/fork.c:

/* The idle tasks do not count.. */
int nr_tasks = 0;

As a matter of fact, prior to kernel 2.2 the initial value of 'nr_tasks' was 1, and the idle task 0 was counted, so the correction by -1 was really necessary. But it was forgotten to undo this subtraction when the 'nr_tasks' had changed its meaning since then.

Best regards,

Anton Lavrentiev
NCBI/NLM/NIH