Lines Matching refs:t
333 kthread_t *t; in thread_create() local
378 t = (kthread_t *)(stk + stksize); in thread_create()
379 bzero(t, sizeof (kthread_t)); in thread_create()
381 audit_thread_create(t); in thread_create()
382 t->t_stk = stk + stksize; in thread_create()
383 t->t_stkbase = stk; in thread_create()
386 t = (kthread_t *)(stk); in thread_create()
387 bzero(t, sizeof (kthread_t)); in thread_create()
388 t->t_stk = stk + sizeof (kthread_t); in thread_create()
389 t->t_stkbase = stk + stksize + sizeof (kthread_t); in thread_create()
391 t->t_flag |= T_TALLOCSTK; in thread_create()
392 t->t_swap = stk; in thread_create()
394 t = kmem_cache_alloc(thread_cache, KM_SLEEP); in thread_create()
395 bzero(t, sizeof (kthread_t)); in thread_create()
396 ASSERT(((uintptr_t)t & (PTR24_ALIGN - 1)) == 0); in thread_create()
398 audit_thread_create(t); in thread_create()
404 t->t_stk = stk + stksize; in thread_create()
405 t->t_stkbase = stk; in thread_create()
407 t->t_stk = stk; /* 3b2-like */ in thread_create()
408 t->t_stkbase = stk + stksize; in thread_create()
413 stkinfo_begin(t); in thread_create()
416 t->t_ts = ts; in thread_create()
424 crhold(t->t_cred = pp->p_cred); in thread_create()
426 t->t_start = gethrestime_sec(); in thread_create()
427 t->t_startpc = proc; in thread_create()
428 t->t_procp = pp; in thread_create()
429 t->t_clfuncs = &sys_classfuncs.thread; in thread_create()
430 t->t_cid = syscid; in thread_create()
431 t->t_pri = pri; in thread_create()
432 t->t_stime = ddi_get_lbolt(); in thread_create()
433 t->t_schedflag = TS_LOAD | TS_DONT_SWAP; in thread_create()
434 t->t_bind_cpu = PBIND_NONE; in thread_create()
435 t->t_bindflag = (uchar_t)default_binding_mode; in thread_create()
436 t->t_bind_pset = PS_NONE; in thread_create()
437 t->t_plockp = &pp->p_lock; in thread_create()
438 t->t_copyops = NULL; in thread_create()
439 t->t_taskq = NULL; in thread_create()
440 t->t_anttime = 0; in thread_create()
441 t->t_hatdepth = 0; in thread_create()
443 t->t_dtrace_vtime = 1; /* assure vtimestamp is always non-zero */ in thread_create()
448 tnf_thread_create(t); in thread_create()
450 LOCK_INIT_CLEAR(&t->t_lock); in thread_create()
457 t->t_stk = thread_stk_init(t->t_stk); in thread_create()
458 thread_load(t, proc, arg, len); in thread_create()
466 t->t_proj = project_hold(proj0p); in thread_create()
468 lgrp_affinity_init(&t->t_lgrp_affinity); in thread_create()
472 t->t_did = next_t_id++; in thread_create()
473 t->t_prev = curthread->t_prev; in thread_create()
474 t->t_next = curthread; in thread_create()
485 curthread->t_prev->t_next = t; in thread_create()
486 curthread->t_prev = t; in thread_create()
499 t->t_cpupart = &cp_default; in thread_create()
508 lgrp_move_thread(t, &cp_default.cp_lgrploads[LGRP_ROOTID], 1); in thread_create()
516 t->t_cpu = CPU; in thread_create()
518 t->t_cpu = disp_lowpri_cpu(cp_default.cp_cpulist, t->t_lpl, in thread_create()
519 t->t_pri, NULL); in thread_create()
521 t->t_disp_queue = t->t_cpu->cpu_disp; in thread_create()
532 THREAD_SET_STATE(t, TS_STOPPED, &transition_lock); in thread_create()
533 CL_SETRUN(t); in thread_create()
534 thread_unlock(t); in thread_create()
538 THREAD_ONPROC(t, t->t_cpu); in thread_create()
548 THREAD_FREEINTR(t, CPU); in thread_create()
552 THREAD_SET_STATE(t, TS_STOPPED, &stop_lock); in thread_create()
559 return (t); in thread_create()
566 thread_rele(kthread_t *t) in thread_rele() argument
570 thread_lock(t); in thread_rele()
572 ASSERT(t == curthread || t->t_state == TS_FREE || t->t_procp == &p0); in thread_rele()
573 kpj = ttoproj(t); in thread_rele()
574 t->t_proj = proj0p; in thread_rele()
576 thread_unlock(t); in thread_rele()
587 kthread_t *t = curthread; in thread_exit() local
589 if ((t->t_proc_flag & TP_ZTHREAD) != 0) in thread_exit()
600 ASSERT(t->t_pollstate == NULL); in thread_exit()
601 ASSERT(t->t_schedctl == NULL); in thread_exit()
602 if (t->t_door) in thread_exit()
607 if (t->t_tnf_tpdp) in thread_exit()
611 thread_rele(t); in thread_exit()
612 t->t_preempt++; in thread_exit()
619 t->t_next->t_prev = t->t_prev; in thread_exit()
620 t->t_prev->t_next = t->t_next; in thread_exit()
621 ASSERT(allthreads != t); /* t0 never exits */ in thread_exit()
622 cv_broadcast(&t->t_joincv); /* wake up anyone in thread_join */ in thread_exit()
625 if (t->t_ctx != NULL) in thread_exit()
626 exitctx(t); in thread_exit()
627 if (t->t_procp->p_pctx != NULL) in thread_exit()
628 exitpctx(t->t_procp); in thread_exit()
631 stkinfo_end(t); in thread_exit()
634 t->t_state = TS_ZOMB; /* set zombie thread */ in thread_exit()
649 kthread_t *t; in did_to_thread() local
652 for (t = curthread->t_next; t != curthread; t = t->t_next) { in did_to_thread()
653 if (t->t_did == tid) in did_to_thread()
656 if (t->t_did == tid) in did_to_thread()
657 return (t); in did_to_thread()
670 kthread_t *t; in thread_join() local
690 while (t = did_to_thread(tid)) in thread_join()
691 cv_wait(&t->t_joincv, &pidlock); in thread_join()
696 thread_free_prevent(kthread_t *t) in thread_free_prevent() argument
700 lp = &thread_free_lock[THREAD_FREE_HASH(t)].tf_lock; in thread_free_prevent()
705 thread_free_allow(kthread_t *t) in thread_free_allow() argument
709 lp = &thread_free_lock[THREAD_FREE_HASH(t)].tf_lock; in thread_free_allow()
714 thread_free_barrier(kthread_t *t) in thread_free_barrier() argument
718 lp = &thread_free_lock[THREAD_FREE_HASH(t)].tf_lock; in thread_free_barrier()
724 thread_free(kthread_t *t) in thread_free() argument
726 boolean_t allocstk = (t->t_flag & T_TALLOCSTK); in thread_free()
727 klwp_t *lwp = t->t_lwp; in thread_free()
728 caddr_t swap = t->t_swap; in thread_free()
730 ASSERT(t != &t0 && t->t_state == TS_FREE); in thread_free()
731 ASSERT(t->t_door == NULL); in thread_free()
732 ASSERT(t->t_schedctl == NULL); in thread_free()
733 ASSERT(t->t_pollstate == NULL); in thread_free()
735 t->t_pri = 0; in thread_free()
736 t->t_pc = 0; in thread_free()
737 t->t_sp = 0; in thread_free()
738 t->t_wchan0 = NULL; in thread_free()
739 t->t_wchan = NULL; in thread_free()
740 if (t->t_cred != NULL) { in thread_free()
741 crfree(t->t_cred); in thread_free()
742 t->t_cred = 0; in thread_free()
744 if (t->t_pdmsg) { in thread_free()
745 kmem_free(t->t_pdmsg, strlen(t->t_pdmsg) + 1); in thread_free()
746 t->t_pdmsg = NULL; in thread_free()
749 audit_thread_free(t); in thread_free()
751 if (t->t_tnf_tpdp) in thread_free()
752 tnf_thread_free(t); in thread_free()
754 if (t->t_cldata) { in thread_free()
755 CL_EXITCLASS(t->t_cid, (caddr_t *)t->t_cldata); in thread_free()
757 if (t->t_rprof != NULL) { in thread_free()
758 kmem_free(t->t_rprof, sizeof (*t->t_rprof)); in thread_free()
759 t->t_rprof = NULL; in thread_free()
761 t->t_lockp = NULL; /* nothing should try to lock this thread now */ in thread_free()
764 if (t->t_ctx) in thread_free()
765 freectx(t, 0); in thread_free()
766 t->t_stk = NULL; in thread_free()
769 lock_clear(&t->t_lock); in thread_free()
771 if (t->t_ts->ts_waiters > 0) in thread_free()
774 kmem_cache_free(turnstile_cache, t->t_ts); in thread_free()
776 free_afd(&t->t_activefd); in thread_free()
783 thread_free_barrier(t); in thread_free()
785 ASSERT(ttoproj(t) == proj0p); in thread_free()
786 project_rele(ttoproj(t)); in thread_free()
788 lgrp_affinity_free(&t->t_lgrp_affinity); in thread_free()
798 t->t_lwp = NULL; in thread_free()
799 t->t_swap = NULL; in thread_free()
808 kmem_cache_free(thread_cache, t); in thread_free()
840 thread_reap_list(kthread_t *t) in thread_reap_list() argument
844 while (t != NULL) { in thread_reap_list()
845 next = t->t_forw; in thread_reap_list()
846 thread_free(t); in thread_reap_list()
847 t = next; in thread_reap_list()
855 kthread_t *t, *l; in thread_zone_destroy() local
861 t = thread_zone_cleanup(&thread_deathrow, &thread_reapcnt, zoneid); in thread_zone_destroy()
883 thread_reap_list(t); in thread_zone_destroy()
897 kthread_t *t, *l; in thread_reaper() local
919 t = thread_deathrow; in thread_reaper()
944 thread_reap_list(t); in thread_reaper()
961 reapq_move_lq_to_tq(kthread_t *t) in reapq_move_lq_to_tq() argument
963 ASSERT(t->t_state == TS_FREE); in reapq_move_lq_to_tq()
965 t->t_forw = thread_deathrow; in reapq_move_lq_to_tq()
966 thread_deathrow = t; in reapq_move_lq_to_tq()
978 reapq_add(kthread_t *t) in reapq_add() argument
990 if (t->t_flag & T_LWPREUSE) { in reapq_add()
991 ASSERT(ttolwp(t) != NULL); in reapq_add()
992 t->t_forw = lwp_deathrow; in reapq_add()
993 lwp_deathrow = t; in reapq_add()
996 t->t_forw = thread_deathrow; in reapq_add()
997 thread_deathrow = t; in reapq_add()
1002 t->t_state = TS_FREE; in reapq_add()
1003 lock_clear(&t->t_lock); in reapq_add()
1022 thread_lock(t); in reapq_add()
1023 thread_unlock(t); in reapq_add()
1033 kthread_t *t, in installctx() argument
1052 ctx->next = t->t_ctx; in installctx()
1053 t->t_ctx = ctx; in installctx()
1061 kthread_t *t, in removectx() argument
1087 ASSERT(t == curthread || ttoproc(t)->p_stat == SIDL || in removectx()
1088 ttoproc(t)->p_agenttp == curthread || t->t_state == TS_STOPPED); in removectx()
1094 mutex_enter(&t->t_ctx_lock); in removectx()
1097 for (ctx = t->t_ctx; ctx != NULL; ctx = ctx->next) { in removectx()
1105 t->t_ctx = ctx->next; in removectx()
1106 mutex_exit(&t->t_ctx_lock); in removectx()
1115 mutex_exit(&t->t_ctx_lock); in removectx()
1122 savectx(kthread_t *t) in savectx() argument
1126 ASSERT(t == curthread); in savectx()
1127 for (ctx = t->t_ctx; ctx != 0; ctx = ctx->next) in savectx()
1133 restorectx(kthread_t *t) in restorectx() argument
1137 ASSERT(t == curthread); in restorectx()
1138 for (ctx = t->t_ctx; ctx != 0; ctx = ctx->next) in restorectx()
1144 forkctx(kthread_t *t, kthread_t *ct) in forkctx() argument
1148 for (ctx = t->t_ctx; ctx != NULL; ctx = ctx->next) in forkctx()
1150 (ctx->fork_op)(t, ct); in forkctx()
1159 lwp_createctx(kthread_t *t, kthread_t *ct) in lwp_createctx() argument
1163 for (ctx = t->t_ctx; ctx != NULL; ctx = ctx->next) in lwp_createctx()
1165 (ctx->lwp_create_op)(t, ct); in lwp_createctx()
1176 exitctx(kthread_t *t) in exitctx() argument
1180 for (ctx = t->t_ctx; ctx != NULL; ctx = ctx->next) in exitctx()
1182 (ctx->exit_op)(t); in exitctx()
1190 freectx(kthread_t *t, int isexec) in freectx() argument
1195 while ((ctx = t->t_ctx) != NULL) { in freectx()
1196 t->t_ctx = ctx->next; in freectx()
1232 setrun_locked(kthread_t *t) in setrun_locked() argument
1234 ASSERT(THREAD_LOCK_HELD(t)); in setrun_locked()
1235 if (t->t_state == TS_SLEEP) { in setrun_locked()
1239 SOBJ_UNSLEEP(t->t_sobj_ops, t); in setrun_locked()
1240 } else if (t->t_state & (TS_RUN | TS_ONPROC)) { in setrun_locked()
1245 } else if (t->t_state == TS_WAIT) { in setrun_locked()
1246 waitq_setrun(t); in setrun_locked()
1247 } else if (t->t_state == TS_STOPPED) { in setrun_locked()
1266 if ((t->t_schedflag & TS_ALLSTART) != TS_ALLSTART) in setrun_locked()
1271 t->t_whystop = 0; in setrun_locked()
1272 t->t_whatstop = 0; in setrun_locked()
1279 t->t_schedflag &= ~TS_ALLSTART; in setrun_locked()
1280 THREAD_TRANSITION(t); /* drop stopped-thread lock */ in setrun_locked()
1281 ASSERT(t->t_lockp == &transition_lock); in setrun_locked()
1282 ASSERT(t->t_wchan0 == NULL && t->t_wchan == NULL); in setrun_locked()
1286 CL_SETRUN(t); in setrun_locked()
1291 setrun(kthread_t *t) in setrun() argument
1293 thread_lock(t); in setrun()
1294 setrun_locked(t); in setrun()
1295 thread_unlock(t); in setrun()
1313 kthread_t *t = curthread; /* current thread */ in thread_unpin() local
1318 ASSERT(t->t_intr != NULL); in thread_unpin()
1320 itp = t->t_intr; /* interrupted thread */ in thread_unpin()
1321 t->t_intr = NULL; /* clear interrupt ptr */ in thread_unpin()
1328 i = intr_passivate(t, itp); in thread_unpin()
1332 i, t, t, itp, itp); in thread_unpin()
1337 t->t_lwp = NULL; in thread_unpin()
1562 tsd_agent_get(kthread_t *t, uint_t key) in tsd_agent_get() argument
1564 struct tsd_thread *tsd = t->t_tsd; in tsd_agent_get()
1566 ASSERT(t == curthread || in tsd_agent_get()
1567 ttoproc(t)->p_agenttp == curthread || t->t_state == TS_STOPPED); in tsd_agent_get()
1584 tsd_agent_set(kthread_t *t, uint_t key, void *value) in tsd_agent_set() argument
1586 struct tsd_thread *tsd = t->t_tsd; in tsd_agent_set()
1588 ASSERT(t == curthread || in tsd_agent_set()
1589 ttoproc(t)->p_agenttp == curthread || t->t_state == TS_STOPPED); in tsd_agent_set()
1594 tsd = t->t_tsd = kmem_zalloc(sizeof (*tsd), KM_SLEEP); in tsd_agent_set()
1760 thread_change_epri(kthread_t *t, pri_t disp_pri) in thread_change_epri() argument
1764 ASSERT(THREAD_LOCK_HELD(t)); in thread_change_epri()
1770 if (t->t_epri == disp_pri) in thread_change_epri()
1773 state = t->t_state; in thread_change_epri()
1779 t->t_epri = disp_pri; in thread_change_epri()
1781 cpu_t *cp = t->t_disp_queue->disp_cpu; in thread_change_epri()
1783 if (t == cp->cpu_dispthread) in thread_change_epri()
1784 cp->cpu_dispatch_pri = DISP_PRIO(t); in thread_change_epri()
1794 SOBJ_CHANGE_EPRI(t->t_sobj_ops, t, disp_pri); in thread_change_epri()
1800 if (disp_pri != t->t_epri) in thread_change_epri()
1801 waitq_change_pri(t, disp_pri); in thread_change_epri()
1809 (void) dispdeq(t); in thread_change_epri()
1810 t->t_epri = disp_pri; in thread_change_epri()
1811 setbackdq(t); in thread_change_epri()
1813 schedctl_set_cidpri(t); in thread_change_epri()
1823 thread_change_pri(kthread_t *t, pri_t disp_pri, int front) in thread_change_pri() argument
1828 ASSERT(THREAD_LOCK_HELD(t)); in thread_change_pri()
1830 state = t->t_state; in thread_change_pri()
1831 THREAD_WILLCHANGE_PRI(t, disp_pri); in thread_change_pri()
1837 t->t_pri = disp_pri; in thread_change_pri()
1840 cpu_t *cp = t->t_disp_queue->disp_cpu; in thread_change_pri()
1842 if (t == cp->cpu_dispthread) in thread_change_pri()
1843 cp->cpu_dispatch_pri = DISP_PRIO(t); in thread_change_pri()
1853 if (disp_pri != t->t_pri) in thread_change_pri()
1854 SOBJ_CHANGE_PRI(t->t_sobj_ops, t, disp_pri); in thread_change_pri()
1860 if (disp_pri != t->t_pri) in thread_change_pri()
1861 waitq_change_pri(t, disp_pri); in thread_change_pri()
1873 on_rq = dispdeq(t); in thread_change_pri()
1875 t->t_pri = disp_pri; in thread_change_pri()
1877 setfrontdq(t); in thread_change_pri()
1879 setbackdq(t); in thread_change_pri()
1882 schedctl_set_cidpri(t); in thread_change_pri()
1891 stkinfo_begin(kthread_t *t) in stkinfo_begin() argument
1901 if (t->t_stk > t->t_stkbase) { in stkinfo_begin()
1903 start = t->t_stkbase; in stkinfo_begin()
1904 end = t->t_stk; in stkinfo_begin()
1907 start = t->t_stk; in stkinfo_begin()
1908 end = t->t_stkbase; in stkinfo_begin()
1940 stkinfo_end(kthread_t *t) in stkinfo_end() argument
1970 if (t->t_stk > t->t_stkbase) { in stkinfo_end()
1972 start = t->t_stkbase; in stkinfo_end()
1973 end = t->t_stk; in stkinfo_end()
1976 start = t->t_stk; in stkinfo_end()
1977 end = t->t_stkbase; in stkinfo_end()
1999 if (t->t_stk > t->t_stkbase) { in stkinfo_end()
2034 DTRACE_PROBE3(stack__usage, kthread_t *, t, in stkinfo_end()
2069 kmem_stkinfo_log[index].kthread = (caddr_t)t; in stkinfo_end()
2070 kmem_stkinfo_log[index].t_startpc = (caddr_t)t->t_startpc; in stkinfo_end()
2074 kmem_stkinfo_log[index].t_tid = t->t_tid; in stkinfo_end()
2076 if (t->t_tid != 0) { in stkinfo_end()
2077 stksz = strlen((t->t_procp)->p_user.u_comm); in stkinfo_end()
2085 (t->t_procp)->p_user.u_comm, stksz); in stkinfo_end()