LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices

Reply
 
Search this Thread
Old 05-27-2006, 07:55 AM   #1
anubhuti_k
LQ Newbie
 
Registered: Oct 2004
Location: India
Distribution: Suse 9.1
Posts: 29

Rep: Reputation: 15
getprocs() does not give the process information correctly


Hi all,

In Aix i'm using getprocs() to get the detailed information about the process.

what does pi_size, a member of struct procsinfo represent? In
/usr/include/procinfo.h, it is mentioned as "long long pi_size;
/* size of image (pages) */"

what is meaning of image (is it a process image size or heap size of the process). If it is not representing the heap memory, how do i get the actual heap size of a process.
Note:I've also seen noticed that pi_tsize is representing size of text.
Can anybody explain me, what is the meaning of fields in the above mentioned structure & way to get the heap size.

Thanks in advance.
 
Old 05-27-2006, 09:07 AM   #2
Michael AM
Member
 
Registered: May 2006
Distribution: AIX 5.3, AIX 6.1, AIX 7.1
Posts: 95

Rep: Reputation: 23
The AIX 5.2 manual page is:
http://publib16.boulder.ibm.com/doc_...1/getprocs.htm

Note in the include file the following note:
Code:
/*
 * Warning: the procinfo, userinfo, and uicredinfo structures represent
 * obsolete interfaces.  These would not compile correctly in 64-bit mode.
 */
#ifndef __64BIT__
struct  procinfo
{
    /* identification/authentication */
    unsigned long   pi_pid;     /* process ID */
    unsigned long   pi_ppid;    /* parent process ID */
    unsigned long   pi_sid;     /* session identifier */
    unsigned long   pi_pgrp;    /* process group */
    unsigned long   pi_uid;     /* real user ID */
    unsigned long   pi_suid;    /* saved user ID */

    /* scheduler information */
    unsigned long   pi_pri;     /* priority, 0 high, 31 low */
    unsigned long   pi_nice;    /* nice for priority, 0 to 39 */
    unsigned long   pi_cpu;     /* processor usage, 0 to 80 */

    /* process states are defined in <sys/proc.h>: */
    unsigned long   pi_stat;    /* process state */

    /* process flags are defined in <sys/proc.h>: */
    unsigned long   pi_flag;

    /* dispatcher fields */
    char        *pi_wchan;  /* wait channel */
    unsigned long   pi_wtype;   /* the wait type */

    /* miscellaneous */
    unsigned long   pi_adspace; /* process address space */
    unsigned long   pi_majflt;  /* i/o page faults   */
    unsigned long   pi_minflt;  /* non i/o page faults   */

    /* valid when the process is a zombie only */
    unsigned long   pi_utime;   /* this process user time */
    unsigned long   pi_stime;   /* this process system time */

    /* process statistics */
    unsigned long   pi_size;    /* size of image (pages) */
};
Page Size in AIX is 4096 bytes. So my best guess atm, is that your image size in bytes is this number * 4096.

Compare this number with output from svmon (which also reports in 'page sizes' and with ps. Note that ps reports in units of 1K.

And then you can determine whther it is heap, text, data, etc.

I expect it is ALL segments totaled. Again, this is easy to compare with output from svmon.
 
Old 05-27-2006, 10:13 AM   #3
anubhuti_k
LQ Newbie
 
Registered: Oct 2004
Location: India
Distribution: Suse 9.1
Posts: 29

Original Poster
Rep: Reputation: 15
Hi Michael,

Thanx a lot for ur prompt reply.

I made this small program :

#include<stdio.h>
#include <procinfo.h>
#include <sys/types.h>

int main()
{
struct procsinfo *ProcessBuffer;
int ProcessSize;
struct fdsinfo *FileBuffer;
int FileSize;
pid_t IndexPointer;
int Count;
ProcessSize = sizeof(struct procsinfo);
ProcessBuffer = (struct procsinfo*)malloc(sizeof(struct procsinfo));
IndexPointer = getpid();
Count = 1;
fprintf(stderr,"pid = %d\n",getpid());
getprocs(ProcessBuffer,ProcessSize,FileBuffer,FileSize,&IndexPointer,Count);
fprintf(stderr,"Pi_size = %d\n",ProcessBuffer->pi_size);
sleep(10);

getprocs(ProcessBuffer,ProcessSize,FileBuffer,FileSize,&IndexPointer,Count);
fprintf(stderr,"Pi_size = %d\n",ProcessBuffer->pi_size);
sleep(10);

getprocs(ProcessBuffer,ProcessSize,FileBuffer,FileSize,&IndexPointer,Count);
fprintf(stderr,"Pi_size = %d\n",ProcessBuffer->pi_size);
}

The output of this program isnt in agreement with svmon output from any angle.

Output I
# ./psize
pid = 37428
Pi_size = 14
Pi_size = 455
Pi_size = 201

svmon output:

# svmon -P 37428

-------------------------------------------------------------------------------
Pid Command Inuse Pin Pgsp Virtual 64-bit Mthrd
34414 psize 9919 2826 1772 7985 N N

Vsid Esid Type Description Inuse Pin Pgsp Virtual Addr Range
a815 d work shared library text 6617 0 69 2787 0..65535
0 0 work kernel seg 3282 2825 1703 5184 0..23321 :
65474..65535
a03e f work shared library data 11 0 0 7 0..2499
6026 2 work process private 7 1 0 7 0..0 :
65313..65535
b8fe 1 pers code,/dev/hd1:67591 2 0 - - 0..1

and interestingly, as we can see that from program, pi_size changes after every sleep(). But svmon still gives same output after every sleep().

Any ideas for the reason of this peculiar behavious.
Thanks again,
Anubhuti
 
Old 05-28-2006, 04:38 PM   #4
Michael AM
Member
 
Registered: May 2006
Distribution: AIX 5.3, AIX 6.1, AIX 7.1
Posts: 95

Rep: Reputation: 23
I'll try some experiments this week.

p.s. I am assuming you are running this on a 32-bit kernel.

p.p.s. I would double check the printf format string. It may be the %d should be %ld, or something like that. I always need to look it up myself.

Last edited by Michael AM; 05-28-2006 at 04:41 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what information does lsmod give? lnthai2002 Linux - Hardware 2 01-13-2006 11:08 AM
How to get the current process information balasquare@yahoo.com Programming 4 09-29-2005 04:39 AM
How to use task_struct to get process information?? Pratik H Pandya Programming 2 09-15-2005 03:40 AM
get information when a process run?????? hungnt Linux - Newbie 6 07-16-2005 10:57 AM
Plz give me some information on proxy server (squid) vyom Linux - Networking 8 03-31-2005 06:57 AM


All times are GMT -5. The time now is 08:03 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration