Mayank Jain(deleted)
|
Re: RE: API for unique thread-id in QNX
|
Mayank Jain(deleted)
06/01/2015 12:36 PM
post113890
|
Re: RE: API for unique thread-id in QNX
I tried below code as a cross-platform solution to obtain unique id and it appears to work on Linux, Mac and Windows
(maybe I'm lucky). On the other hand thread-ids are being reused after thread termination (join) in the same process on
QNX.
uint32_t MyGetTid (void)
{
uint32_t tid = ~0U;
#if defined(__linux__)
tid = syscall(SYS_gettid);
#elif defined(__APPLE__)
// Mac OS >= 10.6 has a system call equivalent to Linux's gettid()
tid = syscall(SYS_thread_selfid);
#elif defined _WIN32
tid = GetCurrentThreadId();
#elif defined(__ANDROID__)
tid = gettid();
#elif defined(__QNX__)
// FIXME: gettid() appears to reuse the thread-id on QNX
tid = gettid();
#endif
return tid;
}
|
|
|