Three scheduling methods linux kernel

1, SCHED_OTHER time-sharing scheduling policy,
2, SCHED_FIFO real-time scheduling strategy, first come first served
3, SCHED_RR real-time scheduling policy, round-robin

 

Time-sharing process through nice and counter value decision value, the smaller the nice, counter, the greater the probability of being scheduled, that is, who uses the fewest cpu process will be given priority scheduling

 

Real-time process will giveprioritycalls, real-time process based onreal-time prioritydecides scheduling weight

And the SCHED_FIFO different SHCED_RR:
1, when the strategy employed SHCED_RR time slice process runs out, the system will re-allocation of time slices and placed in the end of the ready queue . On the end of the queue to ensure that all scheduling fair have the same priority RR task 
2, SCHED_FIFO Once occupied cpu it has been run. Run until a higher priority task arrives or give up your own
if you have the same priority real-time processes (according to the schedule weights priority calculation is the same) is ready, the process must wait before you can give up the run-time FIFO the priority of the same task. The RR allows each task execution for some time.

SCHED_FIFO and the same point SHCED_RR:
 . 1, only the RR for real-time tasks and FIFO
 2, created when priority is greater than 0 (1-99)
 3, according to preemptible for priority scheduling algorithm
 4, real-time tasks that is ready immediately seize non-real-time tasks

all tasks using linux time-sharing scheduling policy:
1. create a task specified time-sharing scheduling policy, and assign a priority nice value ( -20 to 19 )
2, will be determined based on the value of each task in a nice cpu execution time on the (counter)
3, if there is no waiting for a resource, the task added to the ready queue
4, the scheduler traverse the ready queue task, each task by priority dynamically calculated ( counter 20 is + - Nice ) As a result, selection results the maximum one to run, the time when the sheet is used up (counter reduced to 0) or give up when the cpu, the task will be placed at the end of the ready queue (time slice expires) or a wait queue (waiting for resources abandoned cpu) in
5, then the scheduler repeats the above calculation process, go 4 step
6, when the scheduler found that the weight obtained all ready tasks calculations is not greater than 0, repeat step 2.

All tasks using FIFO when:
1, specifies the use of FIFO creating process, and set real-time priorities rt_priority (1 -99)
2, without waiting for resources, then the task is added to the ready queue
3, the scheduler traverse the ready queue, according to the real-time priority calculation scheduling weight ( 1000 + rt_priority ), select the weights of the most high task using cpu the FIFO task will always occupy cpu until there is a higher priority task is ready (even if the same priority is not OK) or give up (waiting for resources)
4, the scheduler found to have priority more TaskArrives (high priority task may be interrupted or timer task wake up, or is currently running task and then wake up, etc.), the scheduler immediately save all of the current data cpu registers in the current task stack, again from the high priority task stack register data loaded into cpu, this time the high-priority task starts to run. Repeat step 3
5, if the current task waiting for cpu resources and give up the right to use, then the task will be deleted ready queue, waiting to join the queue, then repeat step 3

for all tasks using RR scheduling strategy:
1, (designated as the RR scheduling parameters when creating a task, and set the task and the real time priority value nice nice value will be converted for the task of the length of time sheet )
2, without waiting for resources, then the task is added to the ready queue
3, the scheduler traverse the ready queue, according to the real-time priority calculation scheduling weight ( 1000 + rt_priority ), select weights highest task using CPU
. 4, if the ready queue RR task time slice 0, the value is set according to the nice the time slice task, while the task is placed in the end of the ready queue. Repeat steps 3
5 since the current task to wait for resources actively withdraw cpu, which is added to the waiting queue. Repeat step 3.

Both sharing scheduling system, there are round-robin scheduling and FIFO scheduling ( non-single scheduling ):
. 1, the RR scheduling and FIFO scheduling process belongs to real-time process, the process of time-sharing scheduling non real-time process
2, when the real-time process is ready, if the current cpu running non-real-time process, the real-time process immediately seize the non-real-time process
3, RR and FIFO processes are processes using real-time priority as the value of the right to a standard schedule, RR is an extension of FIFO . FIFO, if the two processes of the same priority, then the two priority as the specific implementation process which is determined by its position in the queue of the decision, which led to some injustice (the priority is the same, why let you keep running?), as if the two priority scheduling policy tasks are set to RR, is to ensure the implementation of these two tasks can be recycled to ensure fairness.

 

Guess you like

Origin blog.csdn.net/qq_38971487/article/details/90416960