On 8/27/2024 11:31 AM, Jon Turney via Cygwin wrote:
On 27/08/2024 09:21, Mark Liam Brown via Cygwin wrote:
Greetings!

/usr/bin/uptime always reports 0/0/0 average cpu load:
$ uptime
  10:09:01 up 15:59,  0 user,  load average: 0.00, 0.00, 0.00

is this a known bug?

Kind of.

Due to windows API limitations, the current implementation has the short-coming that a process's first call to getloadavg() does not update the globally-maintained loadavg data.

(Because the Windows API cannot provide instantaneous cpu load, only over the 
period between two calls)

(So e.g. if you run something like top in another terminal, you'll suddenly see 
uptime return more sensible values)

See the discussion [1] for more context, and discussion of various approaches to fixing this, which petered out without a patch to [2]...

[1] https://cygwin.com/pipermail/cygwin-developers/2022-May/012569.html
[2] https://cygwin.com/cgit/newlib-cygwin/tree/winsup/cygwin/loadavg.cc

Thank you for the explanation, Mark!

I see that /proc/loadavg appears to get updated.  If one wants the information,
is that a more reliable source than calling uptime for load averages?

Best - Eliot


--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to