linux, os::current_thread_id() vs os::Linux::gettid()

David Holmes david.holmes at oracle.com
Tue Aug 26 03:46:54 UTC 2014


Hi Thomas,

On 26/08/2014 12:55 AM, Thomas Stüfe wrote:
> Hi,
>
> I wonder about the implementation of os::current_thread_id() on Linux.
>
> There is os::Linux::gettid() and os::current_thread_id().
> os::Linux::gettid() returns the kernel thread id, os::current_thread_id()
> returns the pthread id.
>
> os::Linux::gettid() is used to initialize OSThread::_thread_id, so that
> contains the kernel thread id. So now we get conflicting information from
> OSThread::thread_id and os::current_thread_id().
>
> As far as I see, all other platforms consistently return the kernel thread
> id on both code paths.

Only AIX and BSD have gettid and both those ports were based on the 
Linux code.

> Am I overlooking something or is this behaviour intentional?

Intentional but historical, going back to old LinuxThreads. Probably one 
of many cleanups that can be done in the linux code.

David

>
> Kind Regards,
>
> ..Thomas
>


More information about the hotspot-dev mailing list