summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/thread.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 9f8c90acc3..be1614b3cc 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -1467,11 +1467,13 @@ bool Thread::RequestSynchronousCheckpoint(Closure* function) {
{
ScopedThreadListLockUnlock stllu(self);
- ScopedThreadSuspension sts(self, ThreadState::kWaiting);
- while (GetState() == ThreadState::kRunnable) {
- // We became runnable again. Wait till the suspend triggered in ModifySuspendCount
- // moves us to suspended.
- sched_yield();
+ {
+ ScopedThreadSuspension sts(self, ThreadState::kWaiting);
+ while (GetState() == ThreadState::kRunnable) {
+ // We became runnable again. Wait till the suspend triggered in ModifySuspendCount
+ // moves us to suspended.
+ sched_yield();
+ }
}
function->Run(this);
@@ -1485,6 +1487,13 @@ bool Thread::RequestSynchronousCheckpoint(Closure* function) {
DCHECK(updated);
}
+ {
+ // Imitate ResumeAll, the thread may be waiting on Thread::resume_cond_ since we raised its
+ // suspend count. Now the suspend_count_ is lowered so we must do the broadcast.
+ MutexLock mu2(self, *Locks::thread_suspend_count_lock_);
+ Thread::resume_cond_->Broadcast(self);
+ }
+
return true; // We're done, break out of the loop.
}
}