linux, os::current_thread_id() vs os::Linux::gettid()
David Holmes
david.holmes at oracle.com
Tue Aug 26 03:57:57 UTC 2014
On 26/08/2014 1:46 PM, David Holmes wrote:
> 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.
Sorry misunderstood your comment. Yes other platforms currently use the
same low-level thread id for the OSThread and os::current_thread_id(). I
suspect if you could look back in time that Solaris would have also had
different usages eg for LWP id versus user-level thread id.
David
-----
>> 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