uCOS-Ⅲ study notes: time slice

1. Introduction

  1. 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

  1. The number of time slices required by the TimeQuanta task
  2. The number of time slices remaining in the TimeQuantaCtr task

Write the scheduling function OS_SchedRoundRobin() (call every TICK)

  1. Enter the critical section
  2. Read the incoming ready list head pointer task (idle task exits)
  3. 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
  4. Quit if there is only one task
  5. 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
  6. The task of reacquiring the head pointer of the ready list
  7. Exit the critical section, end the function

Three, call process

  1. Initialize
    task TCB and create variables; task TaskCreat passes in time slice parameters and initializes
  2. Call
    each Tick cycle to call the time slice scheduling function

Guess you like

Origin blog.csdn.net/qq_45396672/article/details/109473281