Lines Matching refs:t

335 	kthread_t *t;  in thread_create()  local
380 t = (kthread_t *)(stk + stksize); in thread_create()
381 bzero(t, sizeof (kthread_t)); in thread_create()
383 audit_thread_create(t); in thread_create()
384 t->t_stk = stk + stksize; in thread_create()
385 t->t_stkbase = stk; in thread_create()
388 t = (kthread_t *)(stk); in thread_create()
389 bzero(t, sizeof (kthread_t)); in thread_create()
390 t->t_stk = stk + sizeof (kthread_t); in thread_create()
391 t->t_stkbase = stk + stksize + sizeof (kthread_t); in thread_create()
393 t->t_flag |= T_TALLOCSTK; in thread_create()
394 t->t_swap = stk; in thread_create()
396 t = kmem_cache_alloc(thread_cache, KM_SLEEP); in thread_create()
397 bzero(t, sizeof (kthread_t)); in thread_create()
398 ASSERT(((uintptr_t)t & (PTR24_ALIGN - 1)) == 0); in thread_create()
400 audit_thread_create(t); in thread_create()
406 t->t_stk = stk + stksize; in thread_create()
407 t->t_stkbase = stk; in thread_create()
409 t->t_stk = stk; /* 3b2-like */ in thread_create()
410 t->t_stkbase = stk + stksize; in thread_create()
415 stkinfo_begin(t); in thread_create()
418 t->t_ts = ts; in thread_create()
426 crhold(t->t_cred = pp->p_cred); in thread_create()
428 t->t_start = gethrestime_sec(); in thread_create()
429 t->t_startpc = proc; in thread_create()
430 t->t_procp = pp; in thread_create()
431 t->t_clfuncs = &sys_classfuncs.thread; in thread_create()
432 t->t_cid = syscid; in thread_create()
433 t->t_pri = pri; in thread_create()
434 t->t_stime = ddi_get_lbolt(); in thread_create()
435 t->t_schedflag = TS_LOAD | TS_DONT_SWAP; in thread_create()
436 t->t_bind_cpu = PBIND_NONE; in thread_create()
437 t->t_bindflag = (uchar_t)default_binding_mode; in thread_create()
438 t->t_bind_pset = PS_NONE; in thread_create()
439 t->t_plockp = &pp->p_lock; in thread_create()
440 t->t_copyops = NULL; in thread_create()
441 t->t_taskq = NULL; in thread_create()
442 t->t_anttime = 0; in thread_create()
443 t->t_hatdepth = 0; in thread_create()
445 t->t_dtrace_vtime = 1; /* assure vtimestamp is always non-zero */ in thread_create()
448 LOCK_INIT_CLEAR(&t->t_lock); in thread_create()
455 t->t_stk = thread_stk_init(t->t_stk); in thread_create()
456 thread_load(t, proc, arg, len); in thread_create()
464 t->t_proj = project_hold(proj0p); in thread_create()
466 lgrp_affinity_init(&t->t_lgrp_affinity); in thread_create()
470 t->t_did = next_t_id++; in thread_create()
471 t->t_prev = curthread->t_prev; in thread_create()
472 t->t_next = curthread; in thread_create()
483 curthread->t_prev->t_next = t; in thread_create()
484 curthread->t_prev = t; in thread_create()
491 t->t_cpupart = &cp_default; in thread_create()
500 lgrp_move_thread(t, &cp_default.cp_lgrploads[LGRP_ROOTID], 1); in thread_create()
510 t->t_cpu = CPU; in thread_create()
512 t->t_cpu = cp_default.cp_cpulist; in thread_create()
513 t->t_cpu = disp_lowpri_cpu(t->t_cpu, t, t->t_pri); in thread_create()
516 t->t_disp_queue = t->t_cpu->cpu_disp; in thread_create()
527 THREAD_SET_STATE(t, TS_STOPPED, &transition_lock); in thread_create()
528 CL_SETRUN(t); in thread_create()
529 thread_unlock(t); in thread_create()
533 THREAD_ONPROC(t, t->t_cpu); in thread_create()
543 THREAD_FREEINTR(t, CPU); in thread_create()
547 THREAD_SET_STATE(t, TS_STOPPED, &stop_lock); in thread_create()
554 return (t); in thread_create()
561 thread_rele(kthread_t *t) in thread_rele() argument
565 thread_lock(t); in thread_rele()
567 ASSERT(t == curthread || t->t_state == TS_FREE || t->t_procp == &p0); in thread_rele()
568 kpj = ttoproj(t); in thread_rele()
569 t->t_proj = proj0p; in thread_rele()
571 thread_unlock(t); in thread_rele()
582 kthread_t *t = curthread; in thread_exit() local
584 if ((t->t_proc_flag & TP_ZTHREAD) != 0) in thread_exit()
595 ASSERT(t->t_pollstate == NULL); in thread_exit()
596 ASSERT(t->t_schedctl == NULL); in thread_exit()
597 if (t->t_door) in thread_exit()
600 thread_rele(t); in thread_exit()
601 t->t_preempt++; in thread_exit()
608 t->t_next->t_prev = t->t_prev; in thread_exit()
609 t->t_prev->t_next = t->t_next; in thread_exit()
610 ASSERT(allthreads != t); /* t0 never exits */ in thread_exit()
611 cv_broadcast(&t->t_joincv); /* wake up anyone in thread_join */ in thread_exit()
614 if (t->t_ctx != NULL) in thread_exit()
615 exitctx(t); in thread_exit()
616 if (t->t_procp->p_pctx != NULL) in thread_exit()
617 exitpctx(t->t_procp); in thread_exit()
620 stkinfo_end(t); in thread_exit()
623 t->t_state = TS_ZOMB; /* set zombie thread */ in thread_exit()
638 kthread_t *t; in did_to_thread() local
641 for (t = curthread->t_next; t != curthread; t = t->t_next) { in did_to_thread()
642 if (t->t_did == tid) in did_to_thread()
645 if (t->t_did == tid) in did_to_thread()
646 return (t); in did_to_thread()
659 kthread_t *t; in thread_join() local
679 while (t = did_to_thread(tid)) in thread_join()
680 cv_wait(&t->t_joincv, &pidlock); in thread_join()
685 thread_free_prevent(kthread_t *t) in thread_free_prevent() argument
689 lp = &thread_free_lock[THREAD_FREE_HASH(t)].tf_lock; in thread_free_prevent()
694 thread_free_allow(kthread_t *t) in thread_free_allow() argument
698 lp = &thread_free_lock[THREAD_FREE_HASH(t)].tf_lock; in thread_free_allow()
703 thread_free_barrier(kthread_t *t) in thread_free_barrier() argument
707 lp = &thread_free_lock[THREAD_FREE_HASH(t)].tf_lock; in thread_free_barrier()
713 thread_free(kthread_t *t) in thread_free() argument
715 boolean_t allocstk = (t->t_flag & T_TALLOCSTK); in thread_free()
716 klwp_t *lwp = t->t_lwp; in thread_free()
717 caddr_t swap = t->t_swap; in thread_free()
719 ASSERT(t != &t0 && t->t_state == TS_FREE); in thread_free()
720 ASSERT(t->t_door == NULL); in thread_free()
721 ASSERT(t->t_schedctl == NULL); in thread_free()
722 ASSERT(t->t_pollstate == NULL); in thread_free()
724 t->t_pri = 0; in thread_free()
725 t->t_pc = 0; in thread_free()
726 t->t_sp = 0; in thread_free()
727 t->t_wchan0 = NULL; in thread_free()
728 t->t_wchan = NULL; in thread_free()
729 if (t->t_cred != NULL) { in thread_free()
730 crfree(t->t_cred); in thread_free()
731 t->t_cred = 0; in thread_free()
733 if (t->t_pdmsg) { in thread_free()
734 kmem_free(t->t_pdmsg, strlen(t->t_pdmsg) + 1); in thread_free()
735 t->t_pdmsg = NULL; in thread_free()
738 audit_thread_free(t); in thread_free()
739 if (t->t_cldata) { in thread_free()
740 CL_EXITCLASS(t->t_cid, (caddr_t *)t->t_cldata); in thread_free()
742 if (t->t_rprof != NULL) { in thread_free()
743 kmem_free(t->t_rprof, sizeof (*t->t_rprof)); in thread_free()
744 t->t_rprof = NULL; in thread_free()
746 t->t_lockp = NULL; /* nothing should try to lock this thread now */ in thread_free()
749 if (t->t_ctx) in thread_free()
750 freectx(t, 0); in thread_free()
751 t->t_stk = NULL; in thread_free()
754 lock_clear(&t->t_lock); in thread_free()
756 if (t->t_ts->ts_waiters > 0) in thread_free()
759 kmem_cache_free(turnstile_cache, t->t_ts); in thread_free()
761 free_afd(&t->t_activefd); in thread_free()
768 thread_free_barrier(t); in thread_free()
770 ASSERT(ttoproj(t) == proj0p); in thread_free()
771 project_rele(ttoproj(t)); in thread_free()
773 lgrp_affinity_free(&t->t_lgrp_affinity); in thread_free()
779 if (t->t_name != NULL) { in thread_free()
780 kmem_free(t->t_name, THREAD_NAME_MAX); in thread_free()
781 t->t_name = NULL; in thread_free()
788 t->t_lwp = NULL; in thread_free()
789 t->t_swap = NULL; in thread_free()
798 kmem_cache_free(thread_cache, t); in thread_free()
830 thread_reap_list(kthread_t *t) in thread_reap_list() argument
834 while (t != NULL) { in thread_reap_list()
835 next = t->t_forw; in thread_reap_list()
836 thread_free(t); in thread_reap_list()
837 t = next; in thread_reap_list()
845 kthread_t *t, *l; in thread_zone_destroy() local
851 t = thread_zone_cleanup(&thread_deathrow, &thread_reapcnt, zoneid); in thread_zone_destroy()
873 thread_reap_list(t); in thread_zone_destroy()
887 kthread_t *t, *l; in thread_reaper() local
909 t = thread_deathrow; in thread_reaper()
934 thread_reap_list(t); in thread_reaper()
951 reapq_move_lq_to_tq(kthread_t *t) in reapq_move_lq_to_tq() argument
953 ASSERT(t->t_state == TS_FREE); in reapq_move_lq_to_tq()
955 t->t_forw = thread_deathrow; in reapq_move_lq_to_tq()
956 thread_deathrow = t; in reapq_move_lq_to_tq()
968 reapq_add(kthread_t *t) in reapq_add() argument
980 if (t->t_flag & T_LWPREUSE) { in reapq_add()
981 ASSERT(ttolwp(t) != NULL); in reapq_add()
982 t->t_forw = lwp_deathrow; in reapq_add()
983 lwp_deathrow = t; in reapq_add()
986 t->t_forw = thread_deathrow; in reapq_add()
987 thread_deathrow = t; in reapq_add()
992 t->t_state = TS_FREE; in reapq_add()
993 lock_clear(&t->t_lock); in reapq_add()
1012 thread_lock(t); in reapq_add()
1013 thread_unlock(t); in reapq_add()
1019 ctxop_find_by_tmpl(kthread_t *t, const struct ctxop_template *ct, void *arg) in ctxop_find_by_tmpl() argument
1023 ASSERT(MUTEX_HELD(&t->t_ctx_lock)); in ctxop_find_by_tmpl()
1026 if (t->t_ctx == NULL) { in ctxop_find_by_tmpl()
1030 ctx = head = t->t_ctx; in ctxop_find_by_tmpl()
1049 ctxop_detach_chain(kthread_t *t, struct ctxop *ctx) in ctxop_detach_chain() argument
1051 ASSERT(t != NULL); in ctxop_detach_chain()
1052 ASSERT(t->t_ctx != NULL); in ctxop_detach_chain()
1060 t->t_ctx = NULL; in ctxop_detach_chain()
1061 } else if (ctx == t->t_ctx) { in ctxop_detach_chain()
1063 t->t_ctx = ctx->next; in ctxop_detach_chain()
1104 ctxop_attach(kthread_t *t, struct ctxop *ctx) in ctxop_attach() argument
1130 if (t->t_ctx == NULL) { in ctxop_attach()
1134 struct ctxop *head = t->t_ctx, *tail = t->t_ctx->prev; in ctxop_attach()
1141 t->t_ctx = ctx; in ctxop_attach()
1146 ctxop_detach(kthread_t *t, struct ctxop *ctx) in ctxop_detach() argument
1163 ASSERT(t == curthread || ttoproc(t)->p_stat == SIDL || in ctxop_detach()
1164 ttoproc(t)->p_agenttp == curthread || t->t_state == TS_STOPPED); in ctxop_detach()
1170 mutex_enter(&t->t_ctx_lock); in ctxop_detach()
1173 VERIFY(t->t_ctx != NULL); in ctxop_detach()
1178 head = cur = t->t_ctx; in ctxop_detach()
1189 ctxop_detach_chain(t, ctx); in ctxop_detach()
1191 mutex_exit(&t->t_ctx_lock); in ctxop_detach()
1196 ctxop_install(kthread_t *t, const struct ctxop_template *ct, void *arg) in ctxop_install() argument
1198 ctxop_attach(t, ctxop_allocate(ct, arg)); in ctxop_install()
1202 ctxop_remove(kthread_t *t, const struct ctxop_template *ct, void *arg) in ctxop_remove() argument
1210 ASSERT(t == curthread || ttoproc(t)->p_stat == SIDL || in ctxop_remove()
1211 ttoproc(t)->p_agenttp == curthread || t->t_state == TS_STOPPED); in ctxop_remove()
1217 mutex_enter(&t->t_ctx_lock); in ctxop_remove()
1220 ctx = ctxop_find_by_tmpl(t, ct, arg); in ctxop_remove()
1222 ctxop_detach_chain(t, ctx); in ctxop_remove()
1226 mutex_exit(&t->t_ctx_lock); in ctxop_remove()
1236 savectx(kthread_t *t) in savectx() argument
1238 ASSERT(t == curthread); in savectx()
1240 if (t->t_ctx != NULL) { in savectx()
1244 ctx = head = t->t_ctx; in savectx()
1256 restorectx(kthread_t *t) in restorectx() argument
1258 ASSERT(t == curthread); in restorectx()
1260 if (t->t_ctx != NULL) { in restorectx()
1264 ctx = tail = t->t_ctx->prev; in restorectx()
1276 forkctx(kthread_t *t, kthread_t *ct) in forkctx() argument
1278 if (t->t_ctx != NULL) { in forkctx()
1282 ctx = head = t->t_ctx; in forkctx()
1285 (ctx->fork_op)(t, ct); in forkctx()
1298 lwp_createctx(kthread_t *t, kthread_t *ct) in lwp_createctx() argument
1300 if (t->t_ctx != NULL) { in lwp_createctx()
1304 ctx = head = t->t_ctx; in lwp_createctx()
1307 (ctx->lwp_create_op)(t, ct); in lwp_createctx()
1322 exitctx(kthread_t *t) in exitctx() argument
1324 if (t->t_ctx != NULL) { in exitctx()
1328 ctx = head = t->t_ctx; in exitctx()
1331 (ctx->exit_op)(t); in exitctx()
1343 freectx(kthread_t *t, int isexec) in freectx() argument
1346 if (t->t_ctx != NULL) { in freectx()
1349 ctx = head = t->t_ctx; in freectx()
1350 t->t_ctx = NULL; in freectx()
1397 setrun_locked(kthread_t *t) in setrun_locked() argument
1399 ASSERT(THREAD_LOCK_HELD(t)); in setrun_locked()
1400 if (t->t_state == TS_SLEEP) { in setrun_locked()
1404 SOBJ_UNSLEEP(t->t_sobj_ops, t); in setrun_locked()
1405 } else if (t->t_state & (TS_RUN | TS_ONPROC)) { in setrun_locked()
1410 } else if (t->t_state == TS_WAIT) { in setrun_locked()
1411 waitq_setrun(t); in setrun_locked()
1412 } else if (t->t_state == TS_STOPPED) { in setrun_locked()
1431 if ((t->t_schedflag & TS_ALLSTART) != TS_ALLSTART) in setrun_locked()
1436 t->t_whystop = 0; in setrun_locked()
1437 t->t_whatstop = 0; in setrun_locked()
1444 t->t_schedflag &= ~TS_ALLSTART; in setrun_locked()
1445 THREAD_TRANSITION(t); /* drop stopped-thread lock */ in setrun_locked()
1446 ASSERT(t->t_lockp == &transition_lock); in setrun_locked()
1447 ASSERT(t->t_wchan0 == NULL && t->t_wchan == NULL); in setrun_locked()
1451 CL_SETRUN(t); in setrun_locked()
1456 setrun(kthread_t *t) in setrun() argument
1458 thread_lock(t); in setrun()
1459 setrun_locked(t); in setrun()
1460 thread_unlock(t); in setrun()
1478 kthread_t *t = curthread; /* current thread */ in thread_unpin() local
1483 ASSERT(t->t_intr != NULL); in thread_unpin()
1485 itp = t->t_intr; /* interrupted thread */ in thread_unpin()
1486 t->t_intr = NULL; /* clear interrupt ptr */ in thread_unpin()
1495 i = intr_passivate(t, itp); in thread_unpin()
1499 i, t, t, itp, itp); in thread_unpin()
1504 t->t_lwp = NULL; in thread_unpin()
1729 tsd_agent_get(kthread_t *t, uint_t key) in tsd_agent_get() argument
1731 struct tsd_thread *tsd = t->t_tsd; in tsd_agent_get()
1733 ASSERT(t == curthread || in tsd_agent_get()
1734 ttoproc(t)->p_agenttp == curthread || t->t_state == TS_STOPPED); in tsd_agent_get()
1751 tsd_agent_set(kthread_t *t, uint_t key, void *value) in tsd_agent_set() argument
1753 struct tsd_thread *tsd = t->t_tsd; in tsd_agent_set()
1755 ASSERT(t == curthread || in tsd_agent_set()
1756 ttoproc(t)->p_agenttp == curthread || t->t_state == TS_STOPPED); in tsd_agent_set()
1761 tsd = t->t_tsd = kmem_zalloc(sizeof (*tsd), KM_SLEEP); in tsd_agent_set()
1927 thread_change_epri(kthread_t *t, pri_t disp_pri) in thread_change_epri() argument
1931 ASSERT(THREAD_LOCK_HELD(t)); in thread_change_epri()
1937 if (t->t_epri == disp_pri) in thread_change_epri()
1940 state = t->t_state; in thread_change_epri()
1946 t->t_epri = disp_pri; in thread_change_epri()
1948 cpu_t *cp = t->t_disp_queue->disp_cpu; in thread_change_epri()
1950 if (t == cp->cpu_dispthread) in thread_change_epri()
1951 cp->cpu_dispatch_pri = DISP_PRIO(t); in thread_change_epri()
1961 SOBJ_CHANGE_EPRI(t->t_sobj_ops, t, disp_pri); in thread_change_epri()
1967 if (disp_pri != t->t_epri) in thread_change_epri()
1968 waitq_change_pri(t, disp_pri); in thread_change_epri()
1976 (void) dispdeq(t); in thread_change_epri()
1977 t->t_epri = disp_pri; in thread_change_epri()
1978 setbackdq(t); in thread_change_epri()
1980 schedctl_set_cidpri(t); in thread_change_epri()
1990 thread_change_pri(kthread_t *t, pri_t disp_pri, int front) in thread_change_pri() argument
1995 ASSERT(THREAD_LOCK_HELD(t)); in thread_change_pri()
1997 state = t->t_state; in thread_change_pri()
1998 THREAD_WILLCHANGE_PRI(t, disp_pri); in thread_change_pri()
2004 t->t_pri = disp_pri; in thread_change_pri()
2007 cpu_t *cp = t->t_disp_queue->disp_cpu; in thread_change_pri()
2009 if (t == cp->cpu_dispthread) in thread_change_pri()
2010 cp->cpu_dispatch_pri = DISP_PRIO(t); in thread_change_pri()
2020 if (disp_pri != t->t_pri) in thread_change_pri()
2021 SOBJ_CHANGE_PRI(t->t_sobj_ops, t, disp_pri); in thread_change_pri()
2027 if (disp_pri != t->t_pri) in thread_change_pri()
2028 waitq_change_pri(t, disp_pri); in thread_change_pri()
2040 on_rq = dispdeq(t); in thread_change_pri()
2042 t->t_pri = disp_pri; in thread_change_pri()
2044 setfrontdq(t); in thread_change_pri()
2046 setbackdq(t); in thread_change_pri()
2049 schedctl_set_cidpri(t); in thread_change_pri()
2058 stkinfo_begin(kthread_t *t) in stkinfo_begin() argument
2068 if (t->t_stk > t->t_stkbase) { in stkinfo_begin()
2070 start = t->t_stkbase; in stkinfo_begin()
2071 end = t->t_stk; in stkinfo_begin()
2074 start = t->t_stk; in stkinfo_begin()
2075 end = t->t_stkbase; in stkinfo_begin()
2107 stkinfo_end(kthread_t *t) in stkinfo_end() argument
2137 if (t->t_stk > t->t_stkbase) { in stkinfo_end()
2139 start = t->t_stkbase; in stkinfo_end()
2140 end = t->t_stk; in stkinfo_end()
2143 start = t->t_stk; in stkinfo_end()
2144 end = t->t_stkbase; in stkinfo_end()
2166 if (t->t_stk > t->t_stkbase) { in stkinfo_end()
2201 DTRACE_PROBE3(stack__usage, kthread_t *, t, in stkinfo_end()
2236 kmem_stkinfo_log[index].kthread = (caddr_t)t; in stkinfo_end()
2237 kmem_stkinfo_log[index].t_startpc = (caddr_t)t->t_startpc; in stkinfo_end()
2241 kmem_stkinfo_log[index].t_tid = t->t_tid; in stkinfo_end()
2243 if (t->t_tid != 0) { in stkinfo_end()
2244 stksz = strlen((t->t_procp)->p_user.u_comm); in stkinfo_end()
2252 (t->t_procp)->p_user.u_comm, stksz); in stkinfo_end()
2306 thread_setname(kthread_t *t, const char *name) in thread_setname() argument
2335 mutex_enter(&ttoproc(t)->p_lock); in thread_setname()
2336 if (t->t_name == NULL) { in thread_setname()
2337 t->t_name = buf; in thread_setname()
2340 (void) strlcpy(t->t_name, name, THREAD_NAME_MAX); in thread_setname()
2343 bzero(t->t_name, THREAD_NAME_MAX); in thread_setname()
2346 mutex_exit(&ttoproc(t)->p_lock); in thread_setname()
2351 thread_vsetname(kthread_t *t, const char *fmt, ...) in thread_vsetname() argument
2367 return (thread_setname(t, name)); in thread_vsetname()