Process scheduling is when a thread – state process gains access to the CPU and the process transitions from a ready state to a running state.

Process scheduling can be divided into:

A preemptive system is scheduled according to the priority of processes, and processes can skip queues. A non-preemptive system is scheduled on a first-come-first-served basis, and processes cannot skip queues

There are many process scheduling algorithms, and the most commonly used scheduling algorithms are as follows:

1. First come first serve (FCFS)

The first coming process is scheduled first. This algorithm is fair, but if a long job is executed, then the next short job will be put on hold for a long time, causing short job hunger.

2. Shortest Job First First (SJF)

In order to avoid short homework hunger, on the priority of short homework are completed, and then executive homework. This leads to another problem, which is that if there are too many short jobs, the long jobs will not be performed, which leads to long job hunger.

3, time slice round serve (RS)

Time slice rotation is polling, defining the length of a time slice, and then allocating time slices to each process on an average basis. Once the time slice is used up and the job is not finished executing, the job will change from running state to ready state, waiting to be rescheduled. If there are more jobs, it is easy to cause long jobs need to rotate for a long time to complete.

4. Multi-level feedback queue

The algorithm sets different queues, which can be classified into high, medium and low priority queues. The higher the priority is, the shorter the allocated time slice will be; otherwise, the lower the priority is, the longer the allocated time slice will be. First, advanced projects are given high priority; If it is not finished, it will be pushed to the middle priority queue. Push into the low priority queue if it is not done yet. Processes in the current queue cannot be executed until the previous queue has finished executing.

This algorithm is still not effective in avoiding long job starvation because the next level of queue will be executed only if the high-priority queue has no process. If the queue at the previous level has processes all the time, the processes in the queue at the next level will be hungry.

5, high response ratio priority

This algorithm is based on the short-job priority scheduling algorithm and a weight mechanism which is superimposed over time.

Processes execute in order of priority, but to ensure that processes that wait a long time are also executed, the weight of processes is updated based on how long they wait. The longer the waiting time, the higher the weight.

This algorithm can not only give priority to the completion of short work, but also ensure that long work will not be long-term hunger, which is a compromise algorithm.