RFR for JDK-8031374: java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java fails Intermittently
Martin Buchholz
martinrb at google.com
Mon Feb 24 16:54:29 UTC 2014
On Sun, Feb 23, 2014 at 2:59 PM, David Holmes <david.holmes at oracle.com>wrote:
>
>
> For Martin's benefit, while Thread.yield was always assumed to do the
> right thing and act as reasonably expected, that got broken by the Linux
> folks with CFS at one point. So loops involving yield are out of favour.
>
Following up a bit ... when I call Thread.yield, I am generally fine with
continuing to run if there is no other process available to claim the CPU,
so the new Linux CFS behavior is what I was always coding for. hotspot
engineers could implement Thread.yield by calling nanosleep(0), as
suggested by the code snippet below, but I think that would be bad - I'm
happy with the Linux CFS behavior.
// Short sleep, direct OS call.
//
// Note: certain versions of Linux CFS scheduler (since 2.6.23) do not
guarantee
// sched_yield(2) will actually give up the CPU:
//
// * Alone on this pariticular CPU, keeps running.
// * Before the introduction of "skip_buddy" with "compat_yield" disabled
// (pre 2.6.39).
//
// So calling this with 0 is an alternative.
More information about the core-libs-dev
mailing list