1 #include "kernel/system.h"
2 #include <minix/endpoint.h>
4 /*===========================================================================*
6 *===========================================================================*/
7 int do_schedctl(struct proc
* caller
, message
* m_ptr
)
11 int priority
, quantum
, cpu
;
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
);
23 if (!isokendpt(m_ptr
->m_lsys_krn_schedctl
.endpoint
, &proc_nr
))
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
)
39 p
->p_scheduler
= NULL
;
41 /* the caller becomes the scheduler */
42 p
->p_scheduler
= caller
;