perfstat_thread Subroutine
Purpose
Retrieves kernel thread utilization metrics.
Library
Perfstat Library (libperfstat.a)
Syntax
#include <libperfstat.h>
int perfstat_thread (name,userbuff,sizeof_userbuff,desired_number)
perfstat_id_t* name;
perfstat_thread_t* userbuff;
int sizeof_userbuff;
int desired_number;
Description
The perfstat_thread subroutine is used to retrieve per kernel thread utilization metrics for a process or for all the processes. The perfstat_thread subroutine retrieves one or more kernel thread statistics to populate the perfstat_thread_t data structure.
If the name and userbuff parameters are set as NULL, and the desired_number parameter is set to 0, the perfstat_thread subroutine returns the number of active threads.
If the name and userbuff parameters are set to NULL, and the sizeof_userbuff parameter is set to 0, the size of the current version of the perfstat_thread_t data structure is returned.
Parameters
Item | Description |
---|---|
name | Determines whether the kernel thread statistics must be captured
for all the processes or captured for a specific process. The name parameter,
must be set to NULL to get the kernel thread statistics for all processes.
To get the kernel thread statistics for a specific process, the process
ID must be specified. Note: The value of the ID must be passed as
a string to the name parameter. For example, to retrieve the
statistics for a process that has the process ID 12345, the name parameter
must be set to 12345.
|
userbuff | Points to the memory area that is filled with one or more perfstat_thread_t data structures. |
sizeof_userbuff | Specifies the size of the perfstat_thread_t data structure. Note: To
obtain the size of the latest version of the perfstat_thread_t data
structure, set the sizeof_userbuff parameter to 0, and the name and userbuff parameter
to NULL.
|
desired_number | Specifies the number of perfstat_thread_t data structures to copy to the userbuff parameter. |
Return Values
Unless the perfstat_thread subroutine is used to retrieve the number of available structures, the number of structures that are filled is returned upon successful completion. If unsuccessful, a value of -1 is returned and the errno global variable is set.
Error Codes
The subroutine is unsuccessful if the following is true:
Item | Description |
---|---|
EINVAL | One of the parameters is not valid. |
Files
The libperfstat.h file defines standard macros, data types, and subroutines.