Gets kernel thread table entries.
#include <procinfo.h> #include <sys/types.h>
int getthrds (ProcessIdentifier, ThreadBuffer, ThreadSize, IndexPointer, Count) pid_t ProcessIdentifier; struct thrdsinfo *ThreadBuffer; or struct thrdsinfo64 *ThreadBuffer; int ThreadSize; tid_t *IndexPointer; int Count;
The getthrds subroutine returns information about kernel threads, including kernel thread table information defined by the thrdsinfo or thrdsinfo64 structure.
The getthrds subroutine retrieves up to Count kernel thread table entries, starting with the entry corresponding to the thread identifier indicated by IndexPointer, and places them in the array of thrdsinfo or thrdsinfo64 structures indicated by the ThreadBuffer parameter.
On return, the kernel thread identifier referenced by IndexPointer is updated to indicate the next kernel thread table entry to be retrieved. The getthrds subroutine returns the number of kernel thread table entries retrieved.
If the ProcessIdentifier parameter indicates a process identifier, only kernel threads belonging to that process are considered. If this parameter is set to -1, all kernel threads are considered.
The getthrds subroutine is normally called repeatedly in a loop, starting with a kernel thread identifier of zero, and looping until the return value is less than Count, indicating that there are no more entries to retrieve.
When used in 32-bit mode, limits larger than can be represented in 32 bits are truncated to RLIM_INFINITY. Large values are truncated to INT_MAX. Alternatively, the struct thrdsinfo64 and sizeof (struct thrdsinfo64) can be used by 32-bit getthrds to return full 64-bit thread information. Note that the thrdsinfo64 structure not only inceases certain thrdsinfo fields from 32 to 64 bits, but that it contains additional information not present in thrdsinfo. The struct thrdsinfo64 contains the same data as struct thrdsinfo when compiled in a 64-bit program.
If successful, the getthrds subroutine returns the number of kernel thread table entries retrieved; if this is less than the number requested, the end of the kernel thread table has been reached. Otherwise, a value of -1 is returned, and the errno global variable is set to indicate the error.
The getthrds subroutine fails if the following are true:
This subroutine is part of the Base Operating System (BOS) Runtime.
The getpid, getpgrp, or getppid subroutines, the getprocs subroutine.
The ps command.