Package oshi.hardware.platform.windows
Class WindowsCentralProcessor
java.lang.Object
oshi.hardware.common.AbstractCentralProcessor
oshi.hardware.platform.windows.WindowsCentralProcessor
- All Implemented Interfaces:
CentralProcessor
A CPU, representing all of a system's processors. It may contain multiple individual Physical and Logical processors.
-
Nested Class Summary
Nested classes/interfaces inherited from interface oshi.hardware.CentralProcessor
CentralProcessor.LogicalProcessor, CentralProcessor.PhysicalProcessor, CentralProcessor.ProcessorCache, CentralProcessor.ProcessorIdentifier, CentralProcessor.TickType
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
getSystemLoadAverage
(int nelem) Returns the system load average for the number of elements specified, up to 3, representing 1, 5, and 15 minutes.protected Quartet
<List<CentralProcessor.LogicalProcessor>, List<CentralProcessor.PhysicalProcessor>, List<CentralProcessor.ProcessorCache>, List<String>> Initializes logical and physical processor lists and feature flags.private long
lazilyCalculateMultiplier
(long deltaBase, long deltaT) Lazily calculate the capacity tick multiplier once.private static String
parseIdentifier
(String identifier, String key) Parses identifier stringlong
Get number of context switcheslong[]
Get processor current frequency.long
Get number of interruptslong
Get processor max frequency.private long[]
queryNTPower
(int fieldIndex) Call CallNTPowerInformation for Processor information and return an array of the specified indexlong[][]
Get the processor CPU load ticksprotected CentralProcessor.ProcessorIdentifier
Initializes Class variablesprivate static Pair
<List<String>, Map<ProcessorInformation.ProcessorUtilityTickCountProperty, List<Long>>> long[]
Get the system CPU load ticksMethods inherited from class oshi.hardware.common.AbstractCentralProcessor
createProcessorID, createProcListFromDmesg, getContextSwitches, getCurrentFreq, getFeatureFlags, getInterrupts, getLogicalProcessorCount, getLogicalProcessors, getMaxFreq, getPhysicalPackageCount, getPhysicalProcessorCount, getPhysicalProcessors, getProcessorCaches, getProcessorCpuLoadBetweenTicks, getProcessorCpuLoadTicks, getProcessorIdentifier, getSystemCpuLoadBetweenTicks, getSystemCpuLoadTicks, orderedProcCaches, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface oshi.hardware.CentralProcessor
getProcessorCpuLoad, getSystemCpuLoad
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
numaNodeProcToLogicalProcMap
-
USE_LEGACY_SYSTEM_COUNTERS
private static final boolean USE_LEGACY_SYSTEM_COUNTERS -
USE_LOAD_AVERAGE
private static final boolean USE_LOAD_AVERAGE -
USE_CPU_UTILITY
private static final boolean USE_CPU_UTILITY -
processorUtilityCounters
-
initialUtilityCounters
private Map<ProcessorInformation.ProcessorUtilityTickCountProperty,List<Long>> initialUtilityCounters -
utilityBaseMultiplier
-
-
Constructor Details
-
WindowsCentralProcessor
WindowsCentralProcessor()
-
-
Method Details
-
queryProcessorId
Initializes Class variables- Specified by:
queryProcessorId
in classAbstractCentralProcessor
- Returns:
- An array of initialized Logical Processors
-
parseIdentifier
Parses identifier string- Parameters:
identifier
- the full identifier stringkey
- the key to retrieve- Returns:
- the string following id
-
initProcessorCounts
protected Quartet<List<CentralProcessor.LogicalProcessor>,List<CentralProcessor.PhysicalProcessor>, initProcessorCounts()List<CentralProcessor.ProcessorCache>, List<String>> Description copied from class:AbstractCentralProcessor
Initializes logical and physical processor lists and feature flags.- Specified by:
initProcessorCounts
in classAbstractCentralProcessor
- Returns:
- Lists of initialized Logical Processors, Physical Processors, Processor Caches, and Feature Flags.
-
querySystemCpuLoadTicks
public long[] querySystemCpuLoadTicks()Description copied from class:AbstractCentralProcessor
Get the system CPU load ticks- Specified by:
querySystemCpuLoadTicks
in classAbstractCentralProcessor
- Returns:
- The system CPU load ticks
-
queryCurrentFreq
public long[] queryCurrentFreq()Description copied from class:AbstractCentralProcessor
Get processor current frequency.- Specified by:
queryCurrentFreq
in classAbstractCentralProcessor
- Returns:
- The current frequency.
-
queryMaxFreq
public long queryMaxFreq()Description copied from class:AbstractCentralProcessor
Get processor max frequency.- Overrides:
queryMaxFreq
in classAbstractCentralProcessor
- Returns:
- The max frequency.
-
queryNTPower
private long[] queryNTPower(int fieldIndex) Call CallNTPowerInformation for Processor information and return an array of the specified index- Parameters:
fieldIndex
- The field, in order as defined in theinvalid reference
PowrProf#PROCESSOR_INFORMATION
- Returns:
- The array of values.
-
getSystemLoadAverage
public double[] getSystemLoadAverage(int nelem) Description copied from interface:CentralProcessor
Returns the system load average for the number of elements specified, up to 3, representing 1, 5, and 15 minutes. The system load average is the sum of the number of runnable entities queued to the available processors and the number of runnable entities running on the available processors averaged over a period of time.This method is designed to provide a hint about the system load and may be queried frequently.
The way in which the load average is calculated is operating system specific but is typically a damped time-dependent average. Linux includes processes waiting for system resources such as disks, while macOS and Unix consider only processes waiting for CPU.
Windows does not provide a load average. Users may set the configuration property
oshi.os.windows.loadaverage
totrue
to start a daemon thread which will provide a similar metric.The load average may be unavailable on some platforms (e.g., Windows without the above configuration). If the load average is not available, a negative value is returned.
- Parameters:
nelem
- Number of elements to return.- Returns:
- an array of the system load averages for 1, 5, and 15 minutes with the size of the array specified by nelem; or negative values if not available.
-
queryProcessorCpuLoadTicks
public long[][] queryProcessorCpuLoadTicks()Description copied from class:AbstractCentralProcessor
Get the processor CPU load ticks- Specified by:
queryProcessorCpuLoadTicks
in classAbstractCentralProcessor
- Returns:
- The processor CPU load ticks
-
lazilyCalculateMultiplier
private 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
-
queryContextSwitches
public long queryContextSwitches()Description copied from class:AbstractCentralProcessor
Get number of context switches- Specified by:
queryContextSwitches
in classAbstractCentralProcessor
- Returns:
- The context switches
-
queryInterrupts
public long queryInterrupts()Description copied from class:AbstractCentralProcessor
Get number of interrupts- Specified by:
queryInterrupts
in classAbstractCentralProcessor
- Returns:
- The interrupts
-