Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/kern_thread.c
Show First 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
thread_ctor(void *mem, int size, void *arg, int flags) | thread_ctor(void *mem, int size, void *arg, int flags) | ||||
{ | { | ||||
struct thread *td; | struct thread *td; | ||||
td = (struct thread *)mem; | td = (struct thread *)mem; | ||||
td->td_state = TDS_INACTIVE; | td->td_state = TDS_INACTIVE; | ||||
td->td_lastcpu = td->td_oncpu = NOCPU; | td->td_lastcpu = td->td_oncpu = NOCPU; | ||||
td->td_allocdomain = vm_phys_domain(vtophys(td)); | |||||
/* | /* | ||||
* Note that td_critnest begins life as 1 because the thread is not | * Note that td_critnest begins life as 1 because the thread is not | ||||
* running and is thereby implicitly waiting to be on the receiving | * running and is thereby implicitly waiting to be on the receiving | ||||
* end of a context switch. | * end of a context switch. | ||||
*/ | */ | ||||
td->td_critnest = 1; | td->td_critnest = 1; | ||||
td->td_lend_user_pri = PRI_MAX; | td->td_lend_user_pri = PRI_MAX; | ||||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | |||||
* Place an unused thread on the zombie list. | * Place an unused thread on the zombie list. | ||||
*/ | */ | ||||
void | void | ||||
thread_zombie(struct thread *td) | thread_zombie(struct thread *td) | ||||
{ | { | ||||
struct thread_domain_data *tdd; | struct thread_domain_data *tdd; | ||||
struct thread *ztd; | struct thread *ztd; | ||||
tdd = &thread_domain_data[vm_phys_domain(vtophys(td))]; | tdd = &thread_domain_data[td->td_allocdomain]; | ||||
ztd = atomic_load_ptr(&tdd->tdd_zombies); | ztd = atomic_load_ptr(&tdd->tdd_zombies); | ||||
for (;;) { | for (;;) { | ||||
td->td_zombie = ztd; | td->td_zombie = ztd; | ||||
if (atomic_fcmpset_rel_ptr((uintptr_t *)&tdd->tdd_zombies, | if (atomic_fcmpset_rel_ptr((uintptr_t *)&tdd->tdd_zombies, | ||||
(uintptr_t *)&ztd, (uintptr_t)td)) | (uintptr_t *)&ztd, (uintptr_t)td)) | ||||
break; | break; | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,144 Lines • Show Last 20 Lines |