1833429 Members
2997 Online
110052 Solutions
New Discussion

pthread_create

 
Murali_12
Occasional Contributor

pthread_create

On HP-UX 11.0, I am using the pthread_create system call to create new threads on our application. But the pthread_create function returns the thread id in negative ( for example -1342).Any one can shed some light on this as why the thread ids are in negative?

Thanks,
Murali
5 REPLIES 5
Kent Ostby
Honored Contributor

Re: pthread_create

Well, with any type of unexpected system call behavior, I'd check your types and make sure you are making the call with matching data types.

Is it the thread that is being set to -1342 or is it the error status ?

The issue you mention does match any known problems about this call within HP-UX that I can find.

Best regards,

Kent M. Ostby
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Umapathy S
Honored Contributor

Re: pthread_create

Murali,
Can you shed some more info on this.

Is the application stops/suspends anywhere? Any core dump is created? Is the pthread_create() call completly fails.
If there is no other problem, then something something undefined is happening.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Vitek Pepas
Valued Contributor

Re: pthread_create

I agree with Kent. Check your source code. pthread_create returns 0 when successful or positive error number otherwise.
aparna challagulla
Valued Contributor

Re: pthread_create

hi murali,

can u post the code where u r creating/accessing the thread.
and yes try to catch the return code of the function.
and how r u trying to access the id in the code.

aparna
If you don't have time to do it right you must have time to do it over
Zeev Schultz
Honored Contributor

Re: pthread_create

As I assume this is a double post I repost my
suggestion to the fisrt (bad?) one:

Set a watchpoint with debugger and check how pthread_create return value changes.man pthread_create for error return values (not negative).
How to set watchpoints with GDB for example:
http://www.gnu.org/manual/gdb-5.1.1/html_node/gdb_29.html
So computers don't think yet. At least not chess computers. - Seymour Cray