summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2014-08-29 21:21:40 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2014-08-29 21:21:40 +0000
commitcf6e48c4bb6bbfcdbf8906a0127b0ce48b22d2b7 (patch)
tree14d0a8c0d6e5f34e0f23b0359a9139d1f37b36e3
parentcf12f51d2b5f10f150d699c2b913d639f0773a0b (diff)
Use the load average from averunnable.ldavg[] instead of bogus cp_time[]
arithmetic to display the load average in leds 5-8 of 8 led systems.
-rw-r--r--sys/arch/hppa/hppa/autoconf.c22
-rw-r--r--sys/arch/hppa64/hppa64/autoconf.c22
2 files changed, 16 insertions, 28 deletions
diff --git a/sys/arch/hppa/hppa/autoconf.c b/sys/arch/hppa/hppa/autoconf.c
index d0e6fdd6928..5360a6a0f4e 100644
--- a/sys/arch/hppa/hppa/autoconf.c
+++ b/sys/arch/hppa/hppa/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.58 2014/05/08 21:32:45 miod Exp $ */
+/* $OpenBSD: autoconf.c,v 1.59 2014/08/29 21:21:39 miod Exp $ */
/*
* Copyright (c) 1998-2003 Michael Shalayeff
@@ -107,22 +107,16 @@ void
heartbeat(v)
void *v;
{
- static u_int hbcnt = 0, ocp_total, ocp_idle;
- int toggle, cp_mask, cp_total, cp_idle;
+ static u_int hbcnt = 0;
+ int toggle, cp_mask;
timeout_add(&heartbeat_tmo, hz / 16);
- cp_idle = cp_time[CP_IDLE];
- cp_total = cp_time[CP_USER] + cp_time[CP_NICE] + cp_time[CP_SYS] +
- cp_time[CP_INTR] + cp_time[CP_IDLE];
- if (cp_total == ocp_total)
- cp_total = ocp_total + 1;
- if (cp_idle == ocp_idle)
- cp_idle = ocp_idle + 1;
- cp_mask = 0xf0 >> (cp_idle - ocp_idle) * 4 / (cp_total - ocp_total);
- cp_mask &= 0xf0;
- ocp_total = cp_total;
- ocp_idle = cp_idle;
+ /* display the load average in the upper leds if any */
+ cp_mask = averunnable.ldavg[0] >> FSHIFT;
+ if (cp_mask > 0x0f)
+ cp_mask = 0x0f;
+ cp_mask <<= 4;
/*
* do this:
*
diff --git a/sys/arch/hppa64/hppa64/autoconf.c b/sys/arch/hppa64/hppa64/autoconf.c
index 57cb571e8ac..5b56334791d 100644
--- a/sys/arch/hppa64/hppa64/autoconf.c
+++ b/sys/arch/hppa64/hppa64/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.18 2014/07/12 18:44:41 tedu Exp $ */
+/* $OpenBSD: autoconf.c,v 1.19 2014/08/29 21:21:39 miod Exp $ */
/*
* Copyright (c) 1998-2005 Michael Shalayeff
@@ -148,22 +148,16 @@ diskconf(void)
void
heartbeat(void *v)
{
- static u_int hbcnt = 0, ocp_total, ocp_idle;
- int toggle, cp_mask, cp_total, cp_idle;
+ static u_int hbcnt = 0;
+ int toggle, cp_mask;
timeout_add(&heartbeat_tmo, hz / 16);
- cp_idle = cp_time[CP_IDLE];
- cp_total = cp_time[CP_USER] + cp_time[CP_NICE] + cp_time[CP_SYS] +
- cp_time[CP_INTR] + cp_time[CP_IDLE];
- if (cp_total == ocp_total)
- cp_total = ocp_total + 1;
- if (cp_idle == ocp_idle)
- cp_idle = ocp_idle + 1;
- cp_mask = 0xf0 >> (cp_idle - ocp_idle) * 4 / (cp_total - ocp_total);
- cp_mask &= 0xf0;
- ocp_total = cp_total;
- ocp_idle = cp_idle;
+ /* display the load average in the upper leds if any */
+ cp_mask = averunnable.ldavg[0] >> FSHIFT;
+ if (cp_mask > 0x0f)
+ cp_mask = 0x0f;
+ cp_mask <<= 4;
/*
* do this:
*