Description
The method os::yield_all() has been, and is still, the source of many problems.
The first issue comes from its specification:
static void yield_all(); // Yields to all other threads including lower priority
The semantic specified in the comment is extremely strong, so strong that it is almost
impossible to implement it on most OSes/configurations HotSpot officially supports. But
due to the appealing comment, the method is still used based on the behavior suggested
in the comment.
The second issue comes from the differences in the OS-specific implementations. On most
platforms, os::yield_all() is implemented with a sched_yield() system call. But on Solaris, it
is implemented wit the os::sleep() method, which causes a ThreadState transition that doesn't
exist on other platforms.
Regarding the semantic issue and the implementation issue, I suggest to remove the os::yield_all()
method and replace its usages by explicit calls to os::naked_short_sleep() or os::NakedYield().
The first issue comes from its specification:
static void yield_all(); // Yields to all other threads including lower priority
The semantic specified in the comment is extremely strong, so strong that it is almost
impossible to implement it on most OSes/configurations HotSpot officially supports. But
due to the appealing comment, the method is still used based on the behavior suggested
in the comment.
The second issue comes from the differences in the OS-specific implementations. On most
platforms, os::yield_all() is implemented with a sched_yield() system call. But on Solaris, it
is implemented wit the os::sleep() method, which causes a ThreadState transition that doesn't
exist on other platforms.
Regarding the semantic issue and the implementation issue, I suggest to remove the os::yield_all()
method and replace its usages by explicit calls to os::naked_short_sleep() or os::NakedYield().