1 #ifndef URCU_TESTS_DEBUG_YIELD_H
2 #define URCU_TESTS_DEBUG_YIELD_H
7 * Userspace RCU library tests - Debugging header
9 * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 * Copyright (c) 2009 Paul E. McKenney, IBM Corporation.
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 * IBM's contributions to this file may be relicensed under LGPLv2 or later.
34 #define RCU_YIELD_READ (1 << 0)
35 #define RCU_YIELD_WRITE (1 << 1)
38 * Updates with RCU_SIGNAL are much slower. Account this in the delay.
41 /* maximum sleep delay, in us */
42 #define MAX_SLEEP 30000
47 extern unsigned int rcu_yield_active
;
48 extern DECLARE_URCU_TLS(unsigned int, rcu_rand_yield
);
51 static inline void rcu_debug_yield_read(void)
53 if (rcu_yield_active
& RCU_YIELD_READ
)
54 if (rand_r(&URCU_TLS(rcu_rand_yield
)) & 0x1)
55 usleep(rand_r(&URCU_TLS(rcu_rand_yield
)) % MAX_SLEEP
);
58 static inline void rcu_debug_yield_write(void)
60 if (rcu_yield_active
& RCU_YIELD_WRITE
)
61 if (rand_r(&URCU_TLS(rcu_rand_yield
)) & 0x1)
62 usleep(rand_r(&URCU_TLS(rcu_rand_yield
)) % MAX_SLEEP
);
65 static inline void rcu_debug_yield_enable(unsigned int flags
)
67 rcu_yield_active
|= flags
;
70 static inline void rcu_debug_yield_disable(unsigned int flags
)
72 rcu_yield_active
&= ~flags
;
75 static inline void rcu_debug_yield_init(void)
77 URCU_TLS(rcu_rand_yield
) = time(NULL
) ^ (unsigned long) pthread_self();
79 #else /* DEBUG_YIELD */
80 static inline void rcu_debug_yield_read(void)
84 static inline void rcu_debug_yield_write(void)
88 static inline void rcu_debug_yield_enable(unsigned int flags
)
92 static inline void rcu_debug_yield_disable(unsigned int flags
)
96 static inline void rcu_debug_yield_init(void)
101 #endif /* URCU_TESTS_DEBUG_YIELD_H */
This page took 0.030895 seconds and 4 git commands to generate.