Re: Number of threads per process (pstat) (764 Views)
Reply
Regular Advisor
amit mehta_2
Posts: 119
Registered: ‎07-05-2006
Message 1 of 4 (764 Views)
Accepted Solution

No of threads per process

Hi,

While trying to figure out no of threads per process on HP-UX(In case of linux, i think the Threads field of /proc//status will do),i found this (attached here)small utility(written in C) which finds the no of threads per process.

This is working fine on a HP-UX 11.31 machine(IA) but not on hp-ux 11.23 machine(IA).

Snip for both the OS(11.31 and 11.23):
--------------------------------------
On 11.31 IA machine:

[root@hpia5][/]uname -a
HP-UX hpia5 B.11.31 U ia64 1278630092 unlimited-user license
[root@hpia5][/]model
ia64 hp server rx2620
[root@hpia5][/]cc -o threads_per_process threads_list.c
[root@hpia5][/]./threads_per_process |head


------------------------------------------------------------------------------
PID | UID |Threads| RSS | Command
------------------------------------------------------------------------------
0 | 0 | 1 | 16 | swapper
1 | 0 | 2 | 164 | init
11 | 0 | 12 | 192 | ObjectThreadPool
10 | 0 | 1 | 16 | ttisr
9 | 0 | 3 | 48 | ksyncer_daemon


On 11.23 IA machine:
root@hpia7/ >uname -a
HP-UX hpia7 B.11.23 U ia64 0785257145 unlimited-user license
root@hpia7/ >model
ia64 hp server rx2620
root@hpia7/ >./threads_per_process |head
pstat_getproc failed: Value too large to be stored in data type


------------------------------------------------------------------------------
PID | UID |Threads| RSS | Command
------------------------------------------------------------------------------
0 | 0 | 1 | 16 | swapper
0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 |



more info here: http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=060818f70...

I am not much of programmer,but would definitely like to port this program to work
on HP-UX 11.23 as well,Or if there is another
full proof method to determine this(No of threads per process)then please let me know.

Regards,
~amit
Honored Contributor
Don Morris_1
Posts: 797
Registered: ‎05-08-2001
Message 2 of 4 (764 Views)

Re: No of threads per process

One of two things come to mind.

Either you are:

a) Compiling on 11.31 and attempting to run the binary on 11.23.

or

b) Not using -D_PSTAT64 in compilation.

I lean towards (a) since it looks like the 11.23 kernel is complaining about the size of the data structure in the pstat_getproc() call [and since pstat structures usually get new fields between releases (at the end for compatibility) that fits... the 11.31 structure is larger than the 11.23 kernel expects].

Compile the program on 11.23, and use the -D_PSTAT64 (since it doesn't work right otherwise from what I can tell) if you compile DD32.. or just compile DD64.

Here's my result on a r11.23 box:
# uname -a
HP-UX unknown B.11.23 U ia64 2456779667 unlimited-user license

# cc +DD32 -D_PSTAT64 -o tpp tpp.c

# ./tpp |more


------------------------------------------------------------------------------
PID | UID |Threads| RSS | Command
------------------------------------------------------------------------------
0 | 0 | 1 | 16 | swapper
1 | 0 | 2 | 153 | init
8 | 0 | 2 | 32 | kmemdaemon
9 | 0 | 2 | 80 | ioconfigd
10 | 0 | 12 | 192 | ObjectThreadPool

Regular Advisor
amit mehta_2
Posts: 119
Registered: ‎07-05-2006
Message 3 of 4 (764 Views)

Re: No of threads per process

Hi Morris,

Thanks a lot.After compiling with
cc +DD32 -D_PSTAT64 option,it is working now.

Excerpt from the man page of cc :


On my system there wasn't MAN pages for cc,but those available here(link below) has
no info on "D_PSTAT64".

http://devrsrc1.external.hp.com/STKS/cgi-bin/man2html?debug=0&manpage=/opt/ansic/share/man/man1.Z/cc...

Also can you share some insight on hp-ux internals, poritng, hp-ux development to novice like me who aspire to involve in hp-ux development.

Thanks a lot again,Points to follow :)

~amit
Acclaimed Contributor
Dennis Handly
Posts: 25,291
Registered: ‎03-06-2006
Message 4 of 4 (764 Views)

Re: Number of threads per process (pstat)

[ Edited ]

>On my system there wasn't MAN pages for cc

If you have purchased the C/aC++ developer's bundle you should have the man page. If you have the bundled C compiler, you are out of luck. You can look at the aC++ Online Help here:

http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/HTML/index.htm
For more info on the aC++ compiler see:
http://www.hp.com/go/cpp

Why would you expect this with cc(1), see pstat(2):

c03231920.pdf 11.31 Man pages

http://h20566.www2.hp.com/portal/site/hpsc/template.BINARYPORTLET/public/kb/docDisplay/resource.proc...

and "Programming Model Considerations" for -D_PSTAT64.

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.