1*433d6423SLionel Sambuc #include "kernel/system.h" 2*433d6423SLionel Sambuc #include <minix/endpoint.h> 3*433d6423SLionel Sambuc #include "kernel/clock.h" 4*433d6423SLionel Sambuc 5*433d6423SLionel Sambuc /*===========================================================================* 6*433d6423SLionel Sambuc * do_schedule * 7*433d6423SLionel Sambuc *===========================================================================*/ 8*433d6423SLionel Sambuc int do_schedule(struct proc * caller, message * m_ptr) 9*433d6423SLionel Sambuc { 10*433d6423SLionel Sambuc struct proc *p; 11*433d6423SLionel Sambuc int proc_nr; 12*433d6423SLionel Sambuc int priority, quantum, cpu; 13*433d6423SLionel Sambuc 14*433d6423SLionel Sambuc if (!isokendpt(m_ptr->m_lsys_krn_schedule.endpoint, &proc_nr)) 15*433d6423SLionel Sambuc return EINVAL; 16*433d6423SLionel Sambuc 17*433d6423SLionel Sambuc p = proc_addr(proc_nr); 18*433d6423SLionel Sambuc 19*433d6423SLionel Sambuc /* Only this process' scheduler can schedule it */ 20*433d6423SLionel Sambuc if (caller != p->p_scheduler) 21*433d6423SLionel Sambuc return(EPERM); 22*433d6423SLionel Sambuc 23*433d6423SLionel Sambuc /* Try to schedule the process. */ 24*433d6423SLionel Sambuc priority = m_ptr->m_lsys_krn_schedule.priority; 25*433d6423SLionel Sambuc quantum = m_ptr->m_lsys_krn_schedule.quantum; 26*433d6423SLionel Sambuc cpu = m_ptr->m_lsys_krn_schedule.cpu; 27*433d6423SLionel Sambuc 28*433d6423SLionel Sambuc return sched_proc(p, priority, quantum, cpu); 29*433d6423SLionel Sambuc } 30