I wanted to display information about threads running in a big Java application, and see what was executing during set up.
Rexx can provide information on threads, and so I was able to create a script which provided process thread data. There was documentation, but it was not very clear, so I’m documenting what I learned
My program
/* rexx */
do k = 1 to 20
call procinfo
say "jobname asid ppid pid threadid tcb cmdline"
do i=1 to bpxw_pid.0
x =procinfo(bpxw_pid.i,'process')
if x = '' then iterate
if bpxw_LOGNAME.i <> "ZWESVUSR" then iterate
y = procinfo(bpxw_pid.i,'thread')
if y = '' then iterate
do j=1 to bpxw_threads
xtcb = d2x( bpxw_TCB.j)
say bpxw_JOBNAME d2x(bpxw_ASID) right(bpxw_PPID,8),
right(bpxw_PID,8) bpxw_THREAD_ID.j xtcb bpxw_CMDLINE
end
end
sleep(1)
end
- call procinfo returns a list of process ids in a stem bpxw_pid. and userids in a stem bpxw_LOGNAME
- do i=1 to bpxw_pid.0 iterate through the list of the processes
- x =procinfo(bpxw_pid.i,’process’) get the process information about the process id in bpxw_pid.i.
- if x = ” then iterate if the thread no longer exists – do the next one
- if bpxw_LOGNAME.i <> “ZWESVUSR” then iterate ignore threads from other userids
- y = procinfo(bpxw_pid.i,’thread’) get the thread information for the process id in bpxw_pid.i.
- if y = ” then iterate if no data is returned skip this
- do j=1 to bpxw_threads for each thread in the process …
- xtcb = d2x( bpxw_TCB.j) convert the thread TCB from decimal to hex.
- say …
- bpxw_JOBNAME this is from the process information
- d2x(bpxw_ASID) display the ASID of the process in hex
- bpxw_THREAD_ID.j the thread id.