It is the software that is
responsible for scheduling
tasks, managing resources,
and provide an abstraction
layer for the application code
development.
Its kernel provides minimal logic, scheduler
and resource management algorithms
Kernel
Board Support Package (BSP)
The interface between RTOS and the hardware
platform. It is a set of software drivers for
specific hardware components. It has
information about the hardware characteristics.
It includes
System scheduler timer configuration
Hardware interrupt configuration
Memory configuration (stack and heap)
CPU configuration
Hard to develop.
Requires knowledge of
Hardware
Assembly
Operating System
RTOS porting
Development process of BSP where an already
developed BSP is used as a basis, where
adaptations and new developments are carried out.
Scheduler
It is the algorithm that
decides which entity or task
will run and when it will run.
Schedulable
entities
They are kernel object that competes
for an execution time in the system,
based on a predefined scheduling
algorithm. Ex. processes or tasks.
Context switching
What does CONTEXT mean?
State of the CPU required each
time the task is scheduled to run.
A context switch occurs when the
scheduler performs the swap on a
processor from task A to task B
Task Control Block (TCB)
is a data structure that
the kernel maintains for
storing task-specific data
Steps
1. Kernel saves the context of task 1 in its respective TCB
2. Kernel loads the context information of
task 2, which becomes the running task
3. Task 1 context remains
frozen while task 2 is executed
4. If the scheduler needs to run task 1
again, it runs where it left off before
the context switch
Context switch Time
Time taken by the scheduler to
switch from one task to
another. Should not be
disregarded.
Dispatcher
Part of the scheduler responsible for
executing the switch of contexts and
changes in the execution flow
Possible areas for control flow
Kernel
Interrupt service routine (ISR)
Application task
What happens when a task or ISR makes a system call?
Control flow is passed through
kernel to perform the requested
function and passed to task or ISR
again.
Deadlines
Types
Hard
Soft
Maximum time a task must
finish its execution completely,
after being activated again.
Scheduling Algorithms (Scheduling policies)
Most common
Collaborative (non-preemptive)
Cooperative Cyclic Executive (CCE)
Performed through a loop of functions called
cyclic executive. It is non-preemptive.
Cyclic executive
Non-preemptive (cooperative)
No infinity loops
Code
example
Temporal Aspect
Fixed priority-based and preemptive
Preemptive priority-based
The task that gets the processor to run in it, considering any instant of time, is
the highest priority task among the tasks in the “ready” state of the system.
Priorities are fixed and defined during design time. If any task with higher
priority (in relation to the current running task) enters the “ready” state, the
kernel preempts the lower priority to this one with highest priority,
Highest priority task executing
Priority
Fixed
Defined at design time (off line)
Preempts if higher priority task appears
Rate Monotonic (RM)
Assumptions
2. the tasks are independent and do not
have intercommunication;
3. the deadline of a task is the start of its
next period (D = T);
4. constant execution time for tasks;
5. all tasks have the same criticality level;
1. all tasks are periodic;
6. aperiodic tasks are limited to
initialization and some fault recovery
mechanisms;
The less the execution period, the higher
the priority assigned to the task
Processor Utilization Factor
Theoretical limit of use
Execution time-based and preemptive
Round-Robin or Time Slicing
Allocates an equal and predetermined time slice for tasks to run.
Round-robin “alone” does not meet the requirements for real time
systems, since tasks perform roles in different levels of importance.
It can be used together with preemptive priority-based as
tiebreaker between tasks with equal priorities in “ready” state
Equal time slice
Does not meet the real-time requirements alone
Usid with preemptive priority-based.
Dynamic priority-based and preemptive
Earliest Deadline First (EDF)
It is a dynamic scheduling class
algorithm. The lower the deadline, the
higher the priority of the task.
Dynamic priorities (can
change over time)
Lower deadline,
higher priority.
Process utilization factor
Schedulability Analisys
1. all tasks of the system can be
scheduled to execute and fulfill their
deadlines according to the
scheduling algorithm used;
2. still achieve optimal
processor utilization
Only temporal requirements
Tasks
Computation performed by a processor in a
sequential order. A system can be
decomposed into multiple concurrent tasks.
Main states
Ready
Blocked
Running
Classification
Periodic
Aperiodic
Multi-tasking system
Operating system ability (or real-time frame) to manage
various activities/tasks considering their deadlines.
Implies
CPU competition
more than one task competing to be executed
consideration of the scheduling
algorithm and the real time
model (hard, soft) used