Message ID | ortu8ed0lk.fsf@lxoliva.fsfla.org |
---|---|
State | New |
Headers | show |
Series | libstdc++: testsuite: call sched_yield for nonpreemptive targets | expand |
On Tue, 21 Jun 2022 at 06:54, Alexandre Oliva via Libstdc++ <libstdc++@gcc.gnu.org> wrote: > > > As in the gcc testsuite, systems without preemptive multi-threading > require sched_yield calls to be placed at points in which a context > switch might be needed to enable the test to complete. I'll try to remember that, but will probably forget. Is this really the only affected test? > > Regstrapped on x86_64-linux-gnu, also tested with a cross to > aarch64-rtems6. Ok to install? OK, thanks.
On Jun 21, 2022, Jonathan Wakely <jwakely@redhat.com> wrote: > On Tue, 21 Jun 2022 at 06:54, Alexandre Oliva via Libstdc++ > <libstdc++@gcc.gnu.org> wrote: >> >> >> As in the gcc testsuite, systems without preemptive multi-threading >> require sched_yield calls to be placed at points in which a context >> switch might be needed to enable the test to complete. > I'll try to remember that, but will probably forget. Is this really > the only affected test? Yeah, the only one in libstdc++-v3/testsuite, as of gcc-11, which is what I've focused on for this project; I haven't gone through all fails on master to make sure they're unrelated. (This is holding up some filesystem-related patches, whose tests are failing for reasons not present in gcc-11, and some of the forward-ports needed significant rewriting.) libstdc++ has plenty of threading tests, but they involve sleeping or otherwise blocking, which offers a context switch opportunity even on non-preemptive multithreading systems. It's busy waits that require a sched_yield. The gcc testsuite has a handful of those; covered by a separate patch also posted last night.
diff --git a/libstdc++-v3/testsuite/30_threads/this_thread/60421.cc b/libstdc++-v3/testsuite/30_threads/this_thread/60421.cc index ad6f9aeffcc80..12dbeba1cc492 100644 --- a/libstdc++-v3/testsuite/30_threads/this_thread/60421.cc +++ b/libstdc++-v3/testsuite/30_threads/this_thread/60421.cc @@ -59,6 +59,7 @@ test02() while (!sleeping) { // Wait for the thread to start sleeping. + sched_yield (); } while (sleeping) {