src/app/jdk/lib/jvm/os_genode.cpp
// Handler function invoked when a thread's execution is suspended or
// resumed. We have to be careful that only async-safe functions are
// called here (Note: most pthread functions are not async safe and
// should be avoided.)
//
// Note: sigwait() is a more natural fit than sigsuspend() from an
// interface point of view, but sigwait() prevents the signal hander
// from being run. libpthread would get very confused by not having
// its signal handlers run and prevents sigwait()'s use with the
// mutex granting granting signal.
//
// Currently only ever called on the VMThread or JavaThread
//
Handler function invoked when a thread's execution is suspended or
resumed. We have to be careful that only async-safe functions are
called here (Note: most pthread functions are not async safe and
should be avoided.)

sigwait() is a more natural fit than sigsuspend() from an
interface point of view, but sigwait() prevents the signal hander
from being run. libpthread would get very confused by not having
its signal handlers run and prevents sigwait()'s use with the
mutex granting granting signal.

Currently only ever called on the VMThread or JavaThread
Handler function invoked when a thread ' s execution is suspended or resumed . We have to be careful that only async - safe functions are called here ( Note : most pthread functions are not async safe and should be avoided . ) sigwait () is a more natural fit than sigsuspend () from an interface point of view but sigwait () prevents the signal hander from being run . libpthread would get very confused by not having its signal handlers run and prevents sigwait () ' s use with the mutex granting granting signal . Currently only ever called on the VMThread or JavaThread
static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
  int old_errno = errno;
  Thread* thread = Thread::current_or_null_safe();
  assert(thread != NULL, "Missing current thread in SR_handler");
  if (thread->SR_lock() == NULL) {
    return;
  }
  assert(thread->is_VM_thread() || thread->is_Java_thread(), "Must be VMThread or JavaThread");
  OSThread* osthread = thread->osthread();
  os::SuspendResume::State current = osthread->sr.state();
  if (current == os::SuspendResume::SR_SUSPEND_REQUEST) {
    suspend_save_context(osthread, siginfo, context);
    os::SuspendResume::State state = osthread->sr.suspended();
    if (state == os::SuspendResume::SR_SUSPENDED) {
      sigset_t suspend_set;  
      pthread_sigmask(SIG_BLOCK, NULL, &suspend_set);
      sigdelset(&suspend_set, SR_signum);
      sr_semaphore.signal();
      while (1) {
        sigsuspend(&suspend_set);
        os::SuspendResume::State result = osthread->sr.running();
        if (result == os::SuspendResume::SR_RUNNING) {
          sr_semaphore.signal();
          break;
        } else if (result != os::SuspendResume::SR_SUSPENDED) {
          ShouldNotReachHere();
        }
      }
    } else if (state == os::SuspendResume::SR_RUNNING) {
    } else {
      ShouldNotReachHere();
    }
    resume_clear_context(osthread);
  } else if (current == os::SuspendResume::SR_RUNNING) {
  } else if (current == os::SuspendResume::SR_WAKEUP_REQUEST) {
  } else {
  }
  errno = old_errno;
}
static void SR_handler ( int sig , siginfo_t * siginfo , ucontext_t * context ) { int old_errno = errno ; Thread * thread = Thread :: current_or_null_safe ( ) ; assert ( thread != NULL , " " ) ; if ( thread -> SR_lock ( ) == NULL ) { return ; } assert ( thread -> is_VM_thread ( ) || thread -> is_Java_thread ( ) , " " ) ; OSThread * osthread = thread -> osthread ( ) ; os :: SuspendResume :: State current = osthread -> sr . state ( ) ; if ( current == os :: SuspendResume :: SR_SUSPEND_REQUEST ) { suspend_save_context ( osthread , siginfo , context ) ; os :: SuspendResume :: State state = osthread -> sr . suspended ( ) ; if ( state == os :: SuspendResume :: SR_SUSPENDED ) { sigset_t suspend_set ; pthread_sigmask ( SIG_BLOCK , NULL , & suspend_set ) ; sigdelset ( & suspend_set , SR_signum ) ; sr_semaphore . signal ( ) ; while ( 1 ) { sigsuspend ( & suspend_set ) ; os :: SuspendResume :: State result = osthread -> sr . running ( ) ; if ( result == os :: SuspendResume :: SR_RUNNING ) { sr_semaphore . signal ( ) ; break ; } else if ( result != os :: SuspendResume :: SR_SUSPENDED ) { ShouldNotReachHere ( ) ; } } } else if ( state == os :: SuspendResume :: SR_RUNNING ) { } else { ShouldNotReachHere ( ) ; } resume_clear_context ( osthread ) ; } else if ( current == os :: SuspendResume :: SR_RUNNING ) { } else if ( current == os :: SuspendResume :: SR_WAKEUP_REQUEST ) { } else { } errno = old_errno ; }
Handler function invoked when a thread's execution is suspended or
resumed.
Handler function invoked when a thread ' s execution is suspended or resumed .
// Save and restore errno to avoid confusing native code with EINTR // after sigsuspend. // On some systems we have seen signal delivery get "stuck" until the signal // mask is changed as part of thread termination. Check that the current thread // has not already terminated (via SR_lock()) - else the following assertion // will fail because the thread is no longer a JavaThread as the ~JavaThread // destructor has completed. // attempt to switch the state, we assume we had a SUSPEND_REQUEST // signals for sigsuspend() // get current set of blocked signals and unblock resume signal // wait here until we are resumed // request was cancelled, continue // request was cancelled, continue // ignore // ignore