here's one way of reading free mem of the system (or at least a start):


http://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/p/procmgr_value_notify_add.html


you can also follow this guide to get mapping information and then sum it up:

http://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.cookbook/topic/s3_procfs_DCMD_PROC_MAPINFO.html


Note though that esp DCMD_PROC_PAGEDATA is *very* expensive, you don't want to run that often.


regards

-- Michael



From: Albrecht Uhlmann <community-noreply@qnx.com>
Sent: Thursday, February 2, 2023 15:08
To: ostech-core_os
Subject: Re: Programmatically read CPU load and RAM usage
 
Hi Michael,
for total RAM usage, there is a simple command, I think you need to do a stat on /proc and read the filesize member. The knowledge base contains sample code: https://www.qnx.com/support/knowledgebase.html?id=50130000000nbHX

As to CPU load, I am very much interested myself but I do not know a solution. My idea was to open process #1 and use the devctl's to query its individual threads. Threads #1...through to #cpus are the idle threads (one per core), so getting their time must be "Idle time per core". The CPU time of all other threads in procnto I guess is what would be called "Kernel Time". And the remaining time (per core) is user time.
What I do not know is interrupt time.

Any of the QNX gurus comment on this?

Regards,
-Al



_______________________________________________

OSTech
http://community.qnx.com/sf/go/post122126
To cancel your subscription to this discussion, please e-mail ostech-core_os-unsubscribe@community.qnx.com