20-Scheduling Schemes - EDF-RMS & Hybrid Techniques,-08!04!2024
20-Scheduling Schemes - EDF-RMS & Hybrid Techniques,-08!04!2024
20-Scheduling Schemes - EDF-RMS & Hybrid Techniques,-08!04!2024
interrupt
There are two main types of RTOS task scheduling algorithms: pre-
emptive and non-preemptive.
Preemptive scheduling algorithms-
allow the RTOS to interrupt a running task and switch to a higher-
priority task. This is important for ensuring that critical tasks meet their
deadlines, even if lower-priority tasks are already running.
Non-preemptive scheduling algorithms-
do not allow the RTOS to interrupt a running task. This can be useful for
tasks that need to run to completion without being interrupted, but it can
also lead to missed deadlines for higher-priority tasks if a lower-priority
task takes a long time to complete.
In addition to preemption, RTOS task scheduling algorithms also
consider the following factors:
Task priority:
Each task in an RTOS is assigned a priority. Higher-priority tasks are
always scheduled to run before lower-priority tasks.
Task deadline:
Some RTOS task scheduling algorithms also consider the deadlines of
tasks when making scheduling decisions. For example, a deadline-based
scheduling algorithm might give priority to tasks that are closer to their
deadlines.
Task execution time:
Some RTOS task scheduling algorithms also consider the estimated
execution time of tasks when making scheduling decisions. This can
help to ensure that all tasks are scheduled to complete within their
deadlines.
Resource availability:
Some tasks may require resources, such as memory or peripherals. The
RTOS scheduler will only schedule tasks if the required resources are
available
RTOS task scheduling algorithms are complex and must be carefully designed to
meet the specific needs of the real-time system. Some common RTOS task
scheduling algorithms include:
Priority-based scheduling:
This is the most common type of RTOS task scheduling algorithm. It simply
assigns a priority to each task and schedules the task with the highest priority to
run first.
Round-robin scheduling:
This algorithm gives each task an equal amount of time to run, regardless of its
priority. This can be useful for tasks that need to be executed periodically, but it
can also lead to missed deadlines for higher-priority tasks.
Deadline-based scheduling:
This algorithm schedules tasks based on their deadlines. Tasks with earlier
deadlines are scheduled to run first. This algorithm can help to ensure that all
tasks meet their deadlines, but it can be complex to implement.
RTOS task scheduling is a critical part of any real-time system. By carefully designing the task scheduler,
developers can ensure that their system meets its performance and reliability requirements.
The following is a more detailed explanation of the task scheduling process in an RTOS:
Task creation:
When an RTOS application starts up, it creates a number of tasks. Each task is assigned a priority and a stack
space.
Task state:
Each task can be in one of three states: ready, running, or blocked. A task is in the ready state if it is waiting to be
executed. A task is in the running state if it is currently being executed. A task is in the blocked state if it is waiting
for an event to occur before it can continue executing.
Scheduling decision:
When a task becomes ready, the scheduler decides which task to run next. The scheduler typically uses the task
scheduling algorithm to make this decision.
Context switching:
If the scheduler decides to run a different task, it must perform a context switch. This involves saving the state of
the current task and restoring the state of the new task.
Task execution:
The scheduler starts executing the selected task. The task runs until it finishes executing, or until it is preempted by
a higher priority task.
Task deletion:
When a task finishes executing, it is deleted.
There are two major ways to assign priorities
● Static priorities- The priorities of the task that do not change during
execution are called as static priorities. Once the Priority of the task is assigned,
its value is retained till the end or completion of task.
Example: Rate Monotonic Scheduling (RMS)
● Dynamic priorities– The priorities of the task that are dynamically changing
during the execution are called as dynamic priorities. These priorities will change
at each and every instant of time based on the current scenario.
P1 3 20
P2 2 5
P3 2 10
n( 2^1/n - 1 ) = 3 ( 2^1/3 - 1 ) = 0.7977