X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=t%2Fread-to-pipe-async.c;h=b56a990ca15a4542fcd953d6e730beb40ede4b03;hp=26e39f7715077706e5e59dff5185c043c503f441;hb=28cacec42ffebeec281caae90065ee1af319dfa4;hpb=6d5a9bc27c167e06b83d56a75b4db4ecc017cd0d diff --git a/t/read-to-pipe-async.c b/t/read-to-pipe-async.c index 26e39f77..b56a990c 100644 --- a/t/read-to-pipe-async.c +++ b/t/read-to-pipe-async.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "../flist.h" @@ -230,6 +231,12 @@ static int write_work(struct work_item *work) return work->seq + 1; } +static void thread_exiting(struct thread_data *thread) +{ + __sync_fetch_and_add(&thread->done, 1); + pthread_cond_signal(&thread->done_cond); +} + static void *writer_fn(void *data) { struct writer_thread *wt = data; @@ -257,8 +264,7 @@ static void *writer_fn(void *data) seq = write_work(work); } - wt->thread.done = 1; - pthread_cond_signal(&wt->thread.done_cond); + thread_exiting(&wt->thread); return NULL; } @@ -360,14 +366,13 @@ static void *reader_fn(void *data) pthread_mutex_unlock(&rt->thread.lock); if (work) { - rt->busy = 1; + __sync_fetch_and_add(&rt->busy, 1); reader_work(work); - rt->busy = 0; + __sync_fetch_and_sub(&rt->busy, 1); } } - rt->thread.done = 1; - pthread_cond_signal(&rt->thread.done_cond); + thread_exiting(&rt->thread); return NULL; } @@ -468,7 +473,7 @@ static void exit_thread(struct thread_data *thread, void fn(struct writer_thread *), struct writer_thread *wt) { - thread->exit = 1; + __sync_fetch_and_add(&thread->exit, 1); pthread_cond_signal(&thread->cond); while (!thread->done) {