annotate src/os/solaris/vm/osThread_solaris.cpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children cd3d6a6b95d9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 337
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 337
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 337
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 // no precompiled headers
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "runtime/atomic.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "runtime/handles.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "runtime/mutexLocker.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "runtime/os.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "runtime/osThread.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "runtime/safepoint.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "runtime/vmThread.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #ifdef TARGET_ARCH_x86
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 # include "assembler_x86.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #ifdef TARGET_ARCH_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 # include "assembler_sparc.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
39
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40 # include <signal.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Platform dependent initialization and cleanup
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 void OSThread::pd_initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _thread_id = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 sigemptyset(&_caller_sigmask);
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 _current_callback = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 _current_callback_lock = VM_Version::supports_compare_and_exchange() ? NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
52 : new Mutex(Mutex::suspend_resume, "Callback_lock", true);
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 _saved_interrupt_thread_state = _thread_new;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 _vm_created_thread = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 void OSThread::pd_destroy() {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Synchronous interrupt support
a61af66fc99e Initial load
duke
parents:
diff changeset
62 //
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // _current_callback == NULL no pending callback
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // == 1 callback_in_progress
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // == other value pointer to the pending callback
a61af66fc99e Initial load
duke
parents:
diff changeset
66 //
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // CAS on v8 is implemented by using a global atomic_memory_operation_lock,
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // which is shared by other atomic functions. It is OK for normal uses, but
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // dangerous if used after some thread is suspended or if used in signal
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // handlers. Instead here we use a special per-thread lock to synchronize
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // updating _current_callback if we are running on v8. Note in general trying
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // to grab locks after a thread is suspended is not safe, but it is safe for
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // updating _current_callback, because synchronous interrupt callbacks are
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // currently only used in:
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // 1. GetThreadPC_Callback - used by WatcherThread to profile VM thread
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // There is no overlap between the callbacks, which means we won't try to
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // grab a thread's sync lock after the thread has been suspended while holding
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // the same lock.
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // used after a thread is suspended
a61af66fc99e Initial load
duke
parents:
diff changeset
82 static intptr_t compare_and_exchange_current_callback (
a61af66fc99e Initial load
duke
parents:
diff changeset
83 intptr_t callback, intptr_t *addr, intptr_t compare_value, Mutex *sync) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 if (VM_Version::supports_compare_and_exchange()) {
274
f7e6d42d9323 6618886: Anonymous objects can be destructed immediately and so should not be used
xlu
parents: 0
diff changeset
85 return Atomic::cmpxchg_ptr(callback, addr, compare_value);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
86 } else {
274
f7e6d42d9323 6618886: Anonymous objects can be destructed immediately and so should not be used
xlu
parents: 0
diff changeset
87 MutexLockerEx ml(sync, Mutex::_no_safepoint_check_flag);
f7e6d42d9323 6618886: Anonymous objects can be destructed immediately and so should not be used
xlu
parents: 0
diff changeset
88 if (*addr == compare_value) {
f7e6d42d9323 6618886: Anonymous objects can be destructed immediately and so should not be used
xlu
parents: 0
diff changeset
89 *addr = callback;
f7e6d42d9323 6618886: Anonymous objects can be destructed immediately and so should not be used
xlu
parents: 0
diff changeset
90 return compare_value;
f7e6d42d9323 6618886: Anonymous objects can be destructed immediately and so should not be used
xlu
parents: 0
diff changeset
91 } else {
f7e6d42d9323 6618886: Anonymous objects can be destructed immediately and so should not be used
xlu
parents: 0
diff changeset
92 return callback;
f7e6d42d9323 6618886: Anonymous objects can be destructed immediately and so should not be used
xlu
parents: 0
diff changeset
93 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // used in signal handler
a61af66fc99e Initial load
duke
parents:
diff changeset
98 static intptr_t exchange_current_callback(intptr_t callback, intptr_t *addr, Mutex *sync) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 if (VM_Version::supports_compare_and_exchange()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 return Atomic::xchg_ptr(callback, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 } else {
274
f7e6d42d9323 6618886: Anonymous objects can be destructed immediately and so should not be used
xlu
parents: 0
diff changeset
102 MutexLockerEx ml(sync, Mutex::_no_safepoint_check_flag);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
103 intptr_t cb = *addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 *addr = callback;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return cb;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // one interrupt at a time. spin if _current_callback != NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
110 int OSThread::set_interrupt_callback(Sync_Interrupt_Callback * cb) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 int count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 while (compare_and_exchange_current_callback(
a61af66fc99e Initial load
duke
parents:
diff changeset
113 (intptr_t)cb, (intptr_t *)&_current_callback, (intptr_t)NULL, _current_callback_lock) != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 while (_current_callback != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 count++;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
117 if ((WarnOnStalledSpinLock > 0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
118 (count % WarnOnStalledSpinLock == 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 warning("_current_callback seems to be stalled: %p", _current_callback);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
122 os::yield_all(count);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // reset _current_callback, spin if _current_callback is callback_in_progress
a61af66fc99e Initial load
duke
parents:
diff changeset
129 void OSThread::remove_interrupt_callback(Sync_Interrupt_Callback * cb) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 int count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 while (compare_and_exchange_current_callback(
a61af66fc99e Initial load
duke
parents:
diff changeset
132 (intptr_t)NULL, (intptr_t *)&_current_callback, (intptr_t)cb, _current_callback_lock) != (intptr_t)cb) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
134 intptr_t p = (intptr_t)_current_callback;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 assert(p == (intptr_t)callback_in_progress ||
a61af66fc99e Initial load
duke
parents:
diff changeset
136 p == (intptr_t)cb, "wrong _current_callback value");
a61af66fc99e Initial load
duke
parents:
diff changeset
137 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
138 while (_current_callback != cb) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 count++;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
141 if ((WarnOnStalledSpinLock > 0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
142 (count % WarnOnStalledSpinLock == 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 warning("_current_callback seems to be stalled: %p", _current_callback);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
146 os::yield_all(count);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 void OSThread::do_interrupt_callbacks_at_interrupt(InterruptArguments *args) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 Sync_Interrupt_Callback * cb;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 cb = (Sync_Interrupt_Callback *)exchange_current_callback(
a61af66fc99e Initial load
duke
parents:
diff changeset
154 (intptr_t)callback_in_progress, (intptr_t *)&_current_callback, _current_callback_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 if (cb == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // signal is delivered too late (thread is masking interrupt signal??).
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // there is nothing we need to do because requesting thread has given up.
a61af66fc99e Initial load
duke
parents:
diff changeset
159 } else if ((intptr_t)cb == (intptr_t)callback_in_progress) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 fatal("invalid _current_callback state");
a61af66fc99e Initial load
duke
parents:
diff changeset
161 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 assert(cb->target()->osthread() == this, "wrong target");
a61af66fc99e Initial load
duke
parents:
diff changeset
163 cb->execute(args);
a61af66fc99e Initial load
duke
parents:
diff changeset
164 cb->leave_callback(); // notify the requester
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // restore original _current_callback value
a61af66fc99e Initial load
duke
parents:
diff changeset
168 intptr_t p;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 p = exchange_current_callback((intptr_t)cb, (intptr_t *)&_current_callback, _current_callback_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
170 assert(p == (intptr_t)callback_in_progress, "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // Called by the requesting thread to send a signal to target thread and
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // execute "this" callback from the signal handler.
a61af66fc99e Initial load
duke
parents:
diff changeset
175 int OSThread::Sync_Interrupt_Callback::interrupt(Thread * target, int timeout) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // Let signals to the vm_thread go even if the Threads_lock is not acquired
a61af66fc99e Initial load
duke
parents:
diff changeset
177 assert(Threads_lock->owned_by_self() || (target == VMThread::vm_thread()),
a61af66fc99e Initial load
duke
parents:
diff changeset
178 "must have threads lock to call this");
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 OSThread * osthread = target->osthread();
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // may block if target thread already has a pending callback
a61af66fc99e Initial load
duke
parents:
diff changeset
183 osthread->set_interrupt_callback(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 _target = target;
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 int rslt = thr_kill(osthread->thread_id(), os::Solaris::SIGasync());
a61af66fc99e Initial load
duke
parents:
diff changeset
188 assert(rslt == 0, "thr_kill != 0");
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 bool status = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
191 jlong t1 = os::javaTimeMillis();
a61af66fc99e Initial load
duke
parents:
diff changeset
192 { // don't use safepoint check because we might be the watcher thread.
a61af66fc99e Initial load
duke
parents:
diff changeset
193 MutexLockerEx ml(_sync, Mutex::_no_safepoint_check_flag);
a61af66fc99e Initial load
duke
parents:
diff changeset
194 while (!is_done()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 status = _sync->wait(Mutex::_no_safepoint_check_flag, timeout);
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // status == true if timed out
a61af66fc99e Initial load
duke
parents:
diff changeset
198 if (status) break;
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // update timeout
a61af66fc99e Initial load
duke
parents:
diff changeset
201 jlong t2 = os::javaTimeMillis();
a61af66fc99e Initial load
duke
parents:
diff changeset
202 timeout -= t2 - t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
203 t1 = t2;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // reset current_callback
a61af66fc99e Initial load
duke
parents:
diff changeset
208 osthread->remove_interrupt_callback(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 return status;
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 void OSThread::Sync_Interrupt_Callback::leave_callback() {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 if (!_sync->owned_by_self()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // notify requesting thread
a61af66fc99e Initial load
duke
parents:
diff changeset
216 MutexLockerEx ml(_sync, Mutex::_no_safepoint_check_flag);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 _is_done = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
218 _sync->notify_all();
a61af66fc99e Initial load
duke
parents:
diff changeset
219 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // Current thread is interrupted while it is holding the _sync lock, trying
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // to grab it again will deadlock. The requester will timeout anyway,
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // so just return.
a61af66fc99e Initial load
duke
parents:
diff changeset
223 _is_done = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // copied from synchronizer.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 void OSThread::handle_spinlock_contention(int tries) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 if (NoYieldsInMicrolock) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 if (tries > 10) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 os::yield_all(tries); // Yield to threads of any priority
a61af66fc99e Initial load
duke
parents:
diff changeset
234 } else if (tries > 5) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 os::yield(); // Yield to threads of same or higher priority
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }