A question I received this week from a customer.
Hi Chris,
Is there a way to find on which processor a process is executing?
If Ive used binprocessor, ps emo THREAD, would show which processor a process is bound too. But when thats not been used, what are the options?
The ps command will only help if we bind a process to a specific CPU. For example, here we can see that the bootpd process has been bound (and then un-bound) on processor 3:
# bindprocessor -q
The available processors are: 0 1 2 3
# bindprocessor 8585302 3
# ps -o THREAD -p 8585302
USER PID PPID TID ST CP PRI SC WCHAN F TT BND COMMAND
root 8585302 4063394 - A 0 60 1 - 200001 - 3 bootpd /etc/bootptab
# bindprocessor -u 8585302
# ps -o THREAD -p 8585302
USER PID PPID TID ST CP PRI SC WCHAN F TT BND COMMAND
root 8585302 4063394 - A 0 60 1 - 200001 - - bootpd /etc/bootptab
The trace command will tell us what CPU a process is scheduled on.*
# /usr/bin/trace Jcurt' -P'p' '-a'
# sleep 30
# trcstop
# trcrpt -O'exec=y' -O'pid=n' -O'tid=n' -O'wparname=off' -O'cid=off' -O'svc=y' -O'timestamp=1' | /usr/lib/ras/trace_smutil cat Z'/tmp/trace.out'
# vi /tmp/trace.out (Im interested in PID 904428 in this case)
106 ksh 0.033107 dispatch: cmd=ksh pid=9044208 tid=9175205 priority=135 old_tid=9175205 old_priority=135 CPUID=2 [302 usec]
101D ksh0.033108 Home SRAD=-1 Home ref1=-1 Dispatch SRAD=-1 Dispatch ref1=-1
200 ksh0.033108 resume ksh iar=100180CC cpuid=02
*Note: If you are running AIX 5.3 try these options with trcrpt (tested on an AIX 5.3 TL11 SP3 system):
# trcrpt -O'exec=y' -O'pid=n' -O'tid=n' -O'svc=y' -O'timestamp=1' | /usr/lib/ras/trace_smutil cat Z'/tmp/trace.out'
Perhaps there are other methods of monitoring this type of activity online, rather than offline?