public abstract class AbstractCentralProcessor extends Object implements CentralProcessor
CentralProcessor.LogicalProcessor, CentralProcessor.ProcessorIdentifier, CentralProcessor.TickType| Constructor and Description |
|---|
AbstractCentralProcessor()
Create a Processor
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
createProcessorID(String stepping,
String model,
String family,
String[] flags)
Creates a Processor ID by encoding the stepping, model, family, and feature
flags.
|
long |
getContextSwitches()
Get the number of context switches which have occurred
|
long[] |
getCurrentFreq()
Attempts to return the current frequency (in Hz), of the logical processors
on this CPU.
|
String |
getFamily()
Gets the family.
|
String |
getIdentifier()
Identifier, eg.
|
long |
getInterrupts()
Get the number of interrupts which have occurred
|
int |
getLogicalProcessorCount()
Get the number of logical CPUs available for processing.
|
CentralProcessor.LogicalProcessor[] |
getLogicalProcessors()
Returns an array of the CPU's logical processors.
|
long |
getMaxFreq()
Maximum frequeny (in Hz), of the logical processors on this CPU.
|
String |
getModel()
Gets the model.
|
String |
getName()
Name, eg.
|
int |
getPhysicalPackageCount()
Get the number of packages/sockets in the system.
|
int |
getPhysicalProcessorCount()
Get the number of physical CPUs/cores available for processing.
|
double[] |
getProcessorCpuLoadBetweenTicks(long[][] oldTicks)
Returns the "recent cpu usage" for all logical processors by counting ticks
from
CentralProcessor.getProcessorCpuLoadTicks() between the user-provided value from
a previous call. |
long[][] |
getProcessorCpuLoadTicks()
Get Processor CPU Load tick counters.
|
String |
getProcessorID()
Gets the Processor ID.
|
CentralProcessor.ProcessorIdentifier |
getProcessorIdentifier()
The CPU's identifier strings ,including name, vendor, stepping, model, and
family information (also called the signature of a CPU)
|
String |
getStepping()
Gets the stepping.
|
double |
getSystemCpuLoadBetweenTicks(long[] oldTicks)
Returns the "recent cpu usage" for the whole system by counting ticks from
CentralProcessor.getSystemCpuLoadTicks() between the user-provided value from a
previous call. |
long[] |
getSystemCpuLoadTicks()
Get System-wide CPU Load tick counters.
|
String |
getVendor()
Processor vendor.
|
long |
getVendorFreq()
Vendor frequency (in Hz), eg.
|
protected abstract CentralProcessor.LogicalProcessor[] |
initProcessorCounts()
Updates logical and physical processor counts and arrays
|
boolean |
isCpu64bit()
Is CPU 64bit?
|
protected abstract long |
queryContextSwitches()
Get number of context switches
|
protected abstract long[] |
queryCurrentFreq()
Get processor current frequency.
|
protected abstract long |
queryInterrupts()
Get number of interrupts
|
protected abstract long |
queryMaxFreq()
Get processor max frequency.
|
protected abstract long[][] |
queryProcessorCpuLoadTicks()
Get the processor CPU load ticks
|
protected abstract CentralProcessor.ProcessorIdentifier |
queryProcessorId()
Updates logical and physical processor counts and arrays
|
protected abstract long[] |
querySystemCpuLoadTicks()
Get the system CPU load ticks
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetSystemLoadAverageprotected abstract CentralProcessor.LogicalProcessor[] initProcessorCounts()
protected abstract CentralProcessor.ProcessorIdentifier queryProcessorId()
public CentralProcessor.ProcessorIdentifier getProcessorIdentifier()
CentralProcessorgetProcessorIdentifier in interface CentralProcessorCentralProcessor.ProcessorIdentifier object encapsulating CPU identifier
information.public String getVendor()
CentralProcessorgetVendor in interface CentralProcessorpublic String getName()
CentralProcessorgetName in interface CentralProcessorpublic String getFamily()
CentralProcessorgetFamily in interface CentralProcessorpublic String getModel()
CentralProcessorgetModel in interface CentralProcessorpublic String getStepping()
CentralProcessorgetStepping in interface CentralProcessorpublic String getProcessorID()
CentralProcessorCentralProcessor.getIdentifier() . The remaining four bytes are the contents of the
EDX register, containing feature flags.
For processors that do not support the CPUID opcode this field is populated with a comparable hex string. For example, ARM Processors will fill the first 32 bytes with the MIDR.
NOTE: The order of returned bytes is platform and software dependent. Values may be in either Big Endian or Little Endian order.
NOTE: If OSHI is unable to determine the ProcessorID from native sources, it will attempt to reconstruct one from available information in the processor identifier.
getProcessorID in interface CentralProcessorpublic String getIdentifier()
CentralProcessorgetIdentifier in interface CentralProcessorpublic boolean isCpu64bit()
CentralProcessorisCpu64bit in interface CentralProcessorpublic long getVendorFreq()
CentralProcessorgetVendorFreq in interface CentralProcessorpublic long getMaxFreq()
CentralProcessorgetMaxFreq in interface CentralProcessorprotected abstract long queryMaxFreq()
public long[] getCurrentFreq()
CentralProcessorMay not be implemented on all Operating Systems.
On Windows, returns an estimate based on the percent of maximum frequency. On Windows systems with more than 64 logical processors, may only return frequencies for the current processor group in the first portion of the array.
getCurrentFreq in interface CentralProcessorCentralProcessor.getLogicalProcessors() to correlate these
frequencies with physical packages and processors.protected abstract long[] queryCurrentFreq()
public long getContextSwitches()
CentralProcessorgetContextSwitches in interface CentralProcessorprotected abstract long queryContextSwitches()
public long getInterrupts()
CentralProcessorgetInterrupts in interface CentralProcessorprotected abstract long queryInterrupts()
public CentralProcessor.LogicalProcessor[] getLogicalProcessors()
CentralProcessorgetLogicalProcessors in interface CentralProcessorpublic long[] getSystemCpuLoadTicks()
CentralProcessorCentralProcessor.TickType.getIndex() to retrieve the
appropriate index. By measuring the difference between ticks across a time
interval, CPU load over that interval may be calculated.
Note that while tick counters are in units of milliseconds, they may advance in larger increments along with (platform dependent) clock ticks. For example, by default Windows clock ticks are 1/64 of a second (about 15 or 16 milliseconds) and Linux ticks are distribution and configuration dependent but usually 1/100 of a second (10 milliseconds).
Nice and IOWait information is not available on Windows, and IOwait and IRQ information is not available on macOS, so these ticks will always be zero.
To calculate overall Idle time using this method, include both Idle and IOWait ticks. Similarly, IRQ, SoftIRQ, and Steal ticks should be added to the System value to get the total. System ticks also include time executing other virtual hosts (steal).
getSystemCpuLoadTicks in interface CentralProcessorprotected abstract long[] querySystemCpuLoadTicks()
public long[][] getProcessorCpuLoadTicks()
CentralProcessorCentralProcessor.getLogicalProcessorCount() arrays, each containing seven elements
representing milliseconds spent in User (0), Nice (1), System (2), Idle (3),
IOwait (4), Hardware interrupts (IRQ) (5), Software interrupts/DPC (SoftIRQ)
(6), or Steal (7) states. Use
CentralProcessor.TickType.getIndex() to retrieve the
appropriate index. By measuring the difference between ticks across a time
interval, CPU load over that interval may be calculated.
Note that while tick counters are in units of milliseconds, they may advance in larger increments along with (platform dependent) clock ticks. For example, by default Windows clock ticks are 1/64 of a second (about 15 or 16 milliseconds) and Linux ticks are distribution and configuration dependent but usually 1/100 of a second (10 milliseconds).
Nice and IOwait per processor information is not available on Windows, and IOwait and IRQ information is not available on macOS, so these ticks will always be zero.
To calculate overall Idle time using this method, include both Idle and IOWait ticks. Similarly, IRQ, SoftIRQ and Steal ticks should be added to the System value to get the total. System ticks also include time executing other virtual hosts (steal).
getProcessorCpuLoadTicks in interface CentralProcessorprotected abstract long[][] queryProcessorCpuLoadTicks()
public double getSystemCpuLoadBetweenTicks(long[] oldTicks)
CentralProcessorCentralProcessor.getSystemCpuLoadTicks() between the user-provided value from a
previous call.getSystemCpuLoadBetweenTicks in interface CentralProcessoroldTicks - A tick array from a previous call to
CentralProcessor.getSystemCpuLoadTicks()public double[] getProcessorCpuLoadBetweenTicks(long[][] oldTicks)
CentralProcessorCentralProcessor.getProcessorCpuLoadTicks() between the user-provided value from
a previous call.getProcessorCpuLoadBetweenTicks in interface CentralProcessoroldTicks - A tick array from a previous call to
CentralProcessor.getProcessorCpuLoadTicks()public int getLogicalProcessorCount()
CentralProcessorgetLogicalProcessorCount in interface CentralProcessorpublic int getPhysicalProcessorCount()
CentralProcessorgetPhysicalProcessorCount in interface CentralProcessorpublic int getPhysicalPackageCount()
CentralProcessorgetPhysicalPackageCount in interface CentralProcessorprotected String createProcessorID(String stepping, String model, String family, String[] flags)
stepping - The CPU steppingmodel - The CPU modelfamily - The CPU familyflags - A space-delimited list of CPU feature flagsCopyright © 2019. All rights reserved.