hotspot/src/os/bsd/vm/os_bsd.cpp
changeset 40377 b77bf599c11b
parent 40010 e32d5e545789
child 40655 9f644073d3a0
equal deleted inserted replaced
40376:15e772ff7ff4 40377:b77bf599c11b
  2714 //        and blocks in sigsuspend until continued
  2714 //        and blocks in sigsuspend until continued
  2715 //  - resume:
  2715 //  - resume:
  2716 //      - sets target osthread state to continue
  2716 //      - sets target osthread state to continue
  2717 //      - sends signal to end the sigsuspend loop in the SR_handler
  2717 //      - sends signal to end the sigsuspend loop in the SR_handler
  2718 //
  2718 //
  2719 //  Note that the SR_lock plays no role in this suspend/resume protocol.
  2719 //  Note that the SR_lock plays no role in this suspend/resume protocol,
       
  2720 //  but is checked for NULL in SR_handler as a thread termination indicator.
  2720 
  2721 
  2721 static void resume_clear_context(OSThread *osthread) {
  2722 static void resume_clear_context(OSThread *osthread) {
  2722   osthread->set_ucontext(NULL);
  2723   osthread->set_ucontext(NULL);
  2723   osthread->set_siginfo(NULL);
  2724   osthread->set_siginfo(NULL);
  2724 }
  2725 }
  2744 static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
  2745 static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
  2745   // Save and restore errno to avoid confusing native code with EINTR
  2746   // Save and restore errno to avoid confusing native code with EINTR
  2746   // after sigsuspend.
  2747   // after sigsuspend.
  2747   int old_errno = errno;
  2748   int old_errno = errno;
  2748 
  2749 
  2749   Thread* thread = Thread::current();
  2750   Thread* thread = Thread::current_or_null_safe();
       
  2751   assert(thread != NULL, "Missing current thread in SR_handler");
       
  2752 
       
  2753   // On some systems we have seen signal delivery get "stuck" until the signal
       
  2754   // mask is changed as part of thread termination. Check that the current thread
       
  2755   // has not already terminated (via SR_lock()) - else the following assertion
       
  2756   // will fail because the thread is no longer a JavaThread as the ~JavaThread
       
  2757   // destructor has completed.
       
  2758 
       
  2759   if (thread->SR_lock() == NULL) {
       
  2760     return;
       
  2761   }
       
  2762 
       
  2763   assert(thread->is_VM_thread() || thread->is_Java_thread(), "Must be VMThread or JavaThread");
       
  2764 
  2750   OSThread* osthread = thread->osthread();
  2765   OSThread* osthread = thread->osthread();
  2751   assert(thread->is_VM_thread() || thread->is_Java_thread(), "Must be VMThread or JavaThread");
       
  2752 
  2766 
  2753   os::SuspendResume::State current = osthread->sr.state();
  2767   os::SuspendResume::State current = osthread->sr.state();
  2754   if (current == os::SuspendResume::SR_SUSPEND_REQUEST) {
  2768   if (current == os::SuspendResume::SR_SUSPEND_REQUEST) {
  2755     suspend_save_context(osthread, siginfo, context);
  2769     suspend_save_context(osthread, siginfo, context);
  2756 
  2770