summaryrefslogtreecommitdiffstats
path: root/CPUMeter.c
AgeCommit message (Collapse)Author
2023-12-26Update includes based on IWYUBenny Baumann
2023-08-31Rename ProcessList to ProcessTable throughoutNathan Scott
Following up with some discusson from a few months back, where it was proposed that ProcessTable is a better name. This data structure is definitely not a list ... if it was one-dimensional it'd be a set, but in practice it has much more in common with a two-dimensional table. The Process table is a familiar operating system concept for many people too so it resonates a little in that way as well.
2023-08-18Replace isnan() with better comparisons (isgreater(), etc.)Explorer09
The standard isnan() function is defined to never throw FP exceptions even when the argument is a "signaling" NaN. This makes isnan() more expensive than (x != x) expression unless the compiler flag '-fno-signaling-nans' is given. Introduce functions isNaN(), isNonnegative(), isPositive(), sumPositiveValues() and compareRealNumbers(), and replace isnan() in htop's codebase with the new functions. These functions utilize isgreater() and isgreaterequal() comparisons, which do not throw FP exceptions on "quiet" NaNs, which htop uses extensively. With isnan() removed, there is no need to suppress the warning '-Wno-c11-extensions' in FreeBSD. Remove the code from 'configure.ac'. Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
2023-05-08Introduce Machine class for host-specific info (split from ProcessList)Nathan Scott
First stage in sanitizing the process list structure so that htop can support other types of lists too (cgroups, filesystems, ...), in the not-too-distant future. This introduces struct Machine for system-wide information while keeping process-list information in ProcessList (now much less). Next step is to propogate this separation into each platform, to match these core changes.
2022-12-02CPUMeter: show frequency in text modeChristian Göttsche
Closes: #1144
2022-10-24Reformat code baseBenny Baumann
This includes: - Wrap function implementations - Pointer alignment for function signatures - Pointer alignment for variable declarations - Whitespace after keywords - Whitespace after comma - Whitespace around initializers - Whitespace around operators - Code indentation - Line break for single line statements - Misleading alignment
2021-09-22Update license headers to explicitly say GPLv2+Daniel Lange
2021-09-18Header: do not let multi-column meters expand to empty neighborsChristian Göttsche
Extending to right neighbors is intended for text meters with an overlong content, so the whole text is shown if possible. Multi column meters, like the combined memory and swap meter, position its text depending on the given total width; keep the position to the original assigned header slot. Short term resolution for #796
2021-09-02CPUMeter: use correct buffer sizeChristian Göttsche
2021-08-25IWYU updateChristian Göttsche
2021-08-10CPUMeter: show if a CPU is offline in text modeChristian Göttsche
Related to #729 as the text mode displays all zero values for offline CPUs.
2021-07-18Rework CPU countingChristian Göttsche
Currently htop does not support offline CPUs and hot-swapping, e.g. via echo 0 > /sys/devices/system/cpu/cpu2/online Split the current single cpuCount variable into activeCPUs and existingCPUs. Supersedes: #650 Related: #580
2021-07-07Add a new DynamicMeter class for runtime Meter extensionNathan Scott
This commit is based on exploratory work by Sohaib Mohamed. The end goal is two-fold - to support addition of Meters we build via configuration files for both the PCP platform and for scripts ( https://github.com/htop-dev/htop/issues/526 ) Here, we focus on generic code and the PCP support. A new class DynamicMeter is introduced - it uses the special case 'param' field handling that previously was used only by the CPUMeter, such that every runtime-configured Meter is given a unique identifier. Unlike with the CPUMeter this is used internally only. When reading/writing to htoprc instead of CPU(N) - where N is an integer param (CPU number) - we use the string name for each meter. For example, if we have a configuration for a DynamicMeter for some Redis metrics, we might read and write "Dynamic(redis)". This identifier is subsequently matched (back) up to the configuration file so we're able to re-create arbitrary user configurations. The PCP platform configuration file format is fairly simple. We expand configs from several directories, including the users homedir alongside htoprc (below htop/meters/) and also /etc/pcp/htop/meters. The format will be described via a new pcp-htop(5) man page, but its basically ini-style and each Meter has one or more metric expressions associated, as well as specifications for labels, color and so on via a dot separated notation for individual metrics within the Meter. A few initial sample configuration files are provided below ./pcp/meters that give the general idea. The PCP "derived" metric specification - see pmRegisterDerived(3) - is used as the syntax for specifying metrics in PCP DynamicMeters.
2021-04-26Use RichString_appendnAscii where possibleChristian Göttsche
`RichString_appendnAscii()` avoids a `strlen(3)` call over ` RichString_appendAscii()`. Use the former where the length is available from a previous checked `snprintf(3)` call. Keep `RichString_appendAscii()` when passing a string literal and rely on compilers to optimize the `strlen(3)` call away.
2021-03-19Use unsigned types for CPU counts and associated variablesChristian Göttsche
2021-03-19Merge branch 'richstring_memset' of cgzones/htopDaniel Lange
2021-03-18Merge pull request #436 from cgzones/freebsdGraham Inggs
FreeBSD: add support for CPU frequency and temperature Tested on two physical systems running FreeBSD 12.1
2021-03-17RichString: do not unnecessarily clean whole bufferChristian Göttsche
The local stack buffer does not need to be cleaned to zeros when - just initialized, cause the length is set to 0 and the first character is set to '\0', so all printing functions will safely stop - no further used, i.e. the variable goes out of scope
2021-03-12CPUMeter_init: compactify branchesChristian Göttsche
2021-03-04Separate data-update and drawing of headerChristian Göttsche
2021-03-04Save text buffer in MeterChristian Göttsche
2021-02-05FreeBSD: add support for CPU frequency and temperatureChristian Göttsche
2021-01-11Mark several non-modified pointer variables constChristian Göttsche
2020-12-20CPUMeter: drop minimum width of CPU usage in bar modeChristian Göttsche
The usage percentage is the first text, no need to set a minimum width. The BarMeter does already add padding.
2020-12-08Split RichString_(append|appendn|write) into wide and asciiChristian Göttsche
RichString_writeFrom takes a top spot during performance analysis due to the calls to mbstowcs() and iswprint(). Most of the time we know in advance that we are only going to print regular ASCII characters.
2020-12-06Use size_t as len type for Meter_UpdateValuesChristian Göttsche
Most of the time the parameter is passed to snprintf type functions
2020-12-02Dynamically load libsensors at runtimeChristian Göttsche
2020-11-19IWYU update (FreeBSD)Christian Goettsche
2020-11-19IWYU update (Linux)Christian Göttsche
2020-11-16Show CPU temperature in CPU meterChristian Göttsche
Show the CPU temperature in the CPU meter, like CPU frequency, instead of using an extra Meter.
2020-11-02Embracing branchesBenny Baumann
2020-11-02Spacing around operatorsBenny Baumann
2020-10-31Use integer type for item count instead of charChristian Göttsche
2020-10-18Make all required includes explicitBenny Baumann
Information as seen by IWYU 0.12 + clang 9 on Linux
2020-10-16Rename StringUtils.[ch] to XUtils.[ch]Benny Baumann
2020-10-16Move xAsprintf, xSnprintf and xStrdup to StringUtils.hBenny Baumann
2020-10-12CPUMeter: avoid crashes and leaks in case the CPU count changesChristian Göttsche
E.g. if the HT/SMT mode changes Use separate data for sub-meters Do not reuse drawData for maintainability
2020-10-10Mark Object pointer to _display function constChristian Göttsche
2020-10-07Mark Object instances constChristian Göttsche
2020-10-07Mark Object classes and Object class fields constChristian Göttsche
2020-10-05Update License consistently to GPLv2 as per COPYING fileDaniel Lange
2020-09-29Covert Meter attributes to file-local constant arraysChristian Göttsche
2020-09-28CPUMeter: add octuple-column CPU meters.multi
This is a straightforward extension of the existing multi-column CPU meter code, which now allows for up CPU meters to be displayed in up to 16 columns. This also adds the meter declarations to all the platform-specific code.
2020-09-28CPUMeter: refactor common CPU meter rendering code.multi
Instead of scanning the meter name to determine the number of columns in a CPU meter, move the common code behind some wrapper functions, and specify the number of columns as an explicit parameter when called from the wrappers. While this does add a bit of code for all the necessary wrapper functions, this should be less brittle in case of future changes to the CPU meter code.
2020-09-24Read CPU frequency from sysfs by defaultChristian Göttsche
Use the more portable sysfs node /sys/devices/system/cpu/cpuX/cpufreq/scaling_cur_freq to get the CPU frequency. In case of an error fall back to /proc/cpuinfo . Also use a fixed width of 4 for the frequency to avoid position jumps in case the frequency moves in the range 900-1100 MHz.
2020-09-24Update CPU freq display to use NAN on errorBenny Baumann
2020-09-24Use threshold for display of guest/steal/irq metersBenny Baumann
2020-09-24align cpu id to rightChristian Hesse
2020-09-09Merge branch 'master' of https://github.com/rgouicem/htop into rgouicem-masterNathan Scott
2020-09-09Consolidate repeated macro definitions into one headerNathan Scott
The MIN, MAX, CLAMP, MINIMUM, and MAXIMUM macros appear throughout the codebase with many re-definitions. Make a single copy of each in a common header file, and use the BSD variants of MINIMUM/MAXIMUM due to conflicts in the system <sys/param.h> headers.