#include #include int testvar; int done; #define barrier() __asm__ __volatile__("" ::: "memory") void *thread_start(void *arg) { while (!done) { if (testvar == 1) testvar = 0; barrier(); } return arg; } int main(void) { pthread_t thr; int ret; ret = pthread_create(&thr, NULL, thread_start, NULL); if (ret != 0) fprintf(stderr, "pthread_create: error %d\n", ret); while (!done) { if (testvar == 0) testvar = 1; barrier(); } return 0; }