In Beginning Linux Programming (Second Edition) we cover the basics of
querying and setting limits on the amount of resources a single process
can consume. [Chapter 4, BLP2e].
The library call getrusage returns a structure with members that contain
(among other things) the amount of CPU time used so far (both user and
system). These two fields are the only ones specified by the UNIX
specification (SPEC 1170) and are the only ones we mention in BLP2e.
However, Linux has extended this structure to include some other
information, such as the maximum resident set size (the RSS field you get
in "top"). The field is long int ru_maxrss and is measured in kilobytes.
Take a look at the manual page for getrusage for more details on other
resource information such as stack usage.
Regards
Neil Matthew