Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

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
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?
likuair_1
Advisor

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

i am using the system function to get system informations ,so i'm also testing sys$getsyi ,i know how to get the total memory of the system using SYI$_PHYSICALPAGES,but i wanted to get total free pages,in use pages just like
$show memory,can you help me?
Hein van den Heuvel
Honored Contributor

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

likuair,

YOU can do this.

Check out the GETJPI call in the example.
Read it twice.
The GETSYI call is very much similar.
Read up! In the manuals, or: $ help system $GETSYI


As for the 20%.... 20% of what?
A single CPU? All cpu usage?
Since beginning of time? For an iteration?

YOU can do this. If you can not, then IMHO you have no business even asking the first question.
YOU can solve this in the program, or outside in EXCEL.
You'll just need 2 (or more) measurement in a loop. Take that CPU time (in centi-seconds) subtract the prior value, multiply by 100 and divide by the centiseconds between measurements.

IF you can not handle that, call LIB$SPAWN ("SHOW SYSTEM") or similar.

btw... For mere money I'll gladly hold your hand, or do this for you.

Enjoy!
Hein