-   AIX (
-   -   getprocs() does not give the process information correctly (

anubhuti_k 05-27-2006 07:55 AM

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.

Michael AM 05-27-2006 09:07 AM

The AIX 5.2 manual page is:

Note in the include file the following note:

 * 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.

anubhuti_k 05-27-2006 10:13 AM

Hi Michael,

Thanx a lot for ur prompt reply.

I made this small program :

#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());
fprintf(stderr,"Pi_size = %d\n",ProcessBuffer->pi_size);

fprintf(stderr,"Pi_size = %d\n",ProcessBuffer->pi_size);

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 :
a03e f work shared library data 11 0 0 7 0..2499
6026 2 work process private 7 1 0 7 0..0 :
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,

Michael AM 05-28-2006 04:38 PM

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.

All times are GMT -5. The time now is 02:25 AM.