Operating System - HP-UX
1832839 Members
2817 Online
110047 Solutions
New Discussion

pthread programming question

 
Laurent de Segur
Occasional Contributor

pthread programming question

I am new to HP-UX programming and currently in the midst of porting an app to this OS. I've been digging thru the docs and header files to find out on how to solve one problem I have. So far not much luck.

First off, sorry if this is the wrong place for asking. Please let me know where is a better place to ask if this is the case.

I am trying to determine if a thread has run using platform dependent calls and the pthread api. I start with a pthread. All I need is a pd thread call that would return an associated kernel thread from the pthread I give, then an np (non portable) call to gather the thread usage for that particular thread from the kernel stand point (has it been schedule and/or for how long, thread status, etc...). Things like that can be found in the kernel thread context usually.

Thanks for your help in advance.

LdS
5 REPLIES 5
Mike Stroyan
Honored Contributor

Re: pthread programming question

I don't know any simple function that maps between pthread id and lwp id. Another process can see the mapping for stopped lwp's using ttrace() with TT_PROC_GET_FIRST_LWP_STATE and TT_PROC_GET_NEXT_LWP_STATE.
You can get much information about each lwp with the pstat_getlwp() function.
Be aware that their may not be a one-to-one mapping between pthread and lwp. Starting with the 11.22 release, there will be support for PTHREAD_SCOPE_PROCESS in pthread_attr_setscope(), so multiple pthreads may share a small pool of lwps.
Laurent de Segur
Occasional Contributor

Re: pthread programming question

Mike,

Thanks for the answer. I was not aware about lwp processes on HP-UX. Are they equivalent/compatible with lpw on Solaris. Any pointer to lwp documentation on HP-UX is greatly appreciated.

TIA,

LdS
Mike Stroyan
Honored Contributor

Re: pthread programming question

There is quite a bit of background information on lwps in the "HP-UX Process Management
White Paper" at
http://docs.hp.com/hpux/onlinedocs/5965-4642/5965-4642.html

The document dates back to HP-UX 10.30 five years ago. The threading model hasn't really changed except for the recent 11.22 implementation of the MxN model described there.
Laurent de Segur
Occasional Contributor

Re: pthread programming question

I would like to determine if a thread has run by looking at some struct data. So far, I've look in the pthread np calls without much luck. There seems to be no places to get some state on what was the last time a thread was scheduled and running. I suppose that I could use the pthread_getstate_np to get the mcontext then checking the state of the regs, but invoking this symbol from my shlib, the runtime dld is unable to locate the lib with the symbol (libpthread.1?)

Thanks for your help in advance,

LdS
harry d brown jr
Honored Contributor

Re: pthread programming question