Class AbstractOSProcess
- All Implemented Interfaces:
OSProcess
- Direct Known Subclasses:
AixOSProcess,FreeBsdOSProcess,LinuxOSProcess,MacOSProcess,SolarisOSProcess,WindowsOSProcess
@ThreadSafe public abstract class AbstractOSProcess extends java.lang.Object implements OSProcess
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description AbstractOSProcess(int pid) -
Method Summary
Modifier and Type Method Description longgetMajorFaults()The number of major (hard) faults the process has made which have required loading a memory page from disk.longgetMinorFaults()The number of minor (soft) faults the process has made which have not required loading a memory page from disk.doublegetProcessCpuLoadBetweenTicks(OSProcess priorSnapshot)Gets CPU usage of this process since a previous snapshot of the same process, provided as a parameter.doublegetProcessCpuLoadCumulative()Gets cumulative CPU usage of this process.intgetProcessID()Getter for the fieldprocessID.java.lang.StringtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface oshi.software.os.OSProcess
getAffinityMask, getBitness, getBytesRead, getBytesWritten, getCommandLine, getCurrentWorkingDirectory, getGroup, getGroupID, getKernelTime, getName, getOpenFiles, getParentProcessID, getPath, getPriority, getResidentSetSize, getStartTime, getState, getThreadCount, getThreadDetails, getUpTime, getUser, getUserID, getUserTime, getVirtualSize, updateAttributes
-
Constructor Details
-
AbstractOSProcess
public AbstractOSProcess(int pid)
-
-
Method Details
-
getProcessID
public int getProcessID()Description copied from interface:OSProcessGetter for the field
processID.- Specified by:
getProcessIDin interfaceOSProcess- Returns:
- Returns the processID.
-
getProcessCpuLoadCumulative
public double getProcessCpuLoadCumulative()Description copied from interface:OSProcessGets cumulative CPU usage of this process.This calculation sums CPU ticks across all processors and may exceed 100% for multi-threaded processes. This is consistent with the cumulative CPU presented by the "top" command on Linux/Unix machines.
- Specified by:
getProcessCpuLoadCumulativein interfaceOSProcess- Returns:
- The proportion of up time that the process was executing in kernel or user mode.
-
getProcessCpuLoadBetweenTicks
Description copied from interface:OSProcessGets CPU usage of this process since a previous snapshot of the same process, provided as a parameter.This calculation sums CPU ticks across all processors and may exceed 100% for multi-threaded processes. This is consistent with process usage calulations on Linux/Unix machines, but should be divided by the number of logical processors to match the value displayed by the Windows Task Manager.
The accuracy of this calculation is dependent on both the number of threads on which the process is executing, and the precision of the Operating System's tick counters. A polling interval of at least a few seconds is recommended.
- Specified by:
getProcessCpuLoadBetweenTicksin interfaceOSProcess- Parameters:
priorSnapshot- AnOSProcessobject containing statistics for this same process collected at a prior point in time. May be null.- Returns:
- If the prior snapshot is for the same process at a prior point in time, the proportion of elapsed up time between the current process snapshot and the previous one that the process was executing in kernel or user mode. Returns cumulative load otherwise.
-
getMinorFaults
public long getMinorFaults()Description copied from interface:OSProcessThe number of minor (soft) faults the process has made which have not required loading a memory page from disk. Sometimes called reclaims.Not available on Solaris. On Windows, this includes the total of major and minor faults.
- Specified by:
getMinorFaultsin interfaceOSProcess- Returns:
- minor page faults (reclaims).
-
getMajorFaults
public long getMajorFaults()Description copied from interface:OSProcessThe number of major (hard) faults the process has made which have required loading a memory page from disk.Not available on Solaris. Windows does not distinguish major and minor faults at the process level, so this value returns 0 and major faults are included in
OSProcess.getMinorFaults().- Specified by:
getMajorFaultsin interfaceOSProcess- Returns:
- major page faults.
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-