1
2
3
4
5 package oshi.driver.unix.aix.perfstat;
6
7 import java.util.Arrays;
8
9 import com.sun.jna.platform.unix.aix.Perfstat;
10 import com.sun.jna.platform.unix.aix.Perfstat.perfstat_id_t;
11 import com.sun.jna.platform.unix.aix.Perfstat.perfstat_process_t;
12
13 import oshi.annotation.concurrent.ThreadSafe;
14
15
16
17
18 @ThreadSafe
19 public final class PerfstatProcess {
20
21 private static final Perfstat PERF = Perfstat.INSTANCE;
22
23 private PerfstatProcess() {
24 }
25
26
27
28
29
30
31 public static perfstat_process_t[] queryProcesses() {
32 perfstat_process_t process = new perfstat_process_t();
33
34 int procCount = PERF.perfstat_process(null, null, process.size(), 0);
35 if (procCount > 0) {
36 perfstat_process_t[] proct = (perfstat_process_t[]) process.toArray(procCount);
37 perfstat_id_t firstprocess = new perfstat_id_t();
38 int ret = PERF.perfstat_process(firstprocess, proct, process.size(), procCount);
39 if (ret > 0) {
40 return Arrays.copyOf(proct, ret);
41 }
42 }
43 return new perfstat_process_t[0];
44 }
45 }