-#if CONFIG_SCHED_IDLE_IN_PLACE
-/*
- * thread_select_idle:
- *
- * Idle the processor using the current thread context.
- *
- * Called with thread locked, then dropped and relocked.
- */
-static thread_t
-thread_select_idle(
- thread_t thread,
- processor_t processor)
-{
- thread_t new_thread;
- uint64_t arg1, arg2;
- int urgency;
-
- sched_run_decr(thread);
-
- thread->state |= TH_IDLE;
- processor_state_update_idle(procssor);
-
- /* Reload precise timing global policy to thread-local policy */
- thread->precise_user_kernel_time = use_precise_user_kernel_time(thread);
-
- thread_unlock(thread);
-
- /*
- * Switch execution timing to processor idle thread.
- */
- processor->last_dispatch = mach_absolute_time();
-
-#ifdef CONFIG_MACH_APPROXIMATE_TIME
- commpage_update_mach_approximate_time(processor->last_dispatch);
-#endif
-
- thread->last_run_time = processor->last_dispatch;
- processor_timer_switch_thread(processor->last_dispatch,
- &processor->idle_thread->system_timer);
- PROCESSOR_DATA(processor, kernel_timer) = &processor->idle_thread->system_timer;
-
-
- /*
- * Cancel the quantum timer while idling.
- */
- timer_call_quantum_timer_cancel(&processor->quantum_timer);
- processor->first_timeslice = FALSE;
-
- if (thread->sched_call) {
- (*thread->sched_call)(SCHED_CALL_BLOCK, thread);
- }
-
- thread_tell_urgency(THREAD_URGENCY_NONE, 0, 0, 0, NULL);
-
- /*
- * Enable interrupts and perform idling activities. No
- * preemption due to TH_IDLE being set.
- */
- spllo(); new_thread = processor_idle(thread, processor);
-
- /*
- * Return at splsched.
- */
- if (thread->sched_call) {
- (*thread->sched_call)(SCHED_CALL_UNBLOCK, thread);
- }
-
- thread_lock(thread);
-
- /*
- * If awakened, switch to thread timer and start a new quantum.
- * Otherwise skip; we will context switch to another thread or return here.
- */
- if (!(thread->state & TH_WAIT)) {
- uint64_t time_now = processor->last_dispatch = mach_absolute_time();
- processor_timer_switch_thread(time_now, &thread->system_timer);
- timer_update(&thread->runnable_timer, time_now);
- PROCESSOR_DATA(processor, kernel_timer) = &thread->system_timer;
- thread_quantum_init(thread);
- processor->quantum_end = time_now + thread->quantum_remaining;
- timer_call_quantum_timer_enter(&processor->quantum_timer,
- thread, processor->quantum_end, time_now);
- processor->first_timeslice = TRUE;
-
- thread->computation_epoch = time_now;
- }
-
- thread->state &= ~TH_IDLE;
-
- urgency = thread_get_urgency(thread, &arg1, &arg2);
-
- thread_tell_urgency(urgency, arg1, arg2, 0, new_thread);
-
- sched_run_incr(thread);
-
- return (new_thread);
-}
-#endif /* CONFIG_SCHED_IDLE_IN_PLACE */
-