The pick_proc function simply selects the highest priority process to run:
1 2 PRIVATE void pick_proc() 3 { 4 /* Decide who to run now. A new process is selected by setting 5 'next_ptr'. 6 * When a billable process is selected, record it in 'bill_ptr', so 7 that the 8 * clock task can tell who to bill for system time. 9 */ 10 register struct proc *rp;/* process to run */ 11 int q;/* iterate over queues */ 12 13 /* Check each of the scheduling queues for ready processes. The 14 number of 15 * queues is defined in proc.h, and priorities are set in the task 16 table. 17 * The lowest queue contains IDLE, which is always ready. 18 */ 19 for (q=0; q < NR_SCHED_QUEUES; q++) { 20 if ( (rp = rdy_head[q]) != NIL_PROC) { 21 next_ptr = rp;/* run process 'rp' next */ 22 if (priv(rp)->s_flags & BILLABLE) 23 bill_ptr = rp;/* bill for system time */ 24 return; 25 } 26 } 27 }