Operating System - OpenVMS
1748169 Members
4062 Online
108758 Solutions
New Discussion юеВ

Re: how can i get all process names and topcpu using c?

 
likuair_1
Advisor

how can i get all process names and topcpu using c?

i just know how to use sys$getjpi or lib$getjpi when i know the process names,but i wanted to get all the running process in the system ,how can i do it using c language?
11 REPLIES 11
Kris Clippeleyr
Honored Contributor

Re: how can i get all process names and topcpu using c?

Hi,
You don't need the process names in order to obtain various info.
Have a look at the system services $PROCESS_SCAN and $GETJPI in the System Services Reference Manual at:
http://h71000.www7.hp.com/doc/83final/4527/4527pro.html
However, you need to be priv'ed to obtain info about processes not running under your UIC.
Regards,
Kris (aka Qkcl)
I'm gonna hit the highway like a battering ram on a silver-black phantom bike...
Kris Clippeleyr
Honored Contributor

Re: how can i get all process names and topcpu using c?

Hi,
I forgot...
If you're really adventurous have a look at QJPI at
http://www.quadratrix.be/qjpi.html
Regards,
Kris (aka Qkcl)
I'm gonna hit the highway like a battering ram on a silver-black phantom bike...
Jess Goodman
Esteemed Contributor

Re: how can i get all process names and topcpu using c?

$ HELP SYSTEM_SERVICE $GETJPI

Arguments

pidadr

OpenVMS usage:process_id
type: longword (unsigned)
access: modify
mechanism: by 32- or 64-bit reference (Alpha)
mechanism: by 32-bit reference (VAX)

If you give pidadr the value -1, $GETJPI assumes a wildcard
operation and returns the requested information for each process
on the system that it has the privilege to access, one process
per call. To perform a wildcard operation, you must call $GETJPI
in a loop, testing for the condition value SS$_NOMOREPROC after
each call and exiting from the loop when SS$_NOMOREPROC is
returned.



I have one, but it's personal.
likuair_1
Advisor

Re: how can i get all process names and topcpu using c?

hello,Mr.Jess Goodman:
i can not set the pdiadr to -1 just because it's unsigned ,how can i do this?
likuair_1
Advisor

Re: how can i get all process names and topcpu using c?

sorry,i have noticed my error,thank you!
Hein van den Heuvel
Honored Contributor

Re: how can i get all process names and topcpu using c?

>> sorry,i have noticed my error,thank you!

Not your error! Sloppy parameter / dscription. It clearly indicates 'unsigned' and then tells you to put a -1 in there. Oh well.

Anyway... now that you figured it out, attached a ditty program to do a 'show process' with CSV output and CPU time columns for USER, EXEC and KERNEL.

Hein.

Hein van den Heuvel
Honored Contributor

Re: how can i get all process names and topcpu using c?

The attachment did not stick. Trying again. Hein.
Ian Miller.
Honored Contributor

Re: how can i get all process names and topcpu using c?

Note that more extensive statistics cane be obtained using SYS$GETRMI
____________________
Purely Personal Opinion
likuair_1
Advisor

Re: how can i get all process names and topcpu using c?

hello,Mr.Hein van den Heuvel:

I just download your codes and test it,
the following is the output :

"IOMASTER",13105,1,26,386,360,569,00000C18,8,$1$DGA1:[BKMASIC.][DATA.MASIC1.RELEASE]IOMASTER.EXE;26

here we can see that the kernel time is 13105,and EXECTIME is 1,and usertime is 26,but i wanted to get the cpu using percent of the system just like using
$MONITOR PROCESS/TOPCPU
00000C18 IOMASTER 20 ,
how can i do this?