> Akhil Jain writes:
>> As soon as i restart my process all variables get deleted and now i need
>> the kernel stats from the time i started my process.But when using kstat
>> it will give me the stats from the time kernel has rebooted.So that's
>> why i was asking for such a mechanism to reset the kernel stats.So can
>> we have any workaround for such a scenario?
>
> Read the kstat variables of interest as soon as your process starts,
> and use that as the 'zero' reference point.  Subtract to get the delta
> since program start.
>

Also, you may find great value in using the Solaris hi-resolution timer.

Please see http://www.blastwave.org/man/gethrtime_3C.html

With special attention to the NOTE :

NOTES
     Although the units  of  hi-res  time  are  always  the  same
     (nanoseconds),  the actual resolution is hardware dependent.
     Hi-res time is guaranteed to be monotonic (it won't go back-
     ward, it won't periodically wrap) and linear (it won't occa-
     sionally speed up or slow down for adjustment, like the time
     of  day  can),  but not necessarily unique: two sufficiently
     proximate calls may return the same value.

So that allows the user to fetch a very accurate and linear timestamp
before doing anything and then using that as the base zero for other
calculations. Using the wallclock time *may* not be ideal because, as the
note suggests, it can slew faster or slower and things like ntpd can play
a role there also. When in doubt use gethrtime and then the user has
really nice dependable data.

But good luck getting two calls within a nanosecond of each other ... I
have tried that one ( just for fun ) and could never get below 25
nanosecs. I often wonder just how accurate and fine grained that hires
timer is .. but that is another ( fun ) discussion.

Dennis

_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to