FreeRTOS Task 调度算法

    技术2022-07-11  126

    FreeRTOS Task 调度算法

    简介调度算法Round Robin SchedulingFixed Priority Pre-emptive Scheduling with Time SlicingFixed Priority Pre-emptive Scheduling without Time SlicingCo-operative Scheduling 任务切换时机

    简介

    本文总结FreeRTOS 任务调度算法。 时间调度算法决定那个就绪状态的任务切换为运行状态。

    调度算法

    Round Robin Scheduling

    该算法保证相同优先级的任务依次进入运行状态(采用’take it in turn ’ 策略)。

    缺点: 不能保证相同优先级的任务执行时间是相等的,只能保证位于就绪状态的任务依次进入运行状态。

    Fixed Priority Pre-emptive Scheduling with Time Slicing

    固定优先级抢占时间片调度算法。 ‘固定优先级’ 指 不改变任务的优先级。 ‘抢占’ 指的是当有更高优先级任务进入就绪状态(优先级高于当前执行任务的优先级), 当前执行状态的任务被抢占, 将有执行状态切换到就绪状态,处于就绪状态的更高优先级任务进入执行状态。 ‘时间片’ 用于具有同一个优先级的任务分享处理时间。

    Fixed Priority Pre-emptive Scheduling without Time Slicing

    不带时间片的调度算法选择任务进入执行状态的策略:

    更高优先级的任务进入就绪状态。处于执行状态的任务进入阻塞或挂起状态。

    Co-operative Scheduling

    不允许进行任务抢占。处于就绪状态的优先级任务还是先执行。

    任务切换时机

    参考FreeRTOS 说明。 It is important to note that the end of a time slice is not the only place that the scheduler can select a new task to run; as will be demonstrated throughout this book, the scheduler will also select a new task to run immediately after the currently executing task enters the Blocked state, or when an interrupt moves a higher priority task into the Ready state

    抢占:立即抢占当前真正执行的任务。 时间片调度:调度器在每个时间篇选择task执行。

    Processed: 0.010, SQL: 9