Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

A problem about top-3.5 on Tru64 UNIX
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);
......

Report this thread to moderator Post Follow-up to this message
Old Post
merzzong
03-22-08 12:19 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 02:27 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.