* End the single threading mode.. */
| 1556 | * End the single threading mode.. |
| 1557 | */ |
| 1558 | void |
| 1559 | thread_single_end(struct proc *p, int mode) |
| 1560 | { |
| 1561 | struct thread *td; |
| 1562 | int wakeup_swapper; |
| 1563 | |
| 1564 | KASSERT(mode == SINGLE_EXIT || mode == SINGLE_BOUNDARY || |
| 1565 | mode == SINGLE_ALLPROC || mode == SINGLE_NO_EXIT, |
| 1566 | ("invalid mode %d", mode)); |
| 1567 | PROC_LOCK_ASSERT(p, MA_OWNED); |
| 1568 | KASSERT((mode == SINGLE_ALLPROC && (p->p_flag & P_TOTAL_STOP) != 0) || |
| 1569 | (mode != SINGLE_ALLPROC && (p->p_flag & P_TOTAL_STOP) == 0), |
| 1570 | ("mode %d does not match P_TOTAL_STOP", mode)); |
| 1571 | KASSERT(mode == SINGLE_ALLPROC || p->p_singlethread == curthread, |
| 1572 | ("thread_single_end from other thread %p %p", |
| 1573 | curthread, p->p_singlethread)); |
| 1574 | KASSERT(mode != SINGLE_BOUNDARY || |
| 1575 | (p->p_flag & P_SINGLE_BOUNDARY) != 0, |
| 1576 | ("mis-matched SINGLE_BOUNDARY flags %x", p->p_flag)); |
| 1577 | p->p_flag &= ~(P_STOPPED_SINGLE | P_SINGLE_EXIT | P_SINGLE_BOUNDARY | |
| 1578 | P_TOTAL_STOP); |
| 1579 | PROC_SLOCK(p); |
| 1580 | p->p_singlethread = NULL; |
| 1581 | wakeup_swapper = 0; |
| 1582 | /* |
| 1583 | * If there are other threads they may now run, |
| 1584 | * unless of course there is a blanket 'stop order' |
| 1585 | * on the process. The single threader must be allowed |
| 1586 | * to continue however as this is a bad place to stop. |
| 1587 | */ |
| 1588 | if (p->p_numthreads != remain_for_mode(mode) && !P_SHOULDSTOP(p)) { |
| 1589 | FOREACH_THREAD_IN_PROC(p, td) { |
| 1590 | thread_lock(td); |
| 1591 | if (TD_IS_SUSPENDED(td)) { |
| 1592 | wakeup_swapper |= thread_unsuspend_one(td, p, |
| 1593 | mode == SINGLE_BOUNDARY); |
| 1594 | } else |
| 1595 | thread_unlock(td); |
| 1596 | } |
| 1597 | } |
| 1598 | KASSERT(mode != SINGLE_BOUNDARY || p->p_boundary_count == 0, |
| 1599 | ("inconsistent boundary count %d", p->p_boundary_count)); |
| 1600 | PROC_SUNLOCK(p); |
| 1601 | if (wakeup_swapper) |
| 1602 | kick_proc0(); |
| 1603 | } |
| 1604 | |
| 1605 | /* |
| 1606 | * Locate a thread by number and return with proc lock held. |
no test coverage detected