2 #include <minix/callnr.h>
4 #include <minix/config.h>
5 #include <minix/sysinfo.h>
6 #include <minix/type.h>
7 #include <machine/archtypes.h>
10 #include "kernel/proc.h" /* for MIN_USER_Q */
12 PRIVATE timer_t sched_timer
;
15 * makes a kernel call that schedules the process using the actuall scheduling
16 * parameters set for this process
18 PUBLIC
int schedule_process(struct mproc
* rmp
)
22 if ((err
= sys_schedule(rmp
->mp_endpoint
, rmp
->mp_priority
,
23 rmp
->mp_time_slice
)) != OK
) {
24 printf("PM: An error occurred when trying to schedule %s: %d\n",
31 /*===========================================================================*
33 *===========================================================================*/
35 PUBLIC
void do_noquantum(void)
38 register struct mproc
*rmp
;
40 if (pm_isokendpt(m_in
.m_source
, &proc_nr_n
) != OK
) {
41 printf("PM: WARNING: got an invalid endpoint in OOQ msg %u.\n",
46 rmp
= &mproc
[proc_nr_n
];
47 if (rmp
->mp_priority
< MIN_USER_Q
) {
48 rmp
->mp_priority
+= 1; /* lower priority */
51 schedule_process(rmp
);
54 /*===========================================================================*
55 * takeover_scheduling *
56 *===========================================================================*/
57 PUBLIC
void takeover_scheduling(void)
62 tmr_inittimer(&sched_timer
);
64 for (proc_nr
=0, trmp
=mproc
; proc_nr
< NR_PROCS
; proc_nr
++, trmp
++) {
65 /* Don't takeover system processes. When the system starts,
66 * this will typically only takeover init, from which other
67 * user space processes will inherit. */
68 if (trmp
->mp_flags
& IN_USE
&& !(trmp
->mp_flags
& PRIV_PROC
)) {
69 if (sys_schedctl(trmp
->mp_endpoint
))
70 printf("PM: Error while taking over scheduling for %s\n",
72 trmp
->mp_flags
|= PM_SCHEDULED
;
76 pm_set_timer(&sched_timer
, 100, balance_queues
, 0);
79 /*===========================================================================*
81 *===========================================================================*/
83 PUBLIC
void balance_queues(tp
)
90 for (proc_nr
=0, rmp
=mproc
; proc_nr
< NR_PROCS
; proc_nr
++, rmp
++) {
91 if (rmp
->mp_flags
& IN_USE
) {
92 if (rmp
->mp_priority
> rmp
->mp_max_priority
) {
93 rmp
->mp_priority
-= 1; /* increase priority */
94 schedule_process(rmp
);
99 pm_set_timer(&sched_timer
, 100, balance_queues
, 0);