Allows kernel extensions to measure the resource utilization of transactions.
#include <sys/types.h>
#include <sys/aacct.h>
unsigned long long acct_get_usage(usage)
struct tusage *usage;
Item | Description |
---|---|
usage | Resource utilization structure. |
This routine is used to measure the resource utilization of a client transaction, so that the cost of the transaction can be included within the accounting record that identifies the client transaction. This accounting record is then used for chargeback purposes.
The acct_get_usage kernel service is designed to be called twice: once at the start of a transaction and a second time at the end of a transaction. Each time that the routine is called, it returns the resource utilization for the calling thread from creation using the usage parameter. Therefore, this routine can be called multiple times to determine the resource utilization of a code fragment by subtracting start and end values.
The usage parameter provides thread-specific information, so the caller must ensure that this routine is called from the same thread context when measuring the utilization of a transaction. The return value identifies the calling thread context.
The acct_get_usage kernel service returns a token that identifies the calling context. This token can be logically compared with other tokens returned by this routine to ensure that start and stop invocations were made from the same thread. The scope of the token depends on the context of the calling program. If this routine is called under a pthread, then it returns a token representing the currently executing pthread. Otherwise, the acct_get_usage kernel service returns a token representing the currently executing kernel thread. In the former case, the token has process-wide scope; in the latter case, the token has system-wide scope.
The acct_get_usage kernel service can only be called from the process environment.
Upon successful completion, the acct_get_usage kernel service returns a token that identifies the calling thread context.