Spin Loop Hint support: Draft JEP proposal
peter.levart at gmail.com
Mon Oct 5 14:59:12 UTC 2015
On 10/05/2015 11:41 AM, Andrew Haley wrote:
> Hi Gil,
> On 04/10/15 17:22, Gil Tene wrote:
>> Add an API that would allow Java code to hint that a spin loop is
>> being executed.
> I don't think this will work for ARM, which has a rather different
> spinlock mechanism.
> Instead of PAUSE, we wait on a lock word with WFE. WFE puts a core
> into a lightweight sleep state waiting on a particular address (the
> lock word) and a write to the lock word wakes it up. This is very
> useful and somewhat analogous to 86's MONITOR/MWAIT.
> I can't immediately see how to generalize your proposal to ARM, which
> is a shame.
Just a thought...
ARM WaitForEvent/SendEvent instructions sound like a kind of
park/unpark, but on a CPU-core-level (WFE) and global system-level
(SendEvent). I wonder whether it would be possible to use them to
optimize the latency of the implementation of park/unpark. The same goes
for Spin Loop Hint. Would it be possible to incorporate spin-looping in
the park/unpark implementation for x86 itself? Higher-level
synchronization constructs (like locks, synchronizers, etc..) would then
just use park/unpark and not bother with spin-looping themselves.
More information about the core-libs-dev