For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > March 2008 > A problem about top-3.5 on Tru64 UNIX









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author A problem about top-3.5 on Tru64 UNIX
merzzong

2008-03-21, 7:19 pm

Hi,
I'm looking for the answers.

I compiled top-3.5 source on a Tru64 UNIX 5.1 (OSF1) machine
and executed it.
then, I've seen the Top process occupied 45Mb of memory.
It's too large!
On another Tru64 machine, only less than 1Mb.

I tried to search for reason of the overload
and found the overload happenes in the part
of getting process information.

In progress, first, Top requests the number of all processes
into "nproc". next, iterating for "nproc" times in a loop,
requests the information of each processes.
But, in the machine of the former, "nproc" value was
about 300,000.
When Top calls table(...) function for 300,000 times,
it's memory usage grows up seriously.
What is worse, sometimes Top occurs a fault and the process dies.
In the machine of the latter, "nproc" was less than 70,000.

When iterating the loop, it ignores the processes whose PID is zero.
Actually, it takes just about 130 processes.
"nproc" is too large as compared to the number of actual processes.
Why must it spend memory of 300,000 cases for getting just 130 cases?

Isn't there a way to act for need only?
I'm expecting valuable replies.

Below is a part of top-3.5 source getting process info.

.......
nproc = table(TBL_PROCINFO, 0, (struct tbl_procinfo *)NULL,
INT_MAX, 0);
for (j=0; j<nproc; j += 8)
{
r = table(TBL_PROCINFO, j, (struct tbl_procinfo *)p_i, 8,
sizeof(struct
tbl_procinfo));
for (k = 0; k < r; k++, pp++)
{
if(p_i[k].pi_pid == 0)
{
pp->p_pid = 0;
}
else
{
pp->p_pid = p_i[k].pi_pid;
pp->p_ruid = p_i[k].pi_ruid;
pp->p_flag = p_i[k].pi_flag;
pp->p_nice = getpriority(PRIO_PROCESS,p_i[k].pi_pid);
/* Load useful values into the proc structure */
do_threads_calculations(pp);
.......
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com