Time slice is to achieve the function of multiple tasks under the same priority. In this priority, each task runs the corresponding task time slice and executes them in turn to achieve the effect of sharing time. The idea of time slice scheduling is to no longer prioritize. Tasks are switched in sequence and within a given period of time. This task scheduling idea is very similar to that of large operating systems such as Linux.
2. Set time slice related functions and variables
Task TCB adds related variable storage time slice size
The number of time slices required by the TimeQuanta task
The number of time slices remaining in the TimeQuantaCtr task
Write the scheduling function OS_SchedRoundRobin() (call every TICK)
Enter the critical section
Read the incoming ready list head pointer task (idle task exits)
The number of time slices (TimeQuantaCtr) of task TCB is reduced
After subtracting the remaining time slice is not 0, exit the critical section function ends
After the decrement, the time slice is 0 and the execution continues
Quit if there is only one task
The time slice is 0, so the execution here puts the task at the last node of the linked list of the ready list here
The task of reacquiring the head pointer of the ready list
Exit the critical section, end the function
Three, call process
Initialize task TCB and create variables; task TaskCreat passes in time slice parameters and initializes
Call each Tick cycle to call the time slice scheduling function