/* ast_cast: */ gpointer ast_cast ( gpointer ast, ASTType type ) { ASSERT(ast); ASSERT(ast_check(ast, type)); return ast; }
void thread_quantum_expire( timer_call_param_t p0, timer_call_param_t p1) { register processor_t myprocessor = p0; register thread_t thread = p1; spl_t s; s = splsched(); thread_lock(thread); /* * Check for fail-safe trip. */ if (!(thread->sched_mode & TH_MODE_TIMESHARE)) { extern uint64_t max_unsafe_computation; uint64_t new_computation; new_computation = myprocessor->quantum_end; new_computation -= thread->computation_epoch; if (new_computation + thread->computation_metered > max_unsafe_computation) { extern uint32_t sched_safe_duration; if (thread->sched_mode & TH_MODE_REALTIME) { thread->priority = DEPRESSPRI; thread->safe_mode |= TH_MODE_REALTIME; thread->sched_mode &= ~TH_MODE_REALTIME; } pset_share_incr(thread->processor_set); thread->safe_release = sched_tick + sched_safe_duration; thread->sched_mode |= (TH_MODE_FAILSAFE|TH_MODE_TIMESHARE); thread->sched_mode &= ~TH_MODE_PREEMPT; } } /* * Recompute scheduled priority if appropriate. */ if (thread->sched_stamp != sched_tick) update_priority(thread); else if (thread->sched_mode & TH_MODE_TIMESHARE) { thread_timer_delta(thread); thread->sched_usage += thread->sched_delta; thread->sched_delta = 0; /* * Adjust the scheduled priority if * the thread has not been promoted * and is not depressed. */ if ( !(thread->sched_mode & TH_MODE_PROMOTED) && !(thread->sched_mode & TH_MODE_ISDEPRESSED) ) compute_my_priority(thread); } /* * This quantum is up, give this thread another. */ if (first_timeslice(myprocessor)) myprocessor->timeslice--; thread_quantum_init(thread); myprocessor->quantum_end += thread->current_quantum; timer_call_enter1(&myprocessor->quantum_timer, thread, myprocessor->quantum_end); thread_unlock(thread); /* * Check for and schedule ast if needed. */ ast_check(myprocessor); splx(s); }