Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/sched_ule.c
Show First 20 Lines • Show All 1,457 Lines • ▼ Show 20 Lines | #ifdef SMP | ||||
sched_setup_smp(); | sched_setup_smp(); | ||||
#else | #else | ||||
tdq_setup(TDQ_SELF(), 0); | tdq_setup(TDQ_SELF(), 0); | ||||
#endif | #endif | ||||
tdq = TDQ_SELF(); | tdq = TDQ_SELF(); | ||||
/* Add thread0's load since it's running. */ | /* Add thread0's load since it's running. */ | ||||
TDQ_LOCK(tdq); | TDQ_LOCK(tdq); | ||||
thread0.td_lock = TDQ_LOCKPTR(TDQ_SELF()); | thread0.td_lock = TDQ_LOCKPTR(tdq); | ||||
tdq_load_add(tdq, &thread0); | tdq_load_add(tdq, &thread0); | ||||
tdq->tdq_lowpri = thread0.td_priority; | tdq->tdq_lowpri = thread0.td_priority; | ||||
TDQ_UNLOCK(tdq); | TDQ_UNLOCK(tdq); | ||||
} | } | ||||
/* | /* | ||||
* This routine determines time constants after stathz and hz are setup. | * This routine determines time constants after stathz and hz are setup. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 1,433 Lines • ▼ Show 20 Lines | #ifdef SMP | ||||
PCPU_SET(sched, DPCPU_PTR(tdq)); | PCPU_SET(sched, DPCPU_PTR(tdq)); | ||||
#endif | #endif | ||||
/* Correct spinlock nesting and acquire the correct lock. */ | /* Correct spinlock nesting and acquire the correct lock. */ | ||||
tdq = TDQ_SELF(); | tdq = TDQ_SELF(); | ||||
TDQ_LOCK(tdq); | TDQ_LOCK(tdq); | ||||
spinlock_exit(); | spinlock_exit(); | ||||
PCPU_SET(switchtime, cpu_ticks()); | PCPU_SET(switchtime, cpu_ticks()); | ||||
PCPU_SET(switchticks, ticks); | PCPU_SET(switchticks, ticks); | ||||
PCPU_GET(idlethread)->td_lock = TDQ_LOCKPTR(tdq); | |||||
} else { | } else { | ||||
tdq = TDQ_SELF(); | tdq = TDQ_SELF(); | ||||
MPASS(td->td_lock == TDQ_LOCKPTR(tdq)); | MPASS(td->td_lock == TDQ_LOCKPTR(tdq)); | ||||
tdq_load_rem(tdq, td); | tdq_load_rem(tdq, td); | ||||
lock_profile_release_lock(&TDQ_LOCKPTR(tdq)->lock_object); | lock_profile_release_lock(&TDQ_LOCKPTR(tdq)->lock_object); | ||||
td->td_lastcpu = td->td_oncpu; | td->td_lastcpu = td->td_oncpu; | ||||
td->td_oncpu = NOCPU; | td->td_oncpu = NOCPU; | ||||
} | } | ||||
Show All 14 Lines | sched_fork_exit(struct thread *td) | ||||
int cpuid; | int cpuid; | ||||
/* | /* | ||||
* Finish setting up thread glue so that it begins execution in a | * Finish setting up thread glue so that it begins execution in a | ||||
* non-nested critical section with the scheduler lock held. | * non-nested critical section with the scheduler lock held. | ||||
*/ | */ | ||||
cpuid = PCPU_GET(cpuid); | cpuid = PCPU_GET(cpuid); | ||||
tdq = TDQ_SELF(); | tdq = TDQ_SELF(); | ||||
if (TD_IS_IDLETHREAD(td)) | |||||
td->td_lock = TDQ_LOCKPTR(tdq); | |||||
MPASS(td->td_lock == TDQ_LOCKPTR(tdq)); | MPASS(td->td_lock == TDQ_LOCKPTR(tdq)); | ||||
td->td_oncpu = cpuid; | td->td_oncpu = cpuid; | ||||
TDQ_LOCK_ASSERT(tdq, MA_OWNED | MA_NOTRECURSED); | TDQ_LOCK_ASSERT(tdq, MA_OWNED | MA_NOTRECURSED); | ||||
lock_profile_obtain_lock_success( | lock_profile_obtain_lock_success( | ||||
&TDQ_LOCKPTR(tdq)->lock_object, 0, 0, __FILE__, __LINE__); | &TDQ_LOCKPTR(tdq)->lock_object, 0, 0, __FILE__, __LINE__); | ||||
KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "running", | KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "running", | ||||
"prio:%d", td->td_priority); | "prio:%d", td->td_priority); | ||||
▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines |