#include <mach/mach_host_server.h>
#include <mach/mach_syscalls.h>
#include <sys/kdebug.h>
+#include <kern/ast.h>
#ifdef MACH_BSD
extern void workqueue_thread_yielded(void);
extern sched_call_t workqueue_get_sched_callback(void);
#endif /* MACH_BSD */
+extern wait_result_t thread_handoff_reason(thread_t thread, ast_t reason);
/* Called from commpage to take a delayed preemption when exiting
* the "Preemption Free Zone" (PFZ).
swtch_continue(void)
{
processor_t myprocessor;
- boolean_t result;
+ boolean_t result;
- disable_preemption();
+ disable_preemption();
myprocessor = current_processor();
- result = !SCHED(processor_queue_empty)(myprocessor) || rt_runq.count > 0;
+ result = SCHED(thread_should_yield)(myprocessor, current_thread());
enable_preemption();
thread_syscall_return(result);
disable_preemption();
myprocessor = current_processor();
- if (SCHED(processor_queue_empty)(myprocessor) && rt_runq.count == 0) {
+ if (!SCHED(thread_should_yield)(myprocessor, current_thread())) {
mp_enable_preemption();
return (FALSE);
disable_preemption();
myprocessor = current_processor();
- result = !SCHED(processor_queue_empty)(myprocessor) || rt_runq.count > 0;
+ result = SCHED(thread_should_yield)(myprocessor, current_thread());
enable_preemption();
return (result);
swtch_pri_continue(void)
{
processor_t myprocessor;
- boolean_t result;
+ boolean_t result;
thread_depress_abort_internal(current_thread());
- disable_preemption();
+ disable_preemption();
myprocessor = current_processor();
- result = !SCHED(processor_queue_empty)(myprocessor) || rt_runq.count > 0;
+ result = SCHED(thread_should_yield)(myprocessor, current_thread());
mp_enable_preemption();
thread_syscall_return(result);
disable_preemption();
myprocessor = current_processor();
- if (SCHED(processor_queue_empty)(myprocessor) && rt_runq.count == 0) {
+ if (!SCHED(thread_should_yield)(myprocessor, current_thread())) {
mp_enable_preemption();
return (FALSE);
disable_preemption();
myprocessor = current_processor();
- result = !SCHED(processor_queue_empty)(myprocessor) || rt_runq.count > 0;
+ result = SCHED(thread_should_yield)(myprocessor, current_thread());
enable_preemption();
return (result);
0);
myprocessor->current_pri = self->sched_pri;
+ myprocessor->current_perfctl_class = thread_get_perfcontrol_class(self);
self->sched_flags |= TH_SFLAG_DEPRESS;
if (interval != 0) {
0);
myprocessor->current_pri = self->sched_pri;
+ myprocessor->current_perfctl_class = thread_get_perfcontrol_class(self);
}
self->computation_epoch = abstime;
self->computation_metered = 0;
disable_preemption();
myprocessor = current_processor();
- if (SCHED(processor_queue_empty)(myprocessor) && rt_runq.count == 0) {
+ if (!SCHED(thread_should_yield)(myprocessor, current_thread())) {
mp_enable_preemption();
return;