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

Function doselwakeup

freebsd/kern/sys_generic.c:1850–1884  ·  view source on GitHub ↗

* Do a wakeup when a selectable event occurs. */

Source from the content-addressed store, hash-verified

1848 * Do a wakeup when a selectable event occurs.
1849 */
1850static void
1851doselwakeup(struct selinfo *sip, int pri)
1852{
1853 struct selfd *sfp;
1854 struct selfd *sfn;
1855 struct seltd *stp;
1856
1857 /* If it's not initialized there can't be any waiters. */
1858 if (sip->si_mtx == NULL)
1859 return;
1860 /*
1861 * Locking the selinfo locks all selfds associated with it.
1862 */
1863 mtx_lock(sip->si_mtx);
1864 TAILQ_FOREACH_SAFE(sfp, &sip->si_tdlist, sf_threads, sfn) {
1865 /*
1866 * Once we remove this sfp from the list and clear the
1867 * sf_si seltdclear will know to ignore this si.
1868 */
1869 TAILQ_REMOVE(&sip->si_tdlist, sfp, sf_threads);
1870 stp = sfp->sf_td;
1871 mtx_lock(&stp->st_mtx);
1872 stp->st_flags |= SELTD_PENDING;
1873 cv_broadcastpri(&stp->st_wait, pri);
1874 mtx_unlock(&stp->st_mtx);
1875 /*
1876 * Paired with selfdfree.
1877 *
1878 * Storing this only after the wakeup provides an invariant that
1879 * stp is not used after selfdfree returns.
1880 */
1881 atomic_store_rel_ptr((uintptr_t *)&sfp->sf_si, (uintptr_t)NULL);
1882 }
1883 mtx_unlock(sip->si_mtx);
1884}
1885
1886static void
1887seltdinit(struct thread *td)

Callers 3

seldrainFunction · 0.85
selwakeupFunction · 0.85
selwakeuppriFunction · 0.85

Calls 3

mtx_lockFunction · 0.70
cv_broadcastpriFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected