1
2
3
4
5 package oshi.software.os.unix.aix;
6
7 import oshi.annotation.concurrent.ThreadSafe;
8 import oshi.driver.unix.aix.PsInfo;
9 import oshi.jna.platform.unix.AixLibc.AixLwpsInfo;
10 import oshi.software.common.AbstractOSThread;
11 import oshi.software.os.OSProcess;
12
13
14
15
16 @ThreadSafe
17 public class AixOSThread extends AbstractOSThread {
18
19 private int threadId;
20 private OSProcess.State state = OSProcess.State.INVALID;
21 private long startMemoryAddress;
22 private long contextSwitches;
23 private long kernelTime;
24 private long userTime;
25 private long startTime;
26 private long upTime;
27 private int priority;
28
29 public AixOSThread(int pid, int tid) {
30 super(pid);
31 this.threadId = tid;
32 updateAttributes();
33 }
34
35 @Override
36 public int getThreadId() {
37 return this.threadId;
38 }
39
40 @Override
41 public OSProcess.State getState() {
42 return this.state;
43 }
44
45 @Override
46 public long getStartMemoryAddress() {
47 return this.startMemoryAddress;
48 }
49
50 @Override
51 public long getContextSwitches() {
52 return this.contextSwitches;
53 }
54
55 @Override
56 public long getKernelTime() {
57 return this.kernelTime;
58 }
59
60 @Override
61 public long getUserTime() {
62 return this.userTime;
63 }
64
65 @Override
66 public long getUpTime() {
67 return this.upTime;
68 }
69
70 @Override
71 public long getStartTime() {
72 return this.startTime;
73 }
74
75 @Override
76 public int getPriority() {
77 return this.priority;
78 }
79
80 @Override
81 public boolean updateAttributes() {
82 AixLwpsInfo lwpsinfo = PsInfo.queryLwpsInfo(getOwningProcessId(), getThreadId());
83 if (lwpsinfo == null) {
84 this.state = OSProcess.State.INVALID;
85 return false;
86 }
87 this.threadId = (int) lwpsinfo.pr_lwpid;
88 this.startMemoryAddress = lwpsinfo.pr_addr;
89 this.state = AixOSProcess.getStateFromOutput((char) lwpsinfo.pr_sname);
90 this.priority = lwpsinfo.pr_pri;
91 return true;
92 }
93 }