20-Scheduling Schemes - EDF-RMS & Hybrid Techniques,-08!04!2024

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 28

The energy field of the

heart is 5000 times stronger


than the brain, so thinking
positive is never enough- Module 5
you need to feel positive
(Proved by Inst. Heart RTOS
Math, USA)
Module:5 Real Time Operating System
Classification of Real time system, Issues & challenges in RTS,
Real time scheduling schemes- EDF-RMS & Hybrid techniques,
eCOS, POSIX, Protothreads.
RTOS Schedule
Task scheduling in a real-time operating system (RTOS) is the
process of determining which task should be executed next, based
on the system's resources and the tasks' priorities and deadlines.
RTOS task scheduling is critical for ensuring that real-time tasks
meet their deadlines, as even a small delay in executing a task can
have serious consequences.
How to perform task schedule

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.

Example: Earliest Deadline First (EDF)


Earliest Deadline First (EDF) CPU scheduling algorithm-EDF uses
priorities to the jobs for scheduling. It assigns priorities to the task
according to the absolute deadline. The task whose deadline is closest
gets the highest priority
Example: Consider two processes P1 and P2.
Let the period of P1 be p1 = 50
Let the processing time of P1 be t1 = 25
Let the period of P2 be period2 = 75
Let the processing time of P2 be t2 = 30
Advantages of the EDF scheduling algorithm:
•Meeting Deadlines:
EDF ensures that tasks with the earliest deadlines are executed first. By prioritizing tasks based
on their deadlines, EDF minimizes the chances of missing deadlines and helps meet real-time
requirements.
•Optimal Utilization:
EDF maximizes CPU utilization by allowing tasks to execute as soon as their deadlines arrive, as
long as the CPU is available. It optimizes the use of system resources by minimizing idle time.
•Responsiveness:
EDF provides a high level of responsiveness for time-critical tasks. It ensures that tasks are
scheduled and executed promptly, reducing response times and improving system performance.
•Predictability:
EDF provides predictability in terms of task execution times and deadlines. The scheduling
decisions are deterministic and can be analyzed and predicted in advance, which is crucial for
real-time systems.
Flexibility:
• EDF can handle both periodic and aperiodic tasks, making it suitable for a wide range of real-
time systems. It allows for dynamic task creation and scheduling without disrupting the
Limitations of EDF scheduling algorithm:

• Transient Overload Problem


• Resource Sharing Problem
• Efficient Implementation Problem
RMS Algorithm
The rate-monotonic scheduling (RMS) algorithm is a priority
assignment algorithm used in real-time operating systems
(RTOS) to assign static priorities. The algorithm assigns higher
priorities to tasks with shorter cycle durations, so a shorter cycle
duration results in a higher job priority. The RMS algorithm can
guarantee schedulability in applications that consist of a set of
periodic tasks with fixed-length execution times. The more
frequently a task runs, the higher its priority should be, with the
most frequent task having the highest priority in the system.
The priority of a process is inversely proportional to the period it will run for. A
set of processes can be scheduled only if they satisfy the following
equation: Where n is the number of processes in the process set, C i is the
computation time of the process, Ti is the Time period
Example: An example to understand the working
of Rate monotonic scheduling algorithm.

Processes Execution Time (C) Time period (T)

P1 3 20

P2 2 5

P3 2 10
n( 2^1/n - 1 ) = 3 ( 2^1/3 - 1 ) = 0.7977

U = 3/20 + 2/5 + 2/10 = 0.75


It is less than 1 or 100% utilization. The combined utilization of three
processes is less than the threshold of these processes which means the above
set of processes is schedulable and thus satisfies the above equation of the
algorithm.
Scheduling time – For calculating the Scheduling time of the algorithm we
have to take the LCM of the Time period of all the processes. LCM ( 20, 5, 10 )
of the above example is 20. Thus we can schedule it by 20-time units.
Priority – As discussed above, the priority will be the highest for the process
which has the least running time period. Thus P2 will have the highest priority,
and after that P3 and lastly P1.
•P2 > P3 > P1
•Representation and flow is as follows:
Conditions: The analysis of Rate monotonic scheduling
assumes few properties that every process should possess. They
are :

• Processes involved should not share the resources with other


processes.
• Deadlines must be similar to the time periods. Deadlines are
deterministic.
• Process running with highest priority that needs to run, will
preempt all the other processes.
• Priorities must be assigned to all the processes according to
the protocol of Rate monotonic scheduling.
Advantages:
1.It is easy to implement.
2.If any static priority assignment algorithm can meet the
deadlines then rate monotonic scheduling can also do the same.
It is optimal.
3.It consists of a calculated copy of the time periods, unlike
other time-sharing algorithms as Round robin which neglects
the scheduling needs of the processes.
Disadvantages:
4.It is very difficult to support aperiodic and sporadic tasks
under RMA.
5.RMA is not optimal when the task period and deadline differ.
Example: APPLY Rate monotonic scheduling
algorithm. And schedule tha task using EDF and RMS

Process Execution Time period


time
P1 3 20
P2 2 5
P3 2 10
P4 6 15
P5 4 7
Example: APPLY Rate monotonic scheduling
algorithm. And schedule task using EDF and RMS
Process Execution time Time period
P1 3 20
P2 2 5
P3 2 10
P4 6 15
P5 4 7
P6 7 9
P7 1 4
P8 2 16
Difference between RMS and EDF
Thank you
References
[1] https://www.windriver.com/solutions/learning/rtos
[2] https://www.embedded.com/rtos-trends-and-challenges/
[3]https://epgp.inflibnet.ac.in/epgpdata/uploads/epgp_content/S000007CS/
P001072/M023184/ET/1505901073mod26(1.pdf)
[4] https://www.linkedin.com/pulse/task-scheduling-rtos-madhavan-
vivekanandan/

You might also like