Lines Matching refs:td

165 static int	sleepq_resume_thread(struct sleepqueue *sq, struct thread *td,
303 struct thread *td;
305 td = curthread;
308 MPASS(td->td_sleepqueue != NULL);
313 KASSERT(td->td_no_sleeping == 0,
314 ("%s: td %p to sleep on wchan %p with sleeping prohibited",
315 __func__, td, wchan));
329 sq = td->td_sleepqueue;
349 sq = td->td_sleepqueue;
357 LIST_INSERT_HEAD(&sq->sq_free, td->td_sleepqueue, sq_hash);
359 thread_lock(td);
360 TAILQ_INSERT_TAIL(&sq->sq_blocked[queue], td, td_slpq);
362 td->td_sleepqueue = NULL;
363 td->td_sqqueue = queue;
364 td->td_wchan = wchan;
365 td->td_wmesg = wmesg;
367 td->td_flags |= TDF_SINTR;
368 td->td_flags &= ~TDF_SLEEPABORT;
370 thread_unlock(td);
382 struct thread *td;
385 td = curthread;
388 MPASS(TD_ON_SLEEPQ(td));
389 MPASS(td->td_sleepqueue == NULL);
391 if (cold && td == &thread0)
393 KASSERT(td->td_sleeptimo == 0, ("td %d %p td_sleeptimo %jx",
394 td->td_tid, td, (uintmax_t)td->td_sleeptimo));
395 thread_lock(td);
396 callout_when(sbt, pr, flags, &td->td_sleeptimo, &pr1);
397 thread_unlock(td);
398 callout_reset_sbt_on(&td->td_slpcallout, td->td_sleeptimo, pr1,
399 sleepq_timeout, td, PCPU_GET(cpuid), flags | C_PRECALC |
430 struct thread *td;
436 td = curthread;
441 if ((td->td_pflags & TDP_WAKEUP) != 0) {
442 td->td_pflags &= ~TDP_WAKEUP;
444 thread_lock(td);
452 thread_lock(td);
453 if ((td->td_flags & (TDF_NEEDSIGCHK | TDF_NEEDSUSPCHK)) != 0) {
454 thread_unlock(td);
457 (void *)td, (long)p->p_pid, td->td_name);
464 if ((td->td_flags & TDF_NEEDSUSPCHK) != 0) {
470 thread_lock(td);
474 if ((td->td_flags & TDF_NEEDSIGCHK) != 0) {
477 sig = cursig(td);
480 KASSERT((td->td_flags & TDF_SBDRY) != 0,
482 KASSERT(TD_SBDRY_INTR(td),
484 KASSERT((td->td_flags &
488 ret = TD_SBDRY_ERRNO(td);
504 if ((td->td_dbgflags & TDB_FSTP) != 0) {
507 td->td_dbgflags &= ~TDB_FSTP;
518 thread_lock(td);
530 if (TD_ON_SLEEPQ(td)) {
532 if (sleepq_resume_thread(sq, td, 0)) {
543 MPASS(td->td_lock != &sc->sc_lock);
556 struct thread *td;
559 td = curthread;
562 THREAD_LOCK_ASSERT(td, MA_OWNED);
568 if (td->td_sleepqueue != NULL) {
592 rtc_changed = td->td_rtcgen != 0 && td->td_rtcgen != rtc_generation;
593 if ((td->td_flags & TDF_TIMEOUT) || rtc_changed) {
595 td->td_rtcgen = 0;
597 MPASS(TD_ON_SLEEPQ(td));
599 if (sleepq_resume_thread(sq, td, 0)) {
613 sleepq_profile(td->td_wmesg);
615 MPASS(td->td_sleepqueue == NULL);
616 sched_sleep(td, pri);
617 thread_lock_set(td, &sc->sc_lock);
619 TD_SET_SLEEPING(td);
621 KASSERT(TD_IS_RUNNING(td), ("running but not TDS_RUNNING"));
623 (void *)td, (long)td->td_proc->p_pid, (void *)td->td_name);
632 struct thread *td;
635 td = curthread;
636 THREAD_LOCK_ASSERT(td, MA_OWNED);
643 if (td->td_sleeptimo != 0) {
644 if (td->td_sleeptimo <= sbinuptime())
646 td->td_sleeptimo = 0;
648 if (td->td_flags & TDF_TIMEOUT)
649 td->td_flags &= ~TDF_TIMEOUT;
661 callout_stop(&td->td_slpcallout);
671 struct thread *td;
673 td = curthread;
674 THREAD_LOCK_ASSERT(td, MA_OWNED);
677 if (td->td_flags & TDF_SINTR)
678 td->td_flags &= ~TDF_SINTR;
680 if (td->td_flags & TDF_SLEEPABORT) {
681 td->td_flags &= ~TDF_SLEEPABORT;
682 return (td->td_intrval);
694 struct thread *td;
696 td = curthread;
697 MPASS(!(td->td_flags & TDF_SINTR));
698 thread_lock(td);
700 thread_unlock(td);
728 struct thread *td;
731 td = curthread;
732 MPASS(!(td->td_flags & TDF_SINTR));
733 thread_lock(td);
736 thread_unlock(td);
788 sleepq_resume_thread(struct sleepqueue *sq, struct thread *td, int pri)
792 MPASS(td != NULL);
794 MPASS(td->td_wchan == sq->sq_wchan);
795 MPASS(td->td_sqqueue < NR_SLEEPQS && td->td_sqqueue >= 0);
796 THREAD_LOCK_ASSERT(td, MA_OWNED);
800 SDT_PROBE2(sched, , , wakeup, td, td->td_proc);
803 sq->sq_blockedcnt[td->td_sqqueue]--;
804 TAILQ_REMOVE(&sq->sq_blocked[td->td_sqqueue], td, td_slpq);
812 td->td_sleepqueue = sq;
820 td->td_sleepqueue = LIST_FIRST(&sq->sq_free);
821 LIST_REMOVE(td->td_sleepqueue, sq_hash);
823 td->td_wmesg = NULL;
824 td->td_wchan = NULL;
825 td->td_flags &= ~TDF_SINTR;
828 (void *)td, (long)td->td_proc->p_pid, td->td_name);
832 if (pri != 0 && td->td_priority > pri &&
833 PRI_BASE(td->td_pri_class) == PRI_TIMESHARE)
834 sched_prio(td, pri);
837 * Note that thread td might not be sleeping if it is running
842 if (TD_IS_SLEEPING(td)) {
843 TD_CLR_SLEEPING(td);
844 return (setrunnable(td));
895 struct thread *td, *besttd;
917 td = TAILQ_PREV_FAST(besttd, head, thread, td_slpq);
918 if (td == NULL)
920 besttd = td;
929 besttd = td = TAILQ_FIRST(head);
930 while ((td = TAILQ_NEXT(td, td_slpq)) != NULL) {
931 if (td->td_priority < besttd->td_priority)
932 besttd = td;
943 match_any(struct thread *td __unused)
976 struct thread *td, *tdn;
986 TAILQ_FOREACH_SAFE(td, &sq->sq_blocked[queue], td_slpq, tdn) {
987 thread_lock(td);
988 if (matches(td))
989 wakeup_swapper |= sleepq_resume_thread(sq, td, pri);
990 thread_unlock(td);
1005 struct thread *td;
1009 td = arg;
1012 (void *)td, (long)td->td_proc->p_pid, (void *)td->td_name);
1014 thread_lock(td);
1016 if (td->td_sleeptimo > sbinuptime() || td->td_sleeptimo == 0) {
1020 } else if (TD_IS_SLEEPING(td) && TD_ON_SLEEPQ(td)) {
1025 wchan = td->td_wchan;
1027 THREAD_LOCKPTR_ASSERT(td, &sc->sc_lock);
1030 td->td_flags |= TDF_TIMEOUT;
1031 wakeup_swapper = sleepq_resume_thread(sq, td, 0);
1032 } else if (TD_ON_SLEEPQ(td)) {
1039 td->td_flags |= TDF_TIMEOUT;
1042 thread_unlock(td);
1052 sleepq_remove(struct thread *td, void *wchan)
1071 if (!TD_ON_SLEEPQ(td) || td->td_wchan != wchan) {
1076 thread_lock(td);
1078 MPASS(td->td_wchan == wchan);
1079 wakeup_swapper = sleepq_resume_thread(sq, td, 0);
1080 thread_unlock(td);
1091 sleepq_abort(struct thread *td, int intrval)
1096 THREAD_LOCK_ASSERT(td, MA_OWNED);
1097 MPASS(TD_ON_SLEEPQ(td));
1098 MPASS(td->td_flags & TDF_SINTR);
1105 if (td->td_flags & TDF_TIMEOUT)
1109 (void *)td, (long)td->td_proc->p_pid, (void *)td->td_name);
1110 td->td_intrval = intrval;
1111 td->td_flags |= TDF_SLEEPABORT;
1117 if (!TD_IS_SLEEPING(td))
1119 wchan = td->td_wchan;
1125 return (sleepq_resume_thread(sq, td, 0));
1165 struct thread *td, *td_next;
1199 /* Where we will store the td name, tid, etc. */
1220 TAILQ_FOREACH_SAFE(td, &sq->sq_blocked[queue], td_slpq,
1226 stack_save_td(st[stack_idx], td);
1229 td->td_tid, td->td_name, td);
1424 struct thread *td;
1469 TAILQ_FOREACH(td, &sq->sq_blocked[i],
1471 db_printf("\t%p (tid %d, pid %d, \"%s\")\n", td,
1472 td->td_tid, td->td_proc->p_pid,
1473 td->td_name);