Reputation: 490
I just read IEEE Std 1003.1™, 2004 Edition (POSIX spec.) to make sure what is actual thread ID on mac osx. In RATIONALE section of pthread_equal() of POSIX SPEC says:
Implementation may choose to define a thread ID as a structure. This allows additional flexibility and robustness over using an int. for example a thread ID could include a sequence number that allows detection of "dangling IDs" copies of a thread ID that has been detected). Since the C language does not support comparison on structure typs the pthread_equal() function is provided to compare thread IDs.
In Mac OSX, pthread_t is defined as a pointer to the structure named '_opaque_pthread_t' which has 3 members. __sig which is type long, __cleanup_stack which is a pointer to a structure, and __opaque which is array of type char.
My first questions are:
To find out an answer for my question, I googled and then I found this question:Mac/iPhone: Is there a way to get a thread identifier without using Objective-C? but it raises another question.
Another question is:
Upvotes: 4
Views: 4194
Reputation: 636
On OS X pthread_threadid_np, defined in pthread.h, can be used. Note the _np suffix suggests that it is an extension to POSIX.
Upvotes: 4