xref: /minix3/minix/kernel/system/do_schedule.c (revision 366d18b2b85b51f93b2a90700336b4a150a9149d)
1433d6423SLionel Sambuc #include "kernel/system.h"
2433d6423SLionel Sambuc #include <minix/endpoint.h>
3433d6423SLionel Sambuc #include "kernel/clock.h"
4433d6423SLionel Sambuc 
5433d6423SLionel Sambuc /*===========================================================================*
6433d6423SLionel Sambuc  *				do_schedule				     *
7433d6423SLionel Sambuc  *===========================================================================*/
do_schedule(struct proc * caller,message * m_ptr)8433d6423SLionel Sambuc int do_schedule(struct proc * caller, message * m_ptr)
9433d6423SLionel Sambuc {
10433d6423SLionel Sambuc 	struct proc *p;
11433d6423SLionel Sambuc 	int proc_nr;
12*366d18b2SDavid van Moolenbroek 	int priority, quantum, cpu, niced;
13433d6423SLionel Sambuc 
14433d6423SLionel Sambuc 	if (!isokendpt(m_ptr->m_lsys_krn_schedule.endpoint, &proc_nr))
15433d6423SLionel Sambuc 		return EINVAL;
16433d6423SLionel Sambuc 
17433d6423SLionel Sambuc 	p = proc_addr(proc_nr);
18433d6423SLionel Sambuc 
19433d6423SLionel Sambuc 	/* Only this process' scheduler can schedule it */
20433d6423SLionel Sambuc 	if (caller != p->p_scheduler)
21433d6423SLionel Sambuc 		return(EPERM);
22433d6423SLionel Sambuc 
23433d6423SLionel Sambuc 	/* Try to schedule the process. */
24433d6423SLionel Sambuc 	priority = m_ptr->m_lsys_krn_schedule.priority;
25433d6423SLionel Sambuc 	quantum = m_ptr->m_lsys_krn_schedule.quantum;
26433d6423SLionel Sambuc 	cpu = m_ptr->m_lsys_krn_schedule.cpu;
27*366d18b2SDavid van Moolenbroek 	niced = !!(m_ptr->m_lsys_krn_schedule.niced);
28433d6423SLionel Sambuc 
29*366d18b2SDavid van Moolenbroek 	return sched_proc(p, priority, quantum, cpu, niced);
30433d6423SLionel Sambuc }
31