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
= (unsigned) m_ptr
->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
->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
= (int) m_ptr
->SCHEDCTL_PRIORITY
;
33 quantum
= (int) m_ptr
->SCHEDCTL_QUANTUM
;
34 cpu
= (int) m_ptr
->SCHEDCTL_CPU
;
36 /* Try to schedule the process. */
37 if((r
= sched_proc(p
, priority
, quantum
, cpu
) != OK
))
39 p
->p_scheduler
= NULL
;
41 /* the caller becomes the scheduler */
42 p
->p_scheduler
= caller
;