Operating System - HP-UX
1835257 Members
2407 Online
110078 Solutions
New Discussion

How to determine the number of processors?

 
Harri Pasanen
Occasional Advisor

How to determine the number of processors?

How can I determine the number of processors a machine has?

CPU count is useful info when implementing optimal threading algorithms.

On Solaris it the info is available through sysconf(), but apparently not on HP-UX 11.00.
9 REPLIES 9
Alex Glennie
Honored Contributor

Re: How to determine the number of processors?

top should tell you however to do this programatically the followinh should work ?

#include
main () {
struct pst_dynamic psd;
pstat_getdynamic(&psd, sizeof(struct pst_dynamic), 1, 0);
printf("Number of Active Processors: %d\n", psd.psd_proc_cnt);
}
Alex Glennie
Honored Contributor

Re: How to determine the number of processors?

This works too on my 11.xx & 10.20 systems :

echo "processor_count/D" | adb -k /stand/vmunix /dev/mem
Frederic Soriano
Honored Contributor

Re: How to determine the number of processors?

Hello Harri,

Besides the programmatical way, there is another possibility, via the command line; as root, issue the following command:

echo 'processor_count/D' | adb -k /stand/vmunix /dev/kmem | tail -1 | awk '{print $2}'

Regards.
federico_3
Honored Contributor

Re: How to determine the number of processors?

you could use:

#ioscan -fnkCprocessor | grep processor | wc -l

Also the top command could help you. type:
#top

and you will see the Cpu states with their number



Federico
CHRIS_ANORUO
Honored Contributor

Re: How to determine the number of processors?

You can also get the number with the following line command:
cat /var/adm/syslog/syslog.log|grep processor
or
cat /var/adm/syslog/syslog.log|grep processor|wc -l
or
dmesg|pg
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
Alan Riggs
Honored Contributor

Re: How to determine the number of processors?

Just for fun:

sar -M 1 1| tail +6|wc -l
CHRIS_ANORUO
Honored Contributor

Re: How to determine the number of processors?

To add to my previous contribution:
vi /var/tombstones/ts99 and look for the PA's. You will also see the firmware and others under the Revision table.
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
Jiri D
Advisor

Re: How to determine the number of processors?

Hi Harri

You can try this command:
ioscan -k | grep proc

Jiri


Harri Pasanen
Occasional Advisor

Re: How to determine the number of processors?

Thanks for the answers.
I wanted to do this programmatically, so the C code answer was what I was looking for. Should have given it 10 points, 6 was by accident.

Interactive answers were also useful, so I gave some points for those, more to those were you don't have to be root.
Some suggestions gave bogus answers, like 32 processors, (I wish).