MCPcopy Create free account
hub / github.com/F-Stack/f-stack / thread_single_end

Function thread_single_end

freebsd/kern/kern_thread.c:1558–1603  ·  view source on GitHub ↗

* End the single threading mode.. */

Source from the content-addressed store, hash-verified

1556 * End the single threading mode..
1557 */
1558void
1559thread_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.

Callers 3

fork_norfprocFunction · 0.85
resume_all_procFunction · 0.85
post_execveFunction · 0.85

Calls 3

remain_for_modeFunction · 0.85
thread_unsuspend_oneFunction · 0.85
kick_proc0Function · 0.85

Tested by

no test coverage detected