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