resource_usage


The kernel tracks the resource usage of each process, including the amount of CPU time used, and the number of signals received. A resource usage object is read-only, and can be queried for individual resource values.

To receive a resource object containing its resource statistics, use os_this_process::usage() . To obtain resource statistics for the terminated child processes of the current process, use os_this_process::usage_for_terminated_children() .

An operator rusage() exists so that an os_resource_usage can be used whenever a struct rusage is expected.

Library

Platform<ToolKit> for UNIX

Declaration

#include <ospace/unix/rscusage.h>

class os_resource_usage

Interface

Constructor
os_resource_usage()
Constructs an object that is empty.
Constructor
os_resource_usage( const rusage& usage )
Constructs an object from usage .
Constructor
os_resource_usage( const os_resource_usage& usage )
Constructs an object that is a copy of usage .
=
os_resource_usage& operator=( const os_resource_usage& usage )
Assigns an object from usage .
=
os_resource_usage& operator=( const rusage& usage )
Assigns an object from usage .
==
bool operator== ( const os_resource_usage& usage ) const
Returns true if the object is the same as usage .
(rusage)
operator rusage() const
Returns an object as an rusage structure.
average_resident_set_bytes
int average_resident_set_bytes() const
Returns the average resident set size in bytes. This is the average physical memory use and does not take sharing into account. Note that on SUN platforms this is an approximation and can misrepresent the true resident set size.
average_resident_set_pages
int average_resident_set_pages() const
Returns the average resident set size in pages. This is the average physical memory use and does not take sharing into account. Note that on SUN platforms this is an approximation and can misrepresent the true resident set size.
forced_context_switches
int forced_context_switches() const
Returns the number of times a context switch occurred either as a result of a higher priority process entering a run state or because the time slice of the process was completed.
input_blocks
int input_blocks() const
Returns the number of times the program blocked (waited on the system) for input servicing of a read request.
io_page_faults
int io_page_faults() const
Returns the number of page faults that required physical I/O activity. These page faults commonly occur when a program references a page that is not in memory. This type of page fault is also associated with many user I/O requests.
max_resident_set_bytes
int max_resident_set_bytes() const
Returns the maximum byte count in the resident set. This byte count is the maximum amount of physical memory consumed. Note that on SUN platforms this is an approximation and can misrepresent the true resident set size.
max_resident_set_pages
int max_resident_set_pages() const
Returns the maximum pages in the resident set. This is the maximum amount of physical memory consumed. Note that on SUN platforms this is an approximation and can misrepresent the true resident set size.
non_io_page_faults
int non_io_page_faults() const
Returns the number of page faults serviced that did not require physical I/O activity. These minor page faults can occur when reclaiming memory from the heap, during startup when first referencing a shared library, and so forth.
output_blocks
int output_blocks() const
Returns the number of times the program blocked (waited on the system) for output servicing of a write request.
print
void print( ostream& stream ) const
Prints attributes to stream .
received_messages
int received_messages() const
Returns the number of messages received from sockets.
received_signals
int received_signals() const
Returns the number of signals received by the process. On current SUN implementations this does not include SIGSTOP (suspend), and SIGCONT (resume) signals.
sent_messages
int sent_messages() const
Returns the number of messages sent over sockets.
swaps
int swaps() const
Returns the number of times the process was swapped out of main memory.
system_time
os_time_period system_time() const
Returns the total time spent executing in system mode. The time returned for system usage is only accurate to the second.
user_time
os_time_period user_time() const
Returns the total time spent executing in user mode. The time returned for user usage is only accurate to the second.
voluntary_context_switches
int voluntary_context_switches() const
Returns the number of times a context switch occurred because the process voluntarily gave up its time slice prior to completion. A context switch is the transfer of CPU control from one user's program to another. This type of context switch usually results when the user is waiting for a resource, such as during I/O requests. A large portion of UNIX systems calls result in voluntary context switching.

Non-Member Functions

<<
ostream& operator<<( ostream& stream , const os_resource_usage& usage )
Prints usage to stream .

Universal Streaming Service

#include <ospace/uss/unix.h>
<<
os_bstream& operator<<( os_bstream& stream , const os_resource_usage& usage )
Writes usage to stream .
>>
os_bstream& operator>>( os_bstream& stream , os_resource_usage& usage )
Reads usage from stream .

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only. - For use by licensed users only.