【RST笔记6】scheduler

Define and Goal

Scheduling is the act of choosing which event to process at a given time (which task to execute at a given time).
Goal: Guarantee that a set of tasks sharing resources meet their deadlines.

Preemptive抢占式调度 vs Non-preemptive非抢占式调度

  • Preemptive:
    preemptive scheduling task execution can be stopped (and later resumed) by the scheduler【调度员控制】
    Faster response times for higher-priority processes.【快速响应,高优先级】
    Higher overhead (more context switching and scheduling overhead)【调度开销大】
  • Non-preemptive:
    once a task has started it continues until it terminates or suspends itself. 【除非任务被terminates终结或suspends中止】
    Response times are more predictable, but are slower overall.【好预测,但是慢】
    Less overhead (less context switching and scheduling overhead).【调度开销小】

Run-time Executives 执行指令

How does the scheduler decide on the next task to execute?

  • Priority-based: tasks executed in order of priority.
  • Non-priority-based: tasks executed in order determined by other factors.

在这里插入图片描述

Non-prioritised Scheduling 非抢占式调度

Cyclic Scheduling
Each task runs until it finishes, at which point the next task runs, and so on.

Advantages

  • No synchronisation is required since tasks cannot be preempted.
  • Low overhead (no context switching or scheduling overhead).
  • Execution is fully deterministic/predictable.

Disadvantages

  • Long tasks can delay shorter but more critical tasks.
  • Problems can arise if one task gets stuck.
Timed Cyclic Scheduling
Same as cyclic, but each cycle starts after a fixed period.

Advantages

  • No synchronisation is required since tasks cannot be preempted.
  • Execution is predictable

Disadvantages

  • Hard to incorporate long tasks (need to split up tasks with long execution times).
  • Hard to construct schedule (especially as number of tasks increases).
  • Difficult to maintain (must reconstruct schedule even for minor changes).
Round-Robin Scheduling
Each task is allotted a slice of CPU time in cyclical order

Advantages

  • If time-slices are long this becomes like cyclic scheduling (i.e., no-preemption).

Disadvantages

  • If time slices are short this: becomes inefficient due to excessive context changes.

Prioritised Scheduling 抢占式调度

Preemptive Priority
Higher priority tasks preempt lower priority ones, as soon as they need to execute (lower priority task resume once higher priority task completes).

Advantages

  • More responsive for high-priority tasks.

Disadvantages

  • Low priority tasks can suffer starvation.

Priority Assignment:Dynamically (at run-time) and Statically (at compile-time)

  1. Static Priority:
    在这里插入图片描述
  2. dymadic
    在这里插入图片描述

Priority Inversion 优先级倒置

With static priority assignment a higher-priority task can be suspended waiting for a lower-priority task to perform some operation.
→ The priorities of the tasks are undermined. The higher-priority task is said to be blocked, and the situation is known as priority inversion.

Priority inversion can be overcome by allowing tasks to temporarily increase priority to prevent blocking.

Two ways to do this are:

  1. Priority Inheritance【优先级继承】 - temporary priority is that of highest priority task that is
    being blocked e.g., if task A is blocking task D, then A runs with D’s priority.【a堵了d,a就继承d的优先级】
    2.Immediate Ceiling Priority Inheritance【立即天花板继承】 - temporary priority depends on the
    resource:
    I Each resource has a static ceiling value defined, this is the maximum priority of all
    the tasks that use it.
    I A task’s priority is the maximum of its own static priority and the ceiling values of
    any resources it has locked.
    e.g., if the highest priority task to use resource Q has a priority of 4, then any task
    using Q will have a priority of 4 while it does so.【如果使用资源Q的task中,最高优先度为4,那么所有tasks都是优先4】

名词

synchronisation 同步

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值