Browse Source

!9727 [MSLITE]fix thread pool bug

From: @zhang_xue_tong
Reviewed-by: @hangangqiang,@zhanghaibo5
Signed-off-by: @hangangqiang
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
f85c6472be
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      mindspore/lite/src/runtime/thread_pool.c

+ 3
- 3
mindspore/lite/src/runtime/thread_pool.c View File

@@ -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 {


Loading…
Cancel
Save