Operating System - HP-UX
1753792 Members
7320 Online
108799 Solutions
New Discussion юеВ

Re: how to get current process in hpux11 dlkm

 
SOLVED
Go to solution
Laurent Menase
Honored Contributor

Re: how to get current process in hpux11 dlkm

from user level you have pstat_getproc funcs
else in the kernel:
proc_pstat_idx_lookup_hold
proc_pstat_lookup_next_hold

- don(t forget to call proc_release()



Laurent Menase
Honored Contributor

Re: how to get current process in hpux11 dlkm

then once you have the proc you can look at its threads with
kt=p_firstthreadp(p)
then you can use kt_nextp(kt)


Then release the hold.
Laurent Menase
Honored Contributor

Re: how to get current process in hpux11 dlkm

be carefull that walking all procs and threads can take time. So be carefull to schedyield()
2 process walk.
kaijile
Frequent Advisor

Re: how to get current process in hpux11 dlkm

Is proc_list have lock?
what's the name of proc_list's lock?
how to use proc_list's lock ?
Laurent Menase
Honored Contributor

Re: how to get current process in hpux11 dlkm

proc_pstat_idx_lookup_hold
proc_pstat_lookup_next_hold

- don(t forget to call proc_release()

the hold and release is for that
kaijile
Frequent Advisor

Re: how to get current process in hpux11 dlkm

In kernel, i have the pid of the process,
how to get absolute path name of the executable file?
Laurent Menase
Honored Contributor

Re: how to get current process in hpux11 dlkm

In fact I don't see any easy way
Dennis Handly
Acclaimed Contributor

Re: how to get current process in hpux11 dlkm

>how to get absolute path name of the executable file?

Here is how to use pstat(2) calls to get it outside the kernel, not sure if that helps:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1350198
Laurent Menase
Honored Contributor

Re: how to get current process in hpux11 dlkm

in kernel no public API permit to find it.
kaijile
Frequent Advisor

Re: how to get current process in hpux11 dlkm

what are the functions pstat_stub32() and pstat() return value?

q4> disassemble pstat_stub32
Dump of assembler code for function pstat_stub32:
0x8b5678 : ldw 4(%r26),%ret0
0x8b567c : extrw,s %ret0,0,1,%ret0
0x8b5680 : stw %ret0,0(%r26)
0x8b5684 : stw %r0,8(%r26)
0x8b5688 : stw %r0,0x10(%r26)
0x8b568c : stw %r0,0x18(%r26)
0x8b5690 : ldw 0x24(%r26),%ret0
0x8b5694 : extrw,s %ret0,0,1,%ret0
0x8b5698 : ldil L'0x9a000,%r31
0x8b569c : be 0x358(%sr4,%r31)
0x8b56a0 : stw %ret0,0x20(%r26)
End of assembler dump.
q4> disassemble pstat|more
Dump of assembler code for function pstat:
0x9a358 : std %rp,-0x10(%sp)
0x9a35c : ldo 0x80(%sp),%sp
0x9a360 : mfia %r26
0x9a364 : addil L'-0x800,%r26,%r1
0x9a368 : ldo 0x7f8(%r1),%r26
0x9a36c : addil L'-0x10e000,%dp,%r1
0x9a370 : ldd 0x10(%r1),%r25
0x9a374 : ldd 0x440(%r25),%r24