qsbr: only mark reader thread as being waited for in contended case
[urcu.git] / urcu-qsbr.c
index c275b6670672de62fc76aed22ba432d6deea2b44..9b3210a6fde03412f401a68c54c5b073bdc357cd 100644 (file)
@@ -31,6 +31,7 @@
 #include <string.h>
 #include <errno.h>
 #include <poll.h>
+#include <unistd.h>
 
 #define BUILD_QSBR_LIB
 #include "urcu-qsbr-static.h"
@@ -114,10 +115,14 @@ static void wait_for_quiescent_state(void)
        for (index = registry; index < registry + num_readers; index++) {
                int wait_loops = 0;
 
+               if (likely(!rcu_gp_ongoing(&index->urcu_reader_status->qs_gp)))
+                       continue;
+       
                index->urcu_reader_status->gp_waiting = 1;
                while (rcu_gp_ongoing(&index->urcu_reader_status->qs_gp)) {
                        if (wait_loops++ == RCU_QS_ACTIVE_ATTEMPTS) {
-                               sched_yield();  /* ideally sched_yield_to() */
+                               /* adapted wait time, in us */
+                               usleep(LOAD_SHARED(index->urcu_reader_status->qs_time_delta_usec) / 4);
                                wait_loops = 0;
                        } else {
 #ifndef HAS_INCOHERENT_CACHES
This page took 0.024379 seconds and 4 git commands to generate.