Remove building with NOCRYPTO option
[minix.git] / minix / kernel / system / do_schedctl.c
blobdd5af75f0f83717fc83fd7cc852997f911810603
1 #include "kernel/system.h"
2 #include <minix/endpoint.h>
4 /*===========================================================================*
5 * do_schedctl *
6 *===========================================================================*/
7 int do_schedctl(struct proc * caller, message * m_ptr)
9 struct proc *p;
10 uint32_t flags;
11 int priority, quantum, cpu;
12 int proc_nr;
13 int r;
15 /* check parameter validity */
16 flags = m_ptr->m_lsys_krn_schedctl.flags;
17 if (flags & ~SCHEDCTL_FLAG_KERNEL) {
18 printf("do_schedctl: flags 0x%x invalid, caller=%d\n",
19 flags, caller - proc);
20 return EINVAL;
23 if (!isokendpt(m_ptr->m_lsys_krn_schedctl.endpoint, &proc_nr))
24 return EINVAL;
26 p = proc_addr(proc_nr);
28 if ((flags & SCHEDCTL_FLAG_KERNEL) == SCHEDCTL_FLAG_KERNEL) {
29 /* the kernel becomes the scheduler and starts
30 * scheduling the process.
32 priority = m_ptr->m_lsys_krn_schedctl.priority;
33 quantum = m_ptr->m_lsys_krn_schedctl.quantum;
34 cpu = m_ptr->m_lsys_krn_schedctl.cpu;
36 /* Try to schedule the process. */
37 if((r = sched_proc(p, priority, quantum, cpu, FALSE)) != OK)
38 return r;
39 p->p_scheduler = NULL;
40 } else {
41 /* the caller becomes the scheduler */
42 p->p_scheduler = caller;
45 return(OK);