blob: c92305f373afc1e5723490357c69ed25a86c78bb [file] [log] [blame]
Ian Rogers693ff612013-02-01 10:56:12 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_THREAD_INL_H_
18#define ART_RUNTIME_THREAD_INL_H_
Ian Rogers693ff612013-02-01 10:56:12 -080019
20#include "thread.h"
21
Bilyan Borisovbb661c02016-04-04 16:27:32 +010022#ifdef ART_TARGET_ANDROID
Andreas Gampe4382f1e2015-08-05 01:08:53 +000023#include <bionic_tls.h> // Access to our own TLS slot.
24#endif
25
Ian Rogers02ed4c02013-09-06 13:10:04 -070026#include <pthread.h>
27
Ian Rogers1eb512d2013-10-18 15:42:20 -070028#include "base/casts.h"
Ian Rogers693ff612013-02-01 10:56:12 -080029#include "base/mutex-inl.h"
Ian Rogers576ca0c2014-06-06 15:58:22 -070030#include "gc/heap.h"
Ian Rogers68d8b422014-07-17 11:09:10 -070031#include "jni_env_ext.h"
David Sehrf42eb2c2016-10-19 13:20:45 -070032#include "runtime.h"
Mathieu Chartier3cf22532015-07-09 15:15:09 -070033#include "thread_pool.h"
Ian Rogers693ff612013-02-01 10:56:12 -080034
35namespace art {
36
Ian Rogers1eb512d2013-10-18 15:42:20 -070037// Quickly access the current thread from a JNIEnv.
38static inline Thread* ThreadForEnv(JNIEnv* env) {
39 JNIEnvExt* full_env(down_cast<JNIEnvExt*>(env));
40 return full_env->self;
41}
42
Ian Rogers02ed4c02013-09-06 13:10:04 -070043inline Thread* Thread::Current() {
Mathieu Chartier2cebb242015-04-21 16:50:40 -070044 // We rely on Thread::Current returning null for a detached thread, so it's not obvious
Ian Rogers02ed4c02013-09-06 13:10:04 -070045 // that we can replace this with a direct %fs access on x86.
46 if (!is_started_) {
Mathieu Chartier2cebb242015-04-21 16:50:40 -070047 return nullptr;
Ian Rogers02ed4c02013-09-06 13:10:04 -070048 } else {
Bilyan Borisovbb661c02016-04-04 16:27:32 +010049#ifdef ART_TARGET_ANDROID
Andreas Gampe4382f1e2015-08-05 01:08:53 +000050 void* thread = __get_tls()[TLS_SLOT_ART_THREAD_SELF];
51#else
Ian Rogers02ed4c02013-09-06 13:10:04 -070052 void* thread = pthread_getspecific(Thread::pthread_key_self_);
Andreas Gampe4382f1e2015-08-05 01:08:53 +000053#endif
Ian Rogers02ed4c02013-09-06 13:10:04 -070054 return reinterpret_cast<Thread*>(thread);
55 }
56}
57
Ian Rogers7b078e82014-09-10 14:44:24 -070058inline void Thread::AllowThreadSuspension() {
59 DCHECK_EQ(Thread::Current(), this);
60 if (UNLIKELY(TestAllFlags())) {
61 CheckSuspend();
62 }
Mathieu Chartiera59d9b22016-09-26 18:13:17 -070063 // Invalidate the current thread's object pointers (ObjPtr) to catch possible moving GC bugs due
64 // to missing handles.
Mathieu Chartier3f7f03c2016-09-26 11:39:52 -070065 PoisonObjectPointers();
Ian Rogers7b078e82014-09-10 14:44:24 -070066}
67
68inline void Thread::CheckSuspend() {
69 DCHECK_EQ(Thread::Current(), this);
70 for (;;) {
71 if (ReadFlag(kCheckpointRequest)) {
72 RunCheckpointFunction();
73 } else if (ReadFlag(kSuspendRequest)) {
74 FullSuspendCheck();
Hiroshi Yamauchi30493242016-11-03 13:06:52 -070075 } else if (ReadFlag(kEmptyCheckpointRequest)) {
76 RunEmptyCheckpoint();
77 } else {
78 break;
79 }
80 }
81}
82
83inline void Thread::CheckEmptyCheckpoint() {
84 DCHECK_EQ(Thread::Current(), this);
85 for (;;) {
86 if (ReadFlag(kEmptyCheckpointRequest)) {
87 RunEmptyCheckpoint();
Ian Rogers7b078e82014-09-10 14:44:24 -070088 } else {
89 break;
90 }
91 }
92}
93
Ian Rogersc0fa3ad2013-02-05 00:11:55 -080094inline ThreadState Thread::SetState(ThreadState new_state) {
Yu Lieac44242015-06-29 10:50:03 +080095 // Should only be used to change between suspended states.
96 // Cannot use this code to change into or from Runnable as changing to Runnable should
97 // fail if old_state_and_flags.suspend_request is true and changing from Runnable might
98 // miss passing an active suspend barrier.
Ian Rogersc0fa3ad2013-02-05 00:11:55 -080099 DCHECK_NE(new_state, kRunnable);
Andreas Gampeef048f62014-11-25 22:12:27 -0800100 if (kIsDebugBuild && this != Thread::Current()) {
101 std::string name;
102 GetThreadName(name);
103 LOG(FATAL) << "Thread \"" << name << "\"(" << this << " != Thread::Current()="
104 << Thread::Current() << ") changing state to " << new_state;
105 }
Chris Dearman59cde532013-12-04 18:53:49 -0800106 union StateAndFlags old_state_and_flags;
Ian Rogersdd7624d2014-03-14 17:43:00 -0700107 old_state_and_flags.as_int = tls32_.state_and_flags.as_int;
Yu Lieac44242015-06-29 10:50:03 +0800108 CHECK_NE(old_state_and_flags.as_struct.state, kRunnable);
Ian Rogersdd7624d2014-03-14 17:43:00 -0700109 tls32_.state_and_flags.as_struct.state = new_state;
Ian Rogersc0fa3ad2013-02-05 00:11:55 -0800110 return static_cast<ThreadState>(old_state_and_flags.as_struct.state);
111}
112
Mathieu Chartier10b218d2016-07-25 17:48:52 -0700113inline bool Thread::IsThreadSuspensionAllowable() const {
114 if (tls32_.no_thread_suspension != 0) {
115 return false;
116 }
117 for (int i = kLockLevelCount - 1; i >= 0; --i) {
118 if (i != kMutatorLock && GetHeldMutex(static_cast<LockLevel>(i)) != nullptr) {
119 return false;
120 }
121 }
122 return true;
123}
124
Ian Rogers693ff612013-02-01 10:56:12 -0800125inline void Thread::AssertThreadSuspensionIsAllowable(bool check_locks) const {
Ian Rogersf3d874c2014-07-17 18:52:42 -0700126 if (kIsDebugBuild) {
Nicolas Geoffraydb978712014-12-09 13:33:38 +0000127 if (gAborting == 0) {
128 CHECK_EQ(0u, tls32_.no_thread_suspension) << tlsPtr_.last_no_thread_suspension_cause;
129 }
Ian Rogersf3d874c2014-07-17 18:52:42 -0700130 if (check_locks) {
131 bool bad_mutexes_held = false;
132 for (int i = kLockLevelCount - 1; i >= 0; --i) {
133 // We expect no locks except the mutator_lock_ or thread list suspend thread lock.
Ian Rogers4ad5cd32014-11-11 23:08:07 -0800134 if (i != kMutatorLock) {
Ian Rogersf3d874c2014-07-17 18:52:42 -0700135 BaseMutex* held_mutex = GetHeldMutex(static_cast<LockLevel>(i));
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700136 if (held_mutex != nullptr) {
Ian Rogersf3d874c2014-07-17 18:52:42 -0700137 LOG(ERROR) << "holding \"" << held_mutex->GetName()
138 << "\" at point where thread suspension is expected";
139 bad_mutexes_held = true;
140 }
Ian Rogers693ff612013-02-01 10:56:12 -0800141 }
142 }
Nicolas Geoffraydb978712014-12-09 13:33:38 +0000143 if (gAborting == 0) {
144 CHECK(!bad_mutexes_held);
145 }
Ian Rogers693ff612013-02-01 10:56:12 -0800146 }
Ian Rogers693ff612013-02-01 10:56:12 -0800147 }
Ian Rogers693ff612013-02-01 10:56:12 -0800148}
149
Mathieu Chartier8ac9c912015-10-01 15:58:41 -0700150inline void Thread::TransitionToSuspendedAndRunCheckpoints(ThreadState new_state) {
Ian Rogers693ff612013-02-01 10:56:12 -0800151 DCHECK_NE(new_state, kRunnable);
Ian Rogers693ff612013-02-01 10:56:12 -0800152 DCHECK_EQ(GetState(), kRunnable);
153 union StateAndFlags old_state_and_flags;
154 union StateAndFlags new_state_and_flags;
Dave Allison0f5f6bb2013-11-22 17:39:19 -0800155 while (true) {
Ian Rogersdd7624d2014-03-14 17:43:00 -0700156 old_state_and_flags.as_int = tls32_.state_and_flags.as_int;
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700157 if (UNLIKELY((old_state_and_flags.as_struct.flags & kCheckpointRequest) != 0)) {
158 RunCheckpointFunction();
159 continue;
160 }
Hiroshi Yamauchi30493242016-11-03 13:06:52 -0700161 if (UNLIKELY((old_state_and_flags.as_struct.flags & kEmptyCheckpointRequest) != 0)) {
162 RunEmptyCheckpoint();
163 continue;
164 }
Dave Allison0f5f6bb2013-11-22 17:39:19 -0800165 // Change the state but keep the current flags (kCheckpointRequest is clear).
166 DCHECK_EQ((old_state_and_flags.as_struct.flags & kCheckpointRequest), 0);
Hiroshi Yamauchi30493242016-11-03 13:06:52 -0700167 DCHECK_EQ((old_state_and_flags.as_struct.flags & kEmptyCheckpointRequest), 0);
Dave Allison0f5f6bb2013-11-22 17:39:19 -0800168 new_state_and_flags.as_struct.flags = old_state_and_flags.as_struct.flags;
Ian Rogers693ff612013-02-01 10:56:12 -0800169 new_state_and_flags.as_struct.state = new_state;
Ian Rogersb8e087e2014-07-09 21:12:06 -0700170
Yu Lieac44242015-06-29 10:50:03 +0800171 // CAS the value with a memory ordering.
Ian Rogersb8e087e2014-07-09 21:12:06 -0700172 bool done =
Yu Lieac44242015-06-29 10:50:03 +0800173 tls32_.state_and_flags.as_atomic_int.CompareExchangeWeakRelease(old_state_and_flags.as_int,
Ian Rogersb8e087e2014-07-09 21:12:06 -0700174 new_state_and_flags.as_int);
175 if (LIKELY(done)) {
Dave Allison0f5f6bb2013-11-22 17:39:19 -0800176 break;
177 }
178 }
Mathieu Chartier8ac9c912015-10-01 15:58:41 -0700179}
Yu Lieac44242015-06-29 10:50:03 +0800180
Mathieu Chartier8ac9c912015-10-01 15:58:41 -0700181inline void Thread::PassActiveSuspendBarriers() {
Yu Lieac44242015-06-29 10:50:03 +0800182 while (true) {
183 uint16_t current_flags = tls32_.state_and_flags.as_struct.flags;
Hiroshi Yamauchi30493242016-11-03 13:06:52 -0700184 if (LIKELY((current_flags &
185 (kCheckpointRequest | kEmptyCheckpointRequest | kActiveSuspendBarrier)) == 0)) {
Yu Lieac44242015-06-29 10:50:03 +0800186 break;
187 } else if ((current_flags & kActiveSuspendBarrier) != 0) {
188 PassActiveSuspendBarriers(this);
189 } else {
190 // Impossible
Mathieu Chartier8ac9c912015-10-01 15:58:41 -0700191 LOG(FATAL) << "Fatal, thread transitioned into suspended without running the checkpoint";
Yu Lieac44242015-06-29 10:50:03 +0800192 }
193 }
Ian Rogers693ff612013-02-01 10:56:12 -0800194}
195
Mathieu Chartier8ac9c912015-10-01 15:58:41 -0700196inline void Thread::TransitionFromRunnableToSuspended(ThreadState new_state) {
197 AssertThreadSuspensionIsAllowable();
Mathieu Chartier3398c782016-09-30 10:27:43 -0700198 PoisonObjectPointersIfDebug();
Mathieu Chartier8ac9c912015-10-01 15:58:41 -0700199 DCHECK_EQ(this, Thread::Current());
200 // Change to non-runnable state, thereby appearing suspended to the system.
201 TransitionToSuspendedAndRunCheckpoints(new_state);
202 // Mark the release of the share of the mutator_lock_.
203 Locks::mutator_lock_->TransitionFromRunnableToSuspended(this);
204 // Once suspended - check the active suspend barrier flag
205 PassActiveSuspendBarriers();
206}
207
Ian Rogers693ff612013-02-01 10:56:12 -0800208inline ThreadState Thread::TransitionFromSuspendedToRunnable() {
Chris Dearman59cde532013-12-04 18:53:49 -0800209 union StateAndFlags old_state_and_flags;
Ian Rogersdd7624d2014-03-14 17:43:00 -0700210 old_state_and_flags.as_int = tls32_.state_and_flags.as_int;
Ian Rogers693ff612013-02-01 10:56:12 -0800211 int16_t old_state = old_state_and_flags.as_struct.state;
212 DCHECK_NE(static_cast<ThreadState>(old_state), kRunnable);
213 do {
214 Locks::mutator_lock_->AssertNotHeld(this); // Otherwise we starve GC..
Ian Rogersdd7624d2014-03-14 17:43:00 -0700215 old_state_and_flags.as_int = tls32_.state_and_flags.as_int;
Ian Rogers693ff612013-02-01 10:56:12 -0800216 DCHECK_EQ(old_state_and_flags.as_struct.state, old_state);
Yu Lieac44242015-06-29 10:50:03 +0800217 if (LIKELY(old_state_and_flags.as_struct.flags == 0)) {
218 // Optimize for the return from native code case - this is the fast path.
219 // Atomically change from suspended to runnable if no suspend request pending.
220 union StateAndFlags new_state_and_flags;
221 new_state_and_flags.as_int = old_state_and_flags.as_int;
222 new_state_and_flags.as_struct.state = kRunnable;
223 // CAS the value with a memory barrier.
224 if (LIKELY(tls32_.state_and_flags.as_atomic_int.CompareExchangeWeakAcquire(
225 old_state_and_flags.as_int,
226 new_state_and_flags.as_int))) {
227 // Mark the acquisition of a share of the mutator_lock_.
228 Locks::mutator_lock_->TransitionFromSuspendedToRunnable(this);
229 break;
230 }
231 } else if ((old_state_and_flags.as_struct.flags & kActiveSuspendBarrier) != 0) {
232 PassActiveSuspendBarriers(this);
Hiroshi Yamauchi30493242016-11-03 13:06:52 -0700233 } else if ((old_state_and_flags.as_struct.flags &
234 (kCheckpointRequest | kEmptyCheckpointRequest)) != 0) {
Yu Lieac44242015-06-29 10:50:03 +0800235 // Impossible
Mathieu Chartierdabdccc2015-10-01 14:46:29 -0700236 LOG(FATAL) << "Transitioning to runnable with checkpoint flag, "
237 << " flags=" << old_state_and_flags.as_struct.flags
238 << " state=" << old_state_and_flags.as_struct.state;
Yu Lieac44242015-06-29 10:50:03 +0800239 } else if ((old_state_and_flags.as_struct.flags & kSuspendRequest) != 0) {
Ian Rogers693ff612013-02-01 10:56:12 -0800240 // Wait while our suspend count is non-zero.
Nicolas Geoffray9f5f8ac2016-06-29 14:39:59 +0100241
242 // We pass null to the MutexLock as we may be in a situation where the
243 // runtime is shutting down. Guarding ourselves from that situation
244 // requires to take the shutdown lock, which is undesirable here.
245 Thread* thread_to_pass = nullptr;
246 if (kIsDebugBuild && !IsDaemon()) {
247 // We know we can make our debug locking checks on non-daemon threads,
248 // so re-enable them on debug builds.
249 thread_to_pass = this;
250 }
251 MutexLock mu(thread_to_pass, *Locks::thread_suspend_count_lock_);
Hiroshi Yamauchiee235822016-08-19 17:03:27 -0700252 ScopedTransitioningToRunnable scoped_transitioning_to_runnable(this);
Ian Rogersdd7624d2014-03-14 17:43:00 -0700253 old_state_and_flags.as_int = tls32_.state_and_flags.as_int;
Ian Rogers693ff612013-02-01 10:56:12 -0800254 DCHECK_EQ(old_state_and_flags.as_struct.state, old_state);
255 while ((old_state_and_flags.as_struct.flags & kSuspendRequest) != 0) {
256 // Re-check when Thread::resume_cond_ is notified.
Nicolas Geoffray9f5f8ac2016-06-29 14:39:59 +0100257 Thread::resume_cond_->Wait(thread_to_pass);
Ian Rogersdd7624d2014-03-14 17:43:00 -0700258 old_state_and_flags.as_int = tls32_.state_and_flags.as_int;
Ian Rogers693ff612013-02-01 10:56:12 -0800259 DCHECK_EQ(old_state_and_flags.as_struct.state, old_state);
260 }
261 DCHECK_EQ(GetSuspendCount(), 0);
262 }
Ian Rogers719d1a32014-03-06 12:13:39 -0800263 } while (true);
Yu Lieac44242015-06-29 10:50:03 +0800264 // Run the flip function, if set.
265 Closure* flip_func = GetFlipFunction();
266 if (flip_func != nullptr) {
267 flip_func->Run(this);
268 }
269 return static_cast<ThreadState>(old_state);
Ian Rogers693ff612013-02-01 10:56:12 -0800270}
271
Ian Rogers04d7aa92013-03-16 14:29:17 -0700272inline void Thread::VerifyStack() {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800273 if (kVerifyStack) {
274 if (Runtime::Current()->GetHeap()->IsObjectValidationEnabled()) {
275 VerifyStackImpl();
276 }
Ian Rogers04d7aa92013-03-16 14:29:17 -0700277 }
278}
279
Mathieu Chartiere6da9af2013-12-16 11:54:42 -0800280inline size_t Thread::TlabSize() const {
Ian Rogersdd7624d2014-03-14 17:43:00 -0700281 return tlsPtr_.thread_local_end - tlsPtr_.thread_local_pos;
Mathieu Chartier692fafd2013-11-29 17:24:40 -0800282}
283
Mathieu Chartiere6da9af2013-12-16 11:54:42 -0800284inline mirror::Object* Thread::AllocTlab(size_t bytes) {
285 DCHECK_GE(TlabSize(), bytes);
Ian Rogersdd7624d2014-03-14 17:43:00 -0700286 ++tlsPtr_.thread_local_objects;
287 mirror::Object* ret = reinterpret_cast<mirror::Object*>(tlsPtr_.thread_local_pos);
288 tlsPtr_.thread_local_pos += bytes;
Mathieu Chartier692fafd2013-11-29 17:24:40 -0800289 return ret;
290}
291
Hiroshi Yamauchif5b0e202014-02-11 17:02:22 -0800292inline bool Thread::PushOnThreadLocalAllocationStack(mirror::Object* obj) {
Ian Rogersdd7624d2014-03-14 17:43:00 -0700293 DCHECK_LE(tlsPtr_.thread_local_alloc_stack_top, tlsPtr_.thread_local_alloc_stack_end);
294 if (tlsPtr_.thread_local_alloc_stack_top < tlsPtr_.thread_local_alloc_stack_end) {
Hiroshi Yamauchif5b0e202014-02-11 17:02:22 -0800295 // There's room.
Ian Rogers13735952014-10-08 12:43:28 -0700296 DCHECK_LE(reinterpret_cast<uint8_t*>(tlsPtr_.thread_local_alloc_stack_top) +
Mathieu Chartiercb535da2015-01-23 13:50:03 -0800297 sizeof(StackReference<mirror::Object>),
Ian Rogers13735952014-10-08 12:43:28 -0700298 reinterpret_cast<uint8_t*>(tlsPtr_.thread_local_alloc_stack_end));
Mathieu Chartiercb535da2015-01-23 13:50:03 -0800299 DCHECK(tlsPtr_.thread_local_alloc_stack_top->AsMirrorPtr() == nullptr);
300 tlsPtr_.thread_local_alloc_stack_top->Assign(obj);
Ian Rogersdd7624d2014-03-14 17:43:00 -0700301 ++tlsPtr_.thread_local_alloc_stack_top;
Hiroshi Yamauchif5b0e202014-02-11 17:02:22 -0800302 return true;
303 }
304 return false;
305}
306
Mathieu Chartiercb535da2015-01-23 13:50:03 -0800307inline void Thread::SetThreadLocalAllocationStack(StackReference<mirror::Object>* start,
308 StackReference<mirror::Object>* end) {
Hiroshi Yamauchif5b0e202014-02-11 17:02:22 -0800309 DCHECK(Thread::Current() == this) << "Should be called by self";
310 DCHECK(start != nullptr);
311 DCHECK(end != nullptr);
Mathieu Chartiercb535da2015-01-23 13:50:03 -0800312 DCHECK_ALIGNED(start, sizeof(StackReference<mirror::Object>));
313 DCHECK_ALIGNED(end, sizeof(StackReference<mirror::Object>));
Hiroshi Yamauchif5b0e202014-02-11 17:02:22 -0800314 DCHECK_LT(start, end);
Ian Rogersdd7624d2014-03-14 17:43:00 -0700315 tlsPtr_.thread_local_alloc_stack_end = end;
316 tlsPtr_.thread_local_alloc_stack_top = start;
Hiroshi Yamauchif5b0e202014-02-11 17:02:22 -0800317}
318
319inline void Thread::RevokeThreadLocalAllocationStack() {
320 if (kIsDebugBuild) {
321 // Note: self is not necessarily equal to this thread since thread may be suspended.
322 Thread* self = Thread::Current();
323 DCHECK(this == self || IsSuspended() || GetState() == kWaitingPerformingGc)
324 << GetState() << " thread " << this << " self " << self;
325 }
Ian Rogersdd7624d2014-03-14 17:43:00 -0700326 tlsPtr_.thread_local_alloc_stack_end = nullptr;
327 tlsPtr_.thread_local_alloc_stack_top = nullptr;
Hiroshi Yamauchif5b0e202014-02-11 17:02:22 -0800328}
329
Mathieu Chartiera59d9b22016-09-26 18:13:17 -0700330inline void Thread::PoisonObjectPointersIfDebug() {
331 if (kIsDebugBuild) {
332 Thread::Current()->PoisonObjectPointers();
333 }
334}
335
Hiroshi Yamauchi02e7f1a2016-10-03 15:32:01 -0700336inline bool Thread::ModifySuspendCount(Thread* self,
337 int delta,
338 AtomicInteger* suspend_barrier,
339 bool for_debugger) {
340 if (delta > 0 && ((kUseReadBarrier && this != self) || suspend_barrier != nullptr)) {
341 // When delta > 0 (requesting a suspend), ModifySuspendCountInternal() may fail either if
342 // active_suspend_barriers is full or we are in the middle of a thread flip. Retry in a loop.
343 while (true) {
344 if (LIKELY(ModifySuspendCountInternal(self, delta, suspend_barrier, for_debugger))) {
345 return true;
346 } else {
347 // Failure means the list of active_suspend_barriers is full or we are in the middle of a
348 // thread flip, we should release the thread_suspend_count_lock_ (to avoid deadlock) and
349 // wait till the target thread has executed or Thread::PassActiveSuspendBarriers() or the
350 // flip function. Note that we could not simply wait for the thread to change to a suspended
351 // state, because it might need to run checkpoint function before the state change or
352 // resumes from the resume_cond_, which also needs thread_suspend_count_lock_.
353 //
354 // The list of active_suspend_barriers is very unlikely to be full since more than
355 // kMaxSuspendBarriers threads need to execute SuspendAllInternal() simultaneously, and
356 // target thread stays in kRunnable in the mean time.
357 Locks::thread_suspend_count_lock_->ExclusiveUnlock(self);
358 NanoSleep(100000);
359 Locks::thread_suspend_count_lock_->ExclusiveLock(self);
360 }
361 }
362 } else {
363 return ModifySuspendCountInternal(self, delta, suspend_barrier, for_debugger);
364 }
365}
366
Ian Rogers693ff612013-02-01 10:56:12 -0800367} // namespace art
368
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700369#endif // ART_RUNTIME_THREAD_INL_H_