Signed-off-by: Junchang Wang <junchangwang@xxxxxxxxx> --- CodeSamples/count/count_stat_eventual.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CodeSamples/count/count_stat_eventual.c b/CodeSamples/count/count_stat_eventual.c index cbde4aa..2caebfd 100644 --- a/CodeSamples/count/count_stat_eventual.c +++ b/CodeSamples/count/count_stat_eventual.c @@ -40,15 +40,15 @@ void *eventual(void *arg) int t; unsigned long sum; - while (stopflag < 3) { + while (READ_ONCE(stopflag) < 3) { sum = 0; for_each_thread(t) sum += READ_ONCE(per_thread(counter, t)); WRITE_ONCE(global_count, sum); poll(NULL, 0, 1); - if (stopflag) { + if (READ_ONCE(stopflag)) { smp_mb(); - stopflag++; + WRITE_ONCE(stopflag, READ_ONCE(stopflag) + 1); } } return NULL; @@ -66,8 +66,9 @@ void count_init(void) void count_cleanup(void) { - stopflag = 1; - while (stopflag < 3) + WRITE_ONCE(stopflag, 1); + smp_mb(); + while (READ_ONCE(stopflag) < 3) poll(NULL, 0, 1); smp_mb(); } -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe perfbook" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html