Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can a usage counter in Solaris 10 /proc filesystem decrease?
    text
    copied!<p>I'm trying to determine the CPU utilization of specific LWPs in specific processes in Solaris 10 using data from the /proc filesystem. The problem I have is that sometimes a utilization counter <em>decreases</em>.</p> <p>Here's the gist of it:</p> <pre><code>// we'll be reading from the file named /proc/&lt;pid&gt;/lwp/&lt;lwpid&gt;/lwpusage std::stringstream filename; filename &lt;&lt; "/proc/" &lt;&lt; pid &lt;&lt; "/lwp/" &lt;&lt; lwpid &lt;&lt; "/lwpusage"; int fd = open(filename.str().c_str(), O_RDONLY); // error checking while(1) { prusage_t usage; ssize_t readResult = pread(usage_fd, &amp;usage, sizeof(prusage_t), 0); // error checking std::cout &lt;&lt; "sec=" &lt;&lt; usage.pr_stime.tv_sec &lt;&lt; "nsec=" &lt;&lt; usage.pr_stime.tv_nsec &lt;&lt; std::endl; // wait } close(fd); </code></pre> <p>The number of nanoseconds reported in the prusage_t struct are derived from timestamps recorded each time an LWP changes state. This feature is called <a href="http://blogs.oracle.com/eschrock/entry/microstate_accounting_in_solaris_10" rel="nofollow noreferrer">microstate accounting</a>. Sounds good, but every so often the "system call cpu time" counter <em>decreases</em> roughly 1-10 milliseconds.</p> <p>Update: its not just the "system call cpu time" counter, I've since seen other counters decreasing as well.</p> <p>Another curiosity is that it always seems to be exactly one sample that's bogus - never two near each other. All the <em>other</em> samples are monotonically increasing at the expected rate. This seems to rule out the possibility that the counter is somehow reset in the kernel. </p> <p>Any clues as to what's going on here?</p> <pre><code>&gt; uname -a SunOS cdc-build-sol10u7 5.10 Generic_139556-08 i86pc i386 i86pc </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload