summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
cf380c2)
Add randomness to allow 1/2 odds that the yield will be done.
This lets some paths go quickly and others not.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+unsigned int yield_active;
+unsigned int __thread rand_yield;
#endif
static struct reader_data *reader_data;
#endif
static struct reader_data *reader_data;
#define YIELD_READ (1 << 0)
#define YIELD_WRITE (1 << 1)
#define YIELD_READ (1 << 0)
#define YIELD_WRITE (1 << 1)
-extern int yield_active;
+extern unsigned int yield_active;
+extern unsigned int __thread rand_yield;
static inline void debug_yield_read(void)
{
if (yield_active & YIELD_READ)
static inline void debug_yield_read(void)
{
if (yield_active & YIELD_READ)
+ if (rand_r(&rand_yield) & 0x1)
+ sched_yield();
}
static inline void debug_yield_write(void)
{
if (yield_active & YIELD_WRITE)
}
static inline void debug_yield_write(void)
{
if (yield_active & YIELD_WRITE)
+ if (rand_r(&rand_yield) & 0x1)
+ sched_yield();
+}
+
+static inline void debug_yield_init(void)
+{
+ rand_yield = time(NULL) ^ pthread_self();
}
#else
static inline void debug_yield_read(void)
}
#else
static inline void debug_yield_read(void)
static inline void debug_yield_write(void)
{
static inline void debug_yield_write(void)
{
+}
+
+static inline void debug_yield_init(void)
+{
+