dtrace_sleep() Function

The dtrace_sleep() function determines the minimum amount of time a consumer needs to pause before it interacts with the framework. This function has only one argument, the DTrace handle.

void dtrace_sleep(dtrace_hdl_t *dtp)

DTrace maintains three values that specify the rate at which a consumer needs to interact with the framework. These values also indicate whether the tracing continues or is stopped for some reason. The values that DTrace maintains are:

  • switchrate – Specifies how often the principal buffers must be consumed. Principal buffers are maintained as active and passive pairs per-CPU. These pairs can switch, which allows the data to be consumed from one while the new data is written to the other. The rate at which these buffers switch determines the switchrate.

  • statusrate – Specifies how often the consumer should check the DTrace status.

  • aggrate – Specifies how often the aggregation buffers are consumed. Aggregation buffers are not maintained as pairs in the same way as principal buffers. There is a single aggregation buffer per CPU. For more information about the buffer management mechanism, see DTrace Buffers and Buffering.

These three rates determine the amount of time that the dtrace_sleep() function must pause. The dtrace_sleep() function calculates the earliest time for it to wake up based on the last occurrence of these three events and their associated rates. If that earliest time is in the past, the dtrace_sleep() function returns, otherwise it sleeps until that time. If the wakeup time is in the past, the dtrace_sleep() function returns immediately, otherwise, it sleeps until the calculated wakeup time before returning.

You do not have to call the dtrace_sleep() function itself from a consumer. For example, neither intrstat or lockstat use the dtrace_sleep() function to control the rate of data consumption. You can use the dtrace_getopt() function to get the values of the appropriate rate and use timers based on those values. For more information, see the intrstat(8) and lockstat(8) man pages.