#include <assert.h>
#include <limits.h>
#include <sched.h>
+#include <sys/time.h>
#include <compiler.h>
#include <arch.h>
struct urcu_reader_status {
unsigned long qs_gp;
unsigned long gp_waiting;
+ unsigned long qs_time_delta_usec;
+ struct timeval qs_time_last;
};
extern struct urcu_reader_status __thread urcu_reader_status;
static inline void _rcu_quiescent_state(void)
{
long gp_ctr;
+ struct timeval current_time;
smp_mb();
+ gettimeofday(¤t_time, NULL);
+ if (current_time.tv_sec - urcu_reader_status.qs_time_last.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);
+ urcu_reader_status.qs_time_last = current_time;
/*
* volatile accesses can be reordered by the compiler when put in the
* same expression.
static inline void _rcu_thread_online(void)
{
+ struct timeval current_time;
+
+ gettimeofday(¤t_time, NULL);
+ if (current_time.tv_sec - urcu_reader_status.qs_time_last.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);
+ 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));
smp_mb();
}
#include <string.h>
#include <errno.h>
#include <poll.h>
+#include <unistd.h>
#define BUILD_QSBR_LIB
#include "urcu-qsbr-static.h"
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));
wait_loops = 0;
} else {
#ifndef HAS_INCOHERENT_CACHES