The Minix scheduling policy is determined by the sched function:
1 2 PRIVATE void sched(rp, queue, front) 3 register struct proc *rp;/* process to be scheduled */ 4 int *queue;/* return: queue to use */ 5 int *front;/* return: front or back */ 6 { 7 /* This function determines the scheduling policy. It is called 8 whenever a 9 * process must be added to one of the scheduling queues to decide 10 where to 11 * insert it. As a side-effect the process' priority may be updated. 12 */ 13 int time_left = (rp->p_ticks_left > 0);/* quantum fully consumed 14 */ 15 16 /* Check whether the process has time left. Otherwise give a new 17 quantum 18 * and lower the process' priority, unless the process already is in 19 the 20 * lowest queue. 21 */ 22 if (! time_left) {/* quantum consumed ? */ 23 rp->p_ticks_left = rp->p_quantum_size; /* give new quantum */ 24 if (rp->p_priority < (IDLE_Q-1)) { 25 rp->p_priority += 1;/* lower priority */ 26 } 27 } 28 29 /* If there is time left, the process is added to the front of its 30 queue, 31 * so that it can immediately run. The queue to use simply is always 32 the 33 * process' current priority. 34 */ 35 *queue = rp->p_priority; 36 *front = time_left; 37 }