os::current_thread_id on Linux

Jeremy Manson jeremymanson at google.com
Wed Jul 22 22:01:20 UTC 2015

Based on the feedback, this seems to be a good idea, approximately.  Coleen
would have sponsored, but she's going on vacation.  Anyone else feel like


On Wed, Jul 22, 2015 at 11:22 AM, Jeremy Manson <jeremymanson at google.com>

> Hey folks,
> os::current_thread_id on Linux now maps to pthread_self.  The problem with
> pthread_self is that it only makes sense in the context of the running
> process.  When it is written out to the log (as it is in several places),
> there really isn't a way (AFAICT) for the user to map it back to anything
> useful.
> As it happens, that value is mostly used to write to the log.  The places
> where it doesn't do so don't seem to need to use pthread_self for any
> particular reason.
> Meanwhile, the SIGQUIT stack dump
> uses java_thread->osthread()->thread_id() as the nid.  On Linux, that maps
> back to os::Linux::gettid(), whish is also what gets exposed in /proc.
> That makes it much easier to see what threads might be doing the log write.
> Would it be okay to change os::current_thread_id to point
> to os::Linux::gettid()?  That way, it can be mapped back to the output of a
> SIGQUIT dump.
> The downside of gettid() is that it is only available on Linux>2.4.11, but
> that dates from 2001.  If we really still want to support it, we could
> check for that.
> Thoughts?
> Jeremy

More information about the hotspot-runtime-dev mailing list