- {
- s = splsched();
- thread_lock(thread);
-
- if (!(thread->policy & (POLICY_TIMESHARE|POLICY_RR|POLICY_FIFO))) {
- thread_unlock(thread);
- splx(s);
- return;
- }
-
- if (thread->state&TH_IDLE) {
- /* Don't try to time-slice idle threads */
- myprocessor->first_quantum = TRUE;
- if (thread->sched_stamp != sched_tick)
- update_priority(thread);
- thread_unlock(thread);
- splx(s);
- ast_check();
- return;
- }
-
- myprocessor->quantum -= nticks;
- /*
- * Runtime quantum adjustment. Use quantum_adj_index
- * to avoid synchronizing quantum expirations.
- */
- if ( quantum != myprocessor->last_quantum &&
- pset->processor_count > 1 ) {
- myprocessor->last_quantum = quantum;
- simple_lock(&pset->quantum_adj_lock);
- quantum = min_quantum + (pset->quantum_adj_index *
- (quantum - min_quantum)) /
- (pset->processor_count - 1);
- if (++(pset->quantum_adj_index) >= pset->processor_count)
- pset->quantum_adj_index = 0;
- simple_unlock(&pset->quantum_adj_lock);
- }
- if (myprocessor->quantum <= 0) {
- if (thread->sched_stamp != sched_tick)
- update_priority(thread);
- else
- if ( thread->policy == POLICY_TIMESHARE &&
- thread->depress_priority < 0 ) {
- thread_timer_delta(thread);
- thread->sched_usage += thread->sched_delta;
- thread->sched_delta = 0;
- compute_my_priority(thread);
- }