How to check by the kernel API a process memory usage ?


I am interesting in writing a simple C program like “sin”. I haven’t found any good kernel API functions for getting processes memory usage. Do you know how to do it ? (maybe you have some C-language examples) ?

Greetings and thanks for any replays,


Good C-language example you may find in qnx on-line CVS
Also, there was source code of ‘spin’ utility somewhere around. Google it up :slight_smile:


Not all functions available in the C library are documented, some are not even declared in the headers. Also some of the devctl()'s to work with the /proc filesystem can carry somewhat more data than the structures suggest. The migration tool from QNX4 to Neutrino (mig4nto), which is freely available for download, has some source codes in it that show you how to get that information. You may also try the Russian QNX site, they have done amazing things.

In that sense, “sin” and friends are NOT simple programs unless you know the tricks.


Since you used word “sin” I assume you are using qnx4.

You can get information about segments mapped into process using qnx_psinfo() system call.
Number of segments is stored in _psinfo.nselectors. Then you can iterate through all segments using qnx_psinfo() again but with different value in segindex argument.

Examine _seginfo.flags to determine whether the segment is shared or not.

The utility “sin” also shows size of ‘microkernel’, this information is available through qnx_osinfo() call in _osinfo.microkernel_size.

Hmmm that looks nice :slight_smile: Thanks guys :slight_smile: And maybe you also know how to get the information about amount of free system memory ?



qnx_osinfo() in freepmem (and in totpmem is total system memory)