static bool sched_syscall_handler(interrupt_t* state) { switch(sysc_get_call(state)) { case SysSchedule: sysc_call(state, (syscall_handler_t)sched_schedule); return true; case SysYield: sysc_call(state, (syscall_handler_t)sched_yield); return true; default: return false; } }
void sched_yield() { thread_t * thr = thr_current(); thr->state = Yielded; sysc_call(SysSchedule, 0, 0); return; }
void thr_trampoline(thread_t* thread, thread_start_t entry) { entry(); thread->state = Exited; trace("thread %d in process %d exited\n", thread->id, thread->parent->id); sysc_call(SysSchedule, 0, 0); /* never reached - as the thread is aborting, it will never be re-scheduled */ }
void thr_abort(thread_t* target) { target->state = Aborting; error("thread %d in process %d aborted!\n", target->id, target->parent->id); list_t* trace = ksym_trace(); ksym_write_trace(Error, trace); ksym_delete(trace); sysc_call(SysSchedule, 0, 0); /* never reached - as the thread is aborting, it will never be re-scheduled */ }