diff options
author | Antoine Motet <antoine.motet@gmail.com> | 2018-12-16 09:25:54 +0100 |
---|---|---|
committer | Antoine Motet <antoine.motet@gmail.com> | 2018-12-16 11:30:06 +0100 |
commit | 9197adf57e04875fe7fd5b768bc5201d5def2548 (patch) | |
tree | 2e0e75e3fa09d68f7f03db6186871424874b525d /openbsd/Platform.h | |
parent | b7b4200f854f667a917b7da8f92b3e0426131bd7 (diff) |
Fix CPU usage on OpenBSD
The current OpenBSD-specific CPU usage code is broken. The `cpu`
parameter of `Platform_setCPUValues` is an integer in the interval
[0, cpuCount], not [0, cpuCount-1]: Actual CPUs are numbered from
1, the “zero” CPU is a “virtual” one which represents the average
of actual CPUs (I guess it’s inherited from Linux’s `/proc/stats`).
This off-by-one error leads to random crashes.
Moreover, the displayed CPU usage is more detailed with system,
user and nice times.
I made the OpenBSD CPU code more similar to the Linux CPU code,
removing a few old bits from OpenBSD’s top(1). I think it will be
easier to understand, maintain and evolve.
I’d love some feedback from experienced OpenBSD people.
Diffstat (limited to 'openbsd/Platform.h')
-rw-r--r-- | openbsd/Platform.h | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/openbsd/Platform.h b/openbsd/Platform.h index e0da7b9f..56e4c400 100644 --- a/openbsd/Platform.h +++ b/openbsd/Platform.h @@ -17,21 +17,6 @@ in the source distribution for its full text. extern ProcessFieldData Process_fields[]; -#define MAXCPU 256 -// XXX: probably should be a struct member -/* - * Copyright (c) 1984, 1989, William LeFebvre, Rice University - * Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University - * - * Taken directly from OpenBSD's top(1). - * - * percentages(cnt, out, new, old, diffs) - calculate percentage change - * between array "old" and "new", putting the percentages in "out". - * "cnt" is size of each array and "diffs" is used for scratch space. - * The array "old" is updated on each call. - * The routine assumes modulo arithmetic. This function is especially - * useful on BSD machines for calculating cpu state percentages. - */ extern ProcessField Platform_defaultFields[]; extern int Platform_numberOfFields; |