| 2519 | } |
| 2520 | |
| 2521 | static int |
| 2522 | sig_suspend_threads(struct thread *td, struct proc *p, int sending) |
| 2523 | { |
| 2524 | struct thread *td2; |
| 2525 | int wakeup_swapper; |
| 2526 | |
| 2527 | PROC_LOCK_ASSERT(p, MA_OWNED); |
| 2528 | PROC_SLOCK_ASSERT(p, MA_OWNED); |
| 2529 | MPASS(sending || td == curthread); |
| 2530 | |
| 2531 | wakeup_swapper = 0; |
| 2532 | FOREACH_THREAD_IN_PROC(p, td2) { |
| 2533 | thread_lock(td2); |
| 2534 | td2->td_flags |= TDF_ASTPENDING | TDF_NEEDSUSPCHK; |
| 2535 | if ((TD_IS_SLEEPING(td2) || TD_IS_SWAPPED(td2)) && |
| 2536 | (td2->td_flags & TDF_SINTR)) { |
| 2537 | if (td2->td_flags & TDF_SBDRY) { |
| 2538 | /* |
| 2539 | * Once a thread is asleep with |
| 2540 | * TDF_SBDRY and without TDF_SERESTART |
| 2541 | * or TDF_SEINTR set, it should never |
| 2542 | * become suspended due to this check. |
| 2543 | */ |
| 2544 | KASSERT(!TD_IS_SUSPENDED(td2), |
| 2545 | ("thread with deferred stops suspended")); |
| 2546 | if (TD_SBDRY_INTR(td2)) { |
| 2547 | wakeup_swapper |= sleepq_abort(td2, |
| 2548 | TD_SBDRY_ERRNO(td2)); |
| 2549 | continue; |
| 2550 | } |
| 2551 | } else if (!TD_IS_SUSPENDED(td2)) |
| 2552 | thread_suspend_one(td2); |
| 2553 | } else if (!TD_IS_SUSPENDED(td2)) { |
| 2554 | if (sending || td != td2) |
| 2555 | td2->td_flags |= TDF_ASTPENDING; |
| 2556 | #ifdef SMP |
| 2557 | if (TD_IS_RUNNING(td2) && td2 != td) |
| 2558 | forward_signal(td2); |
| 2559 | #endif |
| 2560 | } |
| 2561 | thread_unlock(td2); |
| 2562 | } |
| 2563 | return (wakeup_swapper); |
| 2564 | } |
| 2565 | |
| 2566 | /* |
| 2567 | * Stop the process for an event deemed interesting to the debugger. If si is |
no test coverage detected