delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/08/29/17:56:51

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: Emil Briggs <emil AT baymountain DOT com>
Reply-To: emil AT baymountain DOT com
Organization: Baymountain, Inc.
To: cygwin AT cygwin DOT com
Subject: Processor time bug in fhandler_proc.cc
Date: Thu, 29 Aug 2002 17:56:37 -0400
MIME-Version: 1.0
Message-Id: <200208291756.37044.emil@baymountain.com>


I think there is a bug in fhandler_proc.cc in the way the results of
calls to

  NTSTATUS ret = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) &spt,
                                           sizeof spt, NULL);

are handled. Specifically the value of spt.IdleTime.QuadPart is already
included in spt.KernelTime.QuadPart but the code to compute the uptime
doesn't take that into account and adds in the idle time again as shown below.


      uptime = (spt.InterruptTime.QuadPart + spt.KernelTime.QuadPart +
                spt.IdleTime.QuadPart + spt.UserTime.QuadPart +
                spt.DpcTime.QuadPart) / 100000ULL;

Because the Idle time is already included in the KernelTime the computed
uptime is always too large. In the case of a lightly loaded system it's
about a factor of two and is easy to verify by just letting the system sit
for a while and then checking the reported value from /proc/uptime against 
wall clock time.

This also affects /proc/stat entry for CPU usage where you can see that
the system value is always larger than the idle value.

Regards
Emil


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019