Class AbstractOSProcess

java.lang.Object
oshi.software.common.AbstractOSProcess
All Implemented Interfaces:
OSProcess
Direct Known Subclasses:
FreeBsdOSProcess, LinuxOSProcess, MacOSProcess, SolarisOSProcess, WindowsOSProcess

@ThreadSafe
public abstract class AbstractOSProcess
extends java.lang.Object
implements OSProcess
A process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently.
  • Constructor Details

  • Method Details

    • getProcessID

      public int getProcessID()
      Description copied from interface: OSProcess

      Getter for the field processID.

      Specified by:
      getProcessID in interface OSProcess
      Returns:
      Returns the processID.
    • getProcessCpuLoadCumulative

      public double getProcessCpuLoadCumulative()
      Description copied from interface: OSProcess
      Gets cumulative CPU usage of this process.
      Specified by:
      getProcessCpuLoadCumulative in interface OSProcess
      Returns:
      The proportion of up time that the process was executing in kernel or user mode.
    • getProcessCpuLoadBetweenTicks

      public double getProcessCpuLoadBetweenTicks​(OSProcess priorSnapshot)
      Description copied from interface: OSProcess
      Gets CPU usage of this process since a previous snapshot of the same process, provided as a parameter.

      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:
      getProcessCpuLoadBetweenTicks in interface OSProcess
      Parameters:
      priorSnapshot - An OSProcess object 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.
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object