Package oshi.hardware.platform.mac
Class MacCentralProcessor
- java.lang.Object
-
- oshi.hardware.common.AbstractCentralProcessor
-
- oshi.hardware.platform.mac.MacCentralProcessor
-
- All Implemented Interfaces:
CentralProcessor
@ThreadSafe final class MacCentralProcessor extends AbstractCentralProcessor
A CPU.
-
-
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 Modifier and Type Field Description private static intARM_CPUTYPEprivate static java.util.Set<java.lang.String>ARM_P_CORESprivate static java.util.regex.PatternCPU_Nprivate static longDEFAULT_FREQUENCYprivate longefficiencyCoreFrequencyprivate booleanisArmCpuprivate static org.slf4j.LoggerLOGprivate static intM1_CPUFAMILYprivate static intM2_CPUFAMILYprivate static intM3_CPUFAMILYprivate longperformanceCoreFrequencyprivate java.util.function.Supplier<java.lang.String>vendor
-
Constructor Summary
Constructors Constructor Description MacCentralProcessor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcalculateNominalFrequencies()private java.util.Set<CentralProcessor.ProcessorCache>getCacheValues(int perflevels)private java.util.List<java.lang.String>getFeatureFlagsFromSysctl()private longgetMaxFreqFromByteArray(byte[] data)double[]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<java.util.List<CentralProcessor.LogicalProcessor>,java.util.List<CentralProcessor.PhysicalProcessor>,java.util.List<CentralProcessor.ProcessorCache>,java.util.List<java.lang.String>>initProcessorCounts()Initializes logical and physical processor lists and feature flags.private booleanisArmCpu()private static java.lang.StringplatformExpert()private static java.util.Map<java.lang.Integer,java.lang.String>queryCompatibleStrings()longqueryContextSwitches()Get number of context switcheslong[]queryCurrentFreq()Get processor current frequency.longqueryInterrupts()Get number of interruptslongqueryMaxFreq()Get processor max frequency.long[][]queryProcessorCpuLoadTicks()Get the processor CPU load ticksprotected CentralProcessor.ProcessorIdentifierqueryProcessorId()Updates logical and physical processor counts and arrayslong[]querySystemCpuLoadTicks()Get the system CPU load ticks-
Methods 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 Detail
-
LOG
private static final org.slf4j.Logger LOG
-
ARM_P_CORES
private static final java.util.Set<java.lang.String> ARM_P_CORES
-
ARM_CPUTYPE
private static final int ARM_CPUTYPE
- See Also:
- Constant Field Values
-
M1_CPUFAMILY
private static final int M1_CPUFAMILY
- See Also:
- Constant Field Values
-
M2_CPUFAMILY
private static final int M2_CPUFAMILY
- See Also:
- Constant Field Values
-
M3_CPUFAMILY
private static final int M3_CPUFAMILY
- See Also:
- Constant Field Values
-
DEFAULT_FREQUENCY
private static final long DEFAULT_FREQUENCY
- See Also:
- Constant Field Values
-
CPU_N
private static final java.util.regex.Pattern CPU_N
-
vendor
private final java.util.function.Supplier<java.lang.String> vendor
-
isArmCpu
private final boolean isArmCpu
-
performanceCoreFrequency
private long performanceCoreFrequency
-
efficiencyCoreFrequency
private long efficiencyCoreFrequency
-
-
Method Detail
-
queryProcessorId
protected CentralProcessor.ProcessorIdentifier queryProcessorId()
Description copied from class:AbstractCentralProcessorUpdates logical and physical processor counts and arrays- Specified by:
queryProcessorIdin classAbstractCentralProcessor- Returns:
- An array of initialized Logical Processors
-
initProcessorCounts
protected Quartet<java.util.List<CentralProcessor.LogicalProcessor>,java.util.List<CentralProcessor.PhysicalProcessor>,java.util.List<CentralProcessor.ProcessorCache>,java.util.List<java.lang.String>> initProcessorCounts()
Description copied from class:AbstractCentralProcessorInitializes logical and physical processor lists and feature flags.- Specified by:
initProcessorCountsin classAbstractCentralProcessor- Returns:
- Lists of initialized Logical Processors, Physical Processors, Processor Caches, and Feature Flags.
-
getCacheValues
private java.util.Set<CentralProcessor.ProcessorCache> getCacheValues(int perflevels)
-
getFeatureFlagsFromSysctl
private java.util.List<java.lang.String> getFeatureFlagsFromSysctl()
-
querySystemCpuLoadTicks
public long[] querySystemCpuLoadTicks()
Description copied from class:AbstractCentralProcessorGet the system CPU load ticks- Specified by:
querySystemCpuLoadTicksin classAbstractCentralProcessor- Returns:
- The system CPU load ticks
-
queryCurrentFreq
public long[] queryCurrentFreq()
Description copied from class:AbstractCentralProcessorGet processor current frequency.- Specified by:
queryCurrentFreqin classAbstractCentralProcessor- Returns:
- The current frequency.
-
queryMaxFreq
public long queryMaxFreq()
Description copied from class:AbstractCentralProcessorGet processor max frequency.- Overrides:
queryMaxFreqin classAbstractCentralProcessor- Returns:
- The max frequency.
-
getSystemLoadAverage
public double[] getSystemLoadAverage(int nelem)
Description copied from interface:CentralProcessorReturns 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.loadaveragetotrueto 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:AbstractCentralProcessorGet the processor CPU load ticks- Specified by:
queryProcessorCpuLoadTicksin classAbstractCentralProcessor- Returns:
- The processor CPU load ticks
-
queryContextSwitches
public long queryContextSwitches()
Description copied from class:AbstractCentralProcessorGet number of context switches- Specified by:
queryContextSwitchesin classAbstractCentralProcessor- Returns:
- The context switches
-
queryInterrupts
public long queryInterrupts()
Description copied from class:AbstractCentralProcessorGet number of interrupts- Specified by:
queryInterruptsin classAbstractCentralProcessor- Returns:
- The interrupts
-
platformExpert
private static java.lang.String platformExpert()
-
queryCompatibleStrings
private static java.util.Map<java.lang.Integer,java.lang.String> queryCompatibleStrings()
-
isArmCpu
private boolean isArmCpu()
-
calculateNominalFrequencies
private void calculateNominalFrequencies()
-
getMaxFreqFromByteArray
private long getMaxFreqFromByteArray(byte[] data)
-
-