diff --git a/mindspore/lite/src/runtime/thread_pool.c b/mindspore/lite/src/runtime/thread_pool.c index 14fb3be78b..ae20ee7f81 100644 --- a/mindspore/lite/src/runtime/thread_pool.c +++ b/mindspore/lite/src/runtime/thread_pool.c @@ -625,7 +625,7 @@ bool PopTaskFromQueue(Thread *thread, Task **task) { LOG_ERROR("thread is nullptr"); return false; } - if (thread->task_size == 0) { + if (atomic_load_explicit(&thread->task_size, memory_order_relaxed) == 0) { return false; } const int head_index = atomic_load_explicit(&thread->head, memory_order_relaxed); @@ -651,7 +651,7 @@ void WaitAllThread(struct ThreadPool *thread_pool) { LOG_ERROR("get thread failed, thread_id: %d", i); return; } - if (thread->task_size != 0) { + if (atomic_load_explicit(&thread->task_size, memory_order_acquire) != 0) { k_success_flag = false; break; } @@ -731,7 +731,7 @@ void ThreadRun(Thread *thread) { return; } task->func(task->content, thread_id); - atomic_fetch_sub_explicit(&thread->task_size, 1, memory_order_relaxed); + atomic_fetch_sub_explicit(&thread->task_size, 1, memory_order_release); spin_count = 0; sem_trywait(&thread->sem); } else {