First-come first-served scheduling and FCFS schedulingAlgorithm(Non-preemptible)
When a process enters the ready queue, its PCB is linked to the tail of the queue. When the CPU is idle, the CPU is allocated to the process in the queue header. Then, the running process is deleted from the queue. FCFS schedulingCodeEasy to write and understand.
Shortest job priority scheduling algorithm, SJF scheduling algorithm (preemptible or non-preemptible)
When the CPU is available, it is assigned to the process with the shortest CPU range. If the two processes have CPU intervals of the same length, you can use FCFS scheduling for processing.
The SJF algorithm may be preemptible or non-preemptible. When a new process reaches the ready queue and the previous process is executing, You need to select. A new process may have a shorter CPU interval than the CPU interval generated by the current running process. The SJF algorithm can be used to seize the current running process, rather than the SJF algorithm can allow the current running process to complete its CPU range. SJF scheduling can be preemptible.Shortest remaining time Priority Scheduling.
Priority Scheduling Algorithm
Each process is associated with a priority. The process with the highest priority is allocated to the CPU. Processes with the same priority are scheduled in the FCFS sequence.
Round-Robin (RR) Scheduling Algorithm
The rotation scheduling algorithm is specially designed for time-sharing systems. It is similar to FCFS scheduling, But it increases preemption to switch between processes. Defines a small time unit, called a time volume or time slice. The time slice is usually 10 ms to 100 ms. The ready queue is processed as a cyclic queue. CPU schedulingProgramThe cyclic ready queue allocates a CPU for each process at no more than one interval.
To implement RR scheduling, the ready queue is a FIFO queue of processes. The new process is added to the end of the ready queue. The CPU scheduler selects the first process from the ready queue, sets the timer to be interrupted after a time slice, and finally assigns the process. There are two possible scenarios. A process may only need to be less than the CPU range of a time slice. In this case, the process itself automatically releases the CPU. The scheduler then processes the next process in the ready queue. In another case, the CPU interval of the current running process is longer than that of a time slice, And the timer is interrupted and the operating system is interrupted. Performs context switching. The process is added to the end of the ready queue. Then, the CPU scheduler selects the next process in the ready queue.
Multi-level queue Scheduling