qsbr: adaptative usleep period
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Sat, 26 Sep 2009 22:19:27 +0000 (18:19 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Sat, 26 Sep 2009 22:19:27 +0000 (18:19 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
urcu-qsbr-static.h
urcu-qsbr.c

index d18fabd3cb55f1c6cedec6c78bd1753d7348add0..f1300f320cce2f0605f149a806ebe1e96c5c1464 100644 (file)
@@ -222,16 +222,16 @@ static inline void _rcu_read_unlock(void)
 static inline void _rcu_quiescent_state(void)
 {
        long gp_ctr;
-       struct timeval current_time;
+       struct timeval current_time, delta_time;
 
        smp_mb();
        gettimeofday(&current_time, NULL);
-       if (current_time.tv_sec - urcu_reader_status.qs_time_last.tv_sec >= 1)
+       timersub(&current_time, &urcu_reader_status.qs_time_last, &delta_time);
+       if (delta_time.tv_sec >= 1)
                _STORE_SHARED(urcu_reader_status.qs_time_delta_usec, 1000000);
        else
                _STORE_SHARED(urcu_reader_status.qs_time_delta_usec,
-                     (unsigned long)current_time.tv_usec
-                     - (unsigned long)urcu_reader_status.qs_time_last.tv_usec);
+                     (unsigned long)delta_time.tv_usec);
        urcu_reader_status.qs_time_last = current_time;
        /*
         * volatile accesses can be reordered by the compiler when put in the
@@ -259,15 +259,15 @@ static inline void _rcu_thread_offline(void)
 
 static inline void _rcu_thread_online(void)
 {
-       struct timeval current_time;
+       struct timeval current_time, delta_time;
 
        gettimeofday(&current_time, NULL);
-       if (current_time.tv_sec - urcu_reader_status.qs_time_last.tv_sec >= 1)
+       timersub(&current_time, &urcu_reader_status.qs_time_last, &delta_time);
+       if (delta_time.tv_sec >= 1)
                _STORE_SHARED(urcu_reader_status.qs_time_delta_usec, 1000000);
        else
                _STORE_SHARED(urcu_reader_status.qs_time_delta_usec,
-                     (unsigned long)current_time.tv_usec
-                     - (unsigned long)urcu_reader_status.qs_time_last.tv_usec);
+                     (unsigned long)delta_time.tv_usec);
        urcu_reader_status.qs_time_last = current_time;
        _STORE_SHARED(urcu_reader_status.qs_time_delta_usec, 0);
        _STORE_SHARED(urcu_reader_status.qs_gp, LOAD_SHARED(urcu_gp_ctr));
index 5f06bfaf523715e39c3625a3378666c87a012491..a71ee6631b2b9dce77748b98937bcc58238d3ad3 100644 (file)
@@ -119,7 +119,7 @@ static void wait_for_quiescent_state(void)
                while (rcu_gp_ongoing(&index->urcu_reader_status->qs_gp)) {
                        if (wait_loops++ == RCU_QS_ACTIVE_ATTEMPTS) {
                                /* adapted wait time, in us */
-                               usleep(LOAD_SHARED(index->urcu_reader_status->qs_time_delta_usec));
+                               usleep(LOAD_SHARED(index->urcu_reader_status->qs_time_delta_usec) / 4);
                                wait_loops = 0;
                        } else {
 #ifndef HAS_INCOHERENT_CACHES
This page took 0.028146 seconds and 4 git commands to generate.