blob: d02cd1bfd9580c928fb5576ff469df727fb41ab2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
$NetBSD: patch-ab,v 1.3 2007/04/12 09:55:13 martti Exp $
--- panel-plugin/os.c.orig 2004-07-24 17:25:15.000000000 +0000
+++ panel-plugin/os.c 2007-01-23 15:51:04.000000000 +0000
@@ -67,6 +67,26 @@
return usage;
}
+#elif defined(__DragonFly__)
+long GetCPUUsage (int *oldusage, int *oldtotal)
+{
+ long used, total, usage;
+ struct kinfo_cputime cp_time;
+
+ if (kinfo_get_sched_cputime(&cp_time) < 0) {
+ g_warning("kinfo_get_sched_cputime failed");
+ return 0;
+ }
+ used = cp_time.cp_user + cp_time.cp_nice + cp_time.cp_sys;
+ total = used + cp_time.cp_idle;
+ if (total != *oldtotal)
+ usage = 100 * (used - *oldusage + used / 2 - *oldusage / 2) / (total - *oldtotal);
+ else
+ usage = 0;
+ *oldusage = used;
+ *oldtotal = total;
+ return usage;
+}
#elif defined (__NetBSD__)
long GetCPUUsage (int *oldusage, int *oldtotal)
{
|