[concurrency-interest] spinLoopHint() JEP draft discussion
aph at redhat.com
Thu Oct 8 14:27:47 EDT 2015
On 10/08/2015 06:50 PM, Hans Boehm wrote:
> My question about spinLoopHint() would be whether it can be defined
> in a way that it makes it useful across architectures. I vaguely
> remember seeing claims that even the x86 instructions are not
> implemented consistently enough to be easily usable in portable
> code. I have no idea (though I probably should) about ARM
> equivalents or the like.
There are ARM equivalents defined in the architecture, but I don't
know if they're much more than NOPs.
> It also seems to me that unbounded spin loops are almost always a
> bad idea. (If you've been spinning for 10 seconds, you should be
> sleeping instead. You might even be inadvertently scheduled against
> the thread you're waiting for. Since you're waiting anyway, you
> might as well keep track of how long you've been spinning.) But the
> idea here would be that this is the low-level primitive you use if
> you haven't been spinning for very long?
Right. I don't speak for Gil, but I don't think anyone is proposing
to do any more than adding this hint to the spin loops that people use
More information about the Concurrency-interest