FS#37816 - [gcc] G++ std::this_thread::yield is a no-op (and other issues)
Attached to Project:
Arch Linux
Opened by nightstrike (nightstrike) - Monday, 18 November 2013, 04:28 GMT
Last edited by Allan McRae (Allan) - Wednesday, 20 November 2013, 02:54 GMT
Opened by nightstrike (nightstrike) - Monday, 18 November 2013, 04:28 GMT
Last edited by Allan McRae (Allan) - Wednesday, 20 November 2013, 02:54 GMT
|
Details
Description:
GCC is not configured with --enable-libstdcxx-time. Therefore, yield() winds up being a no-op, instead of a call out to sched_yield(). In 4.9, this option should no longer be needed, but for 4.8 it is. If the option is added, it should be removed for 4.9. But please, build a 4.8 with this option in use so that I don't have to manually edit c++config.h. See: http://stackoverflow.com/a/12961816 Longer link: http://stackoverflow.com/questions/12523122/what-is-glibcxx-use-nanosleep-all-about Note that the particular configure option has several side effects, only one of which is the broken yield(). Additional info: * 4.7, 4.8 only |
This task depends upon
Closed by Allan McRae (Allan)
Wednesday, 20 November 2013, 02:54 GMT
Reason for closing: Won't implement
Wednesday, 20 November 2013, 02:54 GMT
Reason for closing: Won't implement
So what are you editing? In c++/4.8.2/x86_64-unknown-linux-gnu/bits/c++config.h I have (as expected in gcc-4.8.1+)
#define _GLIBCXX_USE_CLOCK_REALTIME 1
The latter makes std::this_thread::yield() turn into this:
/// yield
inline void
yield() noexcept
{
#ifdef _GLIBCXX_USE_SCHED_YIELD
__gthread_yield();
#endif
}
simplifying....
void yield() { }
So a yielding process never actually yields. Which means code compiled using your compiler can't use the yield from the C++ standard library, instead having to call out to the linux-specific sched_yield, which also requires pulling in all of sched.h into the global namespace -- hardly a good situation for anyone.
However, I am not enabling this configure due to it being a potential ABI breaker.