|
32 | 32 | #include "runtime/java.hpp" |
33 | 33 | #include "runtime/os.hpp" |
34 | 34 | #include "runtime/osThread.hpp" |
| 35 | +#include "runtime/semaphore.inline.hpp" |
35 | 36 | #include "runtime/stubRoutines.hpp" |
36 | 37 | #include "runtime/thread.hpp" |
37 | 38 | #include "signals_posix.hpp" |
@@ -369,27 +370,7 @@ static int check_pending_signals() { |
369 | 370 | return i; |
370 | 371 | } |
371 | 372 | } |
372 | | - JavaThread *thread = JavaThread::current(); |
373 | | - ThreadBlockInVM tbivm(thread); |
374 | | - |
375 | | - bool threadIsSuspended; |
376 | | - do { |
377 | | - thread->set_suspend_equivalent(); |
378 | | - // cleared by handle_special_suspend_equivalent_condition() or java_suspend_self() |
379 | | - sig_semaphore->wait(); |
380 | | - |
381 | | - // were we externally suspended while we were waiting? |
382 | | - threadIsSuspended = thread->handle_special_suspend_equivalent_condition(); |
383 | | - if (threadIsSuspended) { |
384 | | - // The semaphore has been incremented, but while we were waiting |
385 | | - // another thread suspended us. We don't want to continue running |
386 | | - // while suspended because that would surprise the thread that |
387 | | - // suspended us. |
388 | | - sig_semaphore->signal(); |
389 | | - |
390 | | - thread->java_suspend_self(); |
391 | | - } |
392 | | - } while (threadIsSuspended); |
| 373 | + sig_semaphore->wait_with_safepoint_check(JavaThread::current()); |
393 | 374 | } |
394 | 375 | ShouldNotReachHere(); |
395 | 376 | return 0; // Satisfy compiler |
@@ -1555,10 +1536,6 @@ void PosixSignals::hotspot_sigmask(Thread* thread) { |
1555 | 1536 | // - sets target osthread state to continue |
1556 | 1537 | // - sends signal to end the sigsuspend loop in the SR_handler |
1557 | 1538 | // |
1558 | | -// Note that the SR_lock plays no role in this suspend/resume protocol, |
1559 | | -// but is checked for NULL in SR_handler as a thread termination indicator. |
1560 | | -// The SR_lock is, however, used by JavaThread::java_suspend()/java_resume() APIs. |
1561 | | -// |
1562 | 1539 | // Note that resume_clear_context() and suspend_save_context() are needed |
1563 | 1540 | // by SR_handler(), so that fetch_frame_from_context() works, |
1564 | 1541 | // which in part is used by: |
@@ -1603,11 +1580,11 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) { |
1603 | 1580 |
|
1604 | 1581 | // On some systems we have seen signal delivery get "stuck" until the signal |
1605 | 1582 | // mask is changed as part of thread termination. Check that the current thread |
1606 | | - // has not already terminated (via SR_lock()) - else the following assertion |
| 1583 | + // has not already terminated - else the following assertion |
1607 | 1584 | // will fail because the thread is no longer a JavaThread as the ~JavaThread |
1608 | 1585 | // destructor has completed. |
1609 | 1586 |
|
1610 | | - if (thread->SR_lock() == NULL) { |
| 1587 | + if (thread->has_terminated()) { |
1611 | 1588 | return; |
1612 | 1589 | } |
1613 | 1590 |
|
|
0 commit comments