{ \
thread_ready = true; \
for (int i = 0; i < ITER_COUNT; i++) \
- PRE var_##NAME POST; \
+ { \
+ sched_yield (); \
+ PRE var_##NAME POST; \
+ } \
return NULL; \
} \
\
return 1; \
} \
while (!thread_ready) \
- ; \
+ sched_yield (); \
for (int i = 0; i < ITER_COUNT; i++) \
- PRE var_##NAME POST; \
+ { \
+ PRE var_##NAME POST; \
+ sched_yield (); \
+ } \
pthread_join (thread_id, NULL); \
if (var_##NAME != (FINAL)) \
{ \
thread_ready = true; \
while (!thread_stop) \
{ \
+ sched_yield (); \
var_##NAME = (INIT1); \
+ sched_yield (); \
var_##NAME = (INIT2); \
+ sched_yield (); \
} \
return NULL; \
} \
} \
int num_1_pass = 0, num_1_fail = 0, num_2_pass = 0, num_2_fail = 0; \
while (!thread_ready) \
- ; \
+ sched_yield (); \
for (int i = 0; i < ITER_COUNT; i++) \
{ \
feclearexcept (FE_ALL_EXCEPT); \
feraiseexcept (BEXC); \
LHSTYPE r = (PRE var_##NAME POST); \
int rexc = fetestexcept (TEST_ALL_EXCEPT); \
+ sched_yield (); \
if (VALTEST1 (r)) \
{ \
if (rexc == ((BEXC) | (EXC1))) \
void **p = va;
if (*p) return *p;
sem1 = 1;
- while (!__atomic_load_n(&sem2, __ATOMIC_ACQUIRE));
+ while (!__atomic_load_n(&sem2, __ATOMIC_ACQUIRE))
+ sched_yield ();
// GCC used to RTL-CSE this and the first load, causing 0 to be returned
return *p;
}
pthread_t thr;
if (pthread_create(&thr, 0, f, &p))
return 2;
- while (!sem1);
+ while (!sem1)
+ sched_yield ();
__atomic_thread_fence(__ATOMIC_ACQUIRE);
p = &p;
__atomic_store_n(&sem2, 1, __ATOMIC_RELEASE);
void **p = va;
if (*p) return *p;
sem1 = 1;
- while (!sem2);
+ while (!sem2)
+ sched_yield ();
__atomic_thread_fence(__ATOMIC_ACQUIRE);
// GCC used to RTL-CSE this and the first load, causing 0 to be returned
return *p;
pthread_t thr;
if (pthread_create(&thr, 0, f, &p))
return 2;
- while (!sem1);
+ while (!sem1)
+ sched_yield ();
__atomic_thread_fence(__ATOMIC_ACQUIRE);
p = &p;
__atomic_thread_fence(__ATOMIC_RELEASE);
static void *f(void *va)
{
void **p = va;
- while (!__atomic_load_n(&sem1, __ATOMIC_ACQUIRE));
+ while (!__atomic_load_n(&sem1, __ATOMIC_ACQUIRE))
+ sched_yield ();
exit(!*p);
}
p = &p;
__atomic_store_n(&sem1, 1, __ATOMIC_RELEASE);
int r = -1;
- while (r < 0) asm("":"+r"(r));
+ while (r < 0)
+ {
+ sched_yield ();
+ asm("":"+r"(r));
+ }
return r;
}
case this to carry across the 32bit boundary. */
for (tmp2 = 0; tmp2 < 64; tmp2++)
{
+ sched_yield ();
+
/* Add 2 using the two different adds. */
tmp1 = __sync_add_and_fetch (&workspace, add1bit);
tmp3 = __sync_fetch_and_add (&workspace, add1bit);
for (tmp2 = 0; tmp2 < 64; tmp2++)
{
+ sched_yield ();
+
/* Subtract 2 using the two different subs. */
tmp1=__sync_sub_and_fetch (&workspace, add1bit);
tmp3=__sync_fetch_and_sub (&workspace, add1bit);
t, err);
};
+ sched_yield ();
+
#ifdef _WIN32
Sleep (5000);
#else
/* Stop please. */
__sync_lock_test_and_set (&doquit, 1ll);
+ sched_yield ();
+
for (t = 0; t < 3; t++)
{
err=pthread_join (threads[t], NULL);