Process Scheduling

Process blocks when it make request for input, and allow other process to run.

When input becomes available, current running process is interrupted by the disk, keyboard and other hardware.

Clock also generates interrupts.

Lower layer of minix3 hides these interrupts by turning them into messages. When Input/Oputput device completes an operation , it sends a message to some process, waking it up and making it eligible to run. Interrupts generated by softwares are called traps. The send and receive operation are translated by system library into software interrupts instructions which has exactly same effect as hardware generated interrupts. The process that executes software interrupts is immediately blocked and the kernel is activated to process the interrupt

Minix3 uses multilevel queuing system for scheduling. Sixteen queues are defined, the lowest priority queue is used only by the idle process. User process start by default in a queue several levels higher than the lowest one. Server processes have higher priorities than user processes and drivers have higher priorities than servers and clock and system task have highest priority.

User process has relatively low quantum, and drivers and servers should run until they block but they are given higher quantum inorder to prevent malfunctioning. If the process use entire quantum, the process whether user, driver or server they are preempted inorder to not to hang the system.

If a process has used consecutive quantums and still did not exit then, this is taken as a sign that the process is stuck in an infinite loop and its priority is lowered and gets a chance to run. A process can be promoted to higher priority queue if a process uses all its quantum but not preventing other processes from running (upto maximum priority permitted for it).

If a process has not used its entire quantum and blocked, then it means it got blocked waiting for i/o. After i/o is complete the process is put at the head of the queue with remaining time quantum. The process that has used the entire time quantum is placed at the end of the queue.

User processes will not run until all the system processes has nothing to do (user process can not prevent running of system process)

When picking a process to run, scheduler checks the highest priority queue. If one or more processes are ready, then the process at the head is executed. If no process than the next lower level priority queue is similarly tested. If no process is ready

At each clock tick, check is made to see if the current process is has run for more than the alloted quantum. If yes, then scheduler moves the process to the end of the queue. Drivers and servers are given time quantum large enough that they are never preempted by the clock.



Reference: