help regarding 'thread allocation to cores' - in hotspot jvm

Y. Srinivas Ramakrishna y.s.ramakrishna at
Sun Nov 21 12:03:18 PST 2010

Hello Dhiraj --

For all practical purposes, the JVM leaves that up to the OS,
never explicitly binding threads to cores. In most cases,
the OS scheduler has more relevant data and certainly more
efficient policies to make a globally more optimal assignment
than a single JVM would. There are interfaces in the planning
stages that might allow specifying scheduling relationships to
help the OS further optimize those decisions but as far as i
know those are not completed yet.

If however you want to play with explicit thread-to-core binding
functionality, then you'll want to look at the code in
os::bind_to_processor() (which by the way is only implemented
in the case of Solaris at the moment), and never used by default
in the JVM. The code is currently only used by GC thread code
to bind specific threads to cores and, as far as i know,
has not been used extensively at all (but rather more as a
debug/special case mechanism so far; although of course i do not
by any means know how specific Solaris customers may be using
that functionality/capability).

To start exploring that code (which may well have bit-rotted since
it was first put in a number of years ago), search for BindCMSThreadToCPU
and BindGCTaskThreadsToCPUs; and go from there.

Anyway, FWIW ...
-- ramki

On 11/21/2010 6:07 AM, ddmetro wrote:
> Hi All,
> I am currently trying to figure out how hotspot jvm allocates thread to
> cores. I found code that creates compiler, vm and java threads as pthread
> and assigns priorities to them. I tried looking in the the 'os' and 'os_cpu'
> folders under 'src' folder of hotspot, however couldn't find anything
> related to - allocation of threads to cores.
> I expected to find this code in a folder by the name of 'i386' or 'i486'. I
> tried looking in the folder 'linux_x86', but couldn't find the required
> code.
> Question: Can someone direct me to the code (.cpp file) that handles thread
> allocation to cores?
> Platform: Linux - Ubuntu 10.04
> Thanking You,
> Dhiraj P.

More information about the hotspot-compiler-dev mailing list