Class WindowsCentralProcessor
java.lang.Object
oshi.hardware.common.AbstractCentralProcessor
oshi.hardware.common.platform.windows.WindowsCentralProcessor
- All Implemented Interfaces:
CentralProcessor
Common non-native logic for Windows Central Processor implementations.
-
Nested Class Summary
Nested classes/interfaces inherited from interface CentralProcessor
CentralProcessor.LogicalProcessor, CentralProcessor.PhysicalProcessor, CentralProcessor.ProcessorCache, CentralProcessor.ProcessorIdentifier, CentralProcessor.TickTypeModifier and TypeInterfaceDescriptionstatic classA class representing a Logical Processor and its replationship to physical processors, physical packages, and logical groupings such as NUMA Nodes and Processor groups, useful for identifying processor topology.static classA class representing a Physical Processor (a core) providing per-core statistics that may vary, particularly in hybrid/modular processors.static classA class representing CPU Cache Memory.static final classA class encapsulating ghe CPU's identifier strings ,including name, vendor, stepping, model, and family information (also called the signature of a CPU)static enumIndex of CPU tick counters in theCentralProcessor.getSystemCpuLoadTicks()andCentralProcessor.getProcessorCpuLoadTicks()arrays. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final booleanWhether to match task manager using Processor Utility ticks.protected static final booleanWhether to use legacy Processor counters rather than Processor Information counters.protected static final booleanWhether to start a daemon thread to calculate load average. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidBuilds the numaNodeProcToLogicalProcMap from the logical processor list.Gets the initial utility counters.Gets the numaNodeProcToLogicalProcMap.protected longlazilyCalculateMultiplier(long deltaBase, long deltaT) Lazily calculate the capacity tick multiplier once.protected static StringparseIdentifier(String identifier, String key) Parses identifier stringprotected long[][]processTickData(List<String> instances, List<Long> systemList, List<Long> userList, List<Long> irqList, List<Long> softIrqList, List<Long> idleList, List<Long> baseList, List<Long> systemUtility, List<Long> processorUtility, List<Long> processorUtilityBase, List<Long> initSystemList, List<Long> initUserList, List<Long> initBase, List<Long> initSystemUtility, List<Long> initProcessorUtility, List<Long> initProcessorUtilityBase) Processes raw perfmon tick data into the standard tick array format.protected abstract Pair<List<String>, Map<ProcessorInformation.ProcessorUtilityTickCountProperty, List<Long>>> Subclasses query the perfmon Processor Information capacity (utility) counters via their JNA or FFM driver.protected abstract Pair<List<String>, Map<ProcessorInformation.ProcessorTickCountProperty, List<Long>>> Subclasses query the perfmon Processor Information tick counters via their JNA or FFM driver.long[][]Get the processor CPU load ticksProvides the current utility counters for re-initialization.protected voidsetInitialUtilityCounters(Map<ProcessorInformation.ProcessorUtilityTickCountProperty, List<Long>> counters) Sets the initial utility counters.Methods inherited from class AbstractCentralProcessor
createProcessorID, createProcessorID, createProcListFromDmesg, getContextSwitches, getCurrentFreq, getFeatureFlags, getInterrupts, getLogicalProcessorCount, getLogicalProcessors, getMaxFreq, getPhysicalPackageCount, getPhysicalProcessorCount, getPhysicalProcessors, getProcessorCaches, getProcessorCpuLoadBetweenTicks, getProcessorCpuLoadBetweenTicks, getProcessorCpuLoadTicks, getProcessorIdentifier, getSystemCpuLoadBetweenTicks, getSystemCpuLoadBetweenTicks, getSystemCpuLoadTicks, initProcessorCounts, orderedProcCaches, queryContextSwitches, queryCurrentFreq, queryInterrupts, queryMaxFreq, queryProcessorId, querySystemCpuLoadTicks, toStringModifier and TypeMethodDescriptionprotected static StringcreateProcessorID(String stepping, String model, String family, String[] flags) Creates a Processor ID by encoding the stepping, model, family, and feature flags.protected static StringcreateProcessorID(String stepping, String model, String family, String[] flags, long hwcap) Creates a Processor ID by encoding the stepping, model, family, and feature flags.protected List<CentralProcessor.PhysicalProcessor> createProcListFromDmesg(List<CentralProcessor.LogicalProcessor> logProcs, Map<Integer, String> dmesg) Creates a list of physical processors from dmesg output.longGet the number of system-wide context switches which have occurred.long[]Attempts to return the current frequency (in Hz), of the logical processors on this CPU.Returns a list of platform-specific strings which identify CPU Feature Flags.longGet the number of system-wide interrupts which have occurred.intGet the number of logical CPUs available for processing.Returns anUnmodifiableListof the CPU's logical processors.longMaximum frequeny (in Hz), of the logical processors on this CPU.intGet the number of packages/sockets in the system.intGet the number of physical CPUs/cores available for processing.Returns anUnmodifiableListof the CPU's physical processors.Makes a best-effort attempt to identify the CPU's processor caches.double[]getProcessorCpuLoadBetweenTicks(long[][] oldTicks) Returns the "recent cpu usage" for all logical processors by counting ticks fromCentralProcessor.getProcessorCpuLoadTicks()between the user-provided value from a previous call.double[]getProcessorCpuLoadBetweenTicks(long[][] oldTicks, long[][] ticks) Returns the "recent cpu usage" for all logical processors by counting ticks fromCentralProcessor.getProcessorCpuLoadTicks()between the user-provided value from a previous call.long[][]Get Processor CPU Load tick counters.The CPU's identifier strings ,including name, vendor, stepping, model, and family information (also called the signature of a CPU).doublegetSystemCpuLoadBetweenTicks(long[] oldTicks) Returns the "recent cpu usage" for the whole system by counting ticks fromCentralProcessor.getSystemCpuLoadTicks()between the user-provided value from a previous call.doublegetSystemCpuLoadBetweenTicks(long[] oldTicks, long[] ticks) Returns the "recent cpu usage" for the whole system by counting ticks between two user-provided values, retrieved fromCentralProcessor.getSystemCpuLoadTicks()at different points in time.long[]Get System-wide CPU Load tick counters.protected abstract Quartet<List<CentralProcessor.LogicalProcessor>, List<CentralProcessor.PhysicalProcessor>, List<CentralProcessor.ProcessorCache>, List<String>> Initializes logical and physical processor lists and feature flags.static List<CentralProcessor.ProcessorCache> Filters a set of processor caches to an ordered listprotected abstract longGet number of context switchesprotected abstract long[]Get processor current frequency.protected abstract longGet number of interruptsprotected longGet processor max frequency.protected abstract CentralProcessor.ProcessorIdentifierUpdates logical and physical processor counts and arraysprotected abstract long[]Get the system CPU load tickstoString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface CentralProcessor
getProcessorCpuLoad, getSystemCpuLoad, getSystemLoadAverageModifier and TypeMethodDescriptiondefault double[]getProcessorCpuLoad(long delay) This is a convenience method which collects an initial set of ticks usingCentralProcessor.getProcessorCpuLoadTicks()and passes that result toCentralProcessor.getProcessorCpuLoadBetweenTicks(long[][])after the specified delay.default doublegetSystemCpuLoad(long delay) This is a convenience method which collects an initial set of ticks usingCentralProcessor.getSystemCpuLoadTicks()and passes that result toCentralProcessor.getSystemCpuLoadBetweenTicks(long[])after the specified delay.double[]getSystemLoadAverage(int nelem) Returns the system load average for the number of elements specified, up to 3, representing 1, 5, and 15 minutes.
-
Field Details
-
USE_LEGACY_SYSTEM_COUNTERS
protected static final boolean USE_LEGACY_SYSTEM_COUNTERSWhether to use legacy Processor counters rather than Processor Information counters. -
USE_LOAD_AVERAGE
protected static final boolean USE_LOAD_AVERAGEWhether to start a daemon thread to calculate load average. -
USE_CPU_UTILITY
protected static final boolean USE_CPU_UTILITYWhether to match task manager using Processor Utility ticks.
-
-
Constructor Details
-
WindowsCentralProcessor
protected WindowsCentralProcessor()Default constructor.
-
-
Method Details
-
getNumaNodeProcToLogicalProcMap
-
getInitialUtilityCounters
protected Map<ProcessorInformation.ProcessorUtilityTickCountProperty, List<Long>> getInitialUtilityCounters()Gets the initial utility counters.- Returns:
- the initial utility counters
-
setInitialUtilityCounters
protected void setInitialUtilityCounters(Map<ProcessorInformation.ProcessorUtilityTickCountProperty, List<Long>> counters) Sets the initial utility counters.- Parameters:
counters- the counters to set
-
buildNumaNodeProcMap
Builds the numaNodeProcToLogicalProcMap from the logical processor list.- Parameters:
logProcs- the list of logical processors
-
parseIdentifier
-
lazilyCalculateMultiplier
protected long lazilyCalculateMultiplier(long deltaBase, long deltaT) Lazily calculate the capacity tick multiplier once.- Parameters:
deltaBase- The difference in base ticks.deltaT- The difference in elapsed 100NS time- Returns:
- The ratio of elapsed time to base ticks
-
queryProcessorUtilityCounters
protected Map<ProcessorInformation.ProcessorUtilityTickCountProperty, List<Long>> queryProcessorUtilityCounters()Provides the current utility counters for re-initialization.- Returns:
- the current processor utility counter values
-
queryProcessorCapacityCounters
protected abstract Pair<List<String>, Map<ProcessorInformation.ProcessorUtilityTickCountProperty, List<Long>>> queryProcessorCapacityCounters()Subclasses query the perfmon Processor Information capacity (utility) counters via their JNA or FFM driver.- Returns:
- the instance names and processor capacity/utility counter values
-
queryProcessorCounters
-
queryProcessorCpuLoadTicks
public long[][] queryProcessorCpuLoadTicks()Description copied from class:AbstractCentralProcessorGet the processor CPU load ticks- Specified by:
queryProcessorCpuLoadTicksin classAbstractCentralProcessor- Returns:
- The processor CPU load ticks
-
processTickData
protected long[][] processTickData(List<String> instances, List<Long> systemList, List<Long> userList, List<Long> irqList, List<Long> softIrqList, List<Long> idleList, List<Long> baseList, List<Long> systemUtility, List<Long> processorUtility, List<Long> processorUtilityBase, List<Long> initSystemList, List<Long> initUserList, List<Long> initBase, List<Long> initSystemUtility, List<Long> initProcessorUtility, List<Long> initProcessorUtilityBase) Processes raw perfmon tick data into the standard tick array format. Handles both legacy and utility-based approaches.- Parameters:
instances- the perfmon instance namessystemList- system (privileged) time ticksuserList- user time ticksirqList- IRQ time tickssoftIrqList- soft IRQ (DPC) time ticksidleList- idle time ticksbaseList- timestamp base (for utility mode), may be nullsystemUtility- system utility ticks, may be nullprocessorUtility- processor utility ticks, may be nullprocessorUtilityBase- processor utility base, may be nullinitSystemList- initial system ticks (for utility mode), may be nullinitUserList- initial user ticks (for utility mode), may be nullinitBase- initial base (for utility mode), may be nullinitSystemUtility- initial system utility, may be nullinitProcessorUtility- initial processor utility, may be nullinitProcessorUtilityBase- initial processor utility base, may be null- Returns:
- the processed tick array
-