0% found this document useful (0 votes)
40 views

ES 2023 L6 Embedded System Interfacing RTOS

The document provides an overview of real-time operating systems (RTOS) and FreeRTOS. It discusses the basics of operating systems including tasks, processes, threads, multiprocessing, and task scheduling. It also describes how to setup FreeRTOS
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

ES 2023 L6 Embedded System Interfacing RTOS

The document provides an overview of real-time operating systems (RTOS) and FreeRTOS. It discusses the basics of operating systems including tasks, processes, threads, multiprocessing, and task scheduling. It also describes how to setup FreeRTOS
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Embedded Systems Real

Time OS (RTOS)
ENEL4ES – Embedded System 2023
Lecture 6
R Khuboni
Electrical, Electronic and Computer Engineering (EECE) Discipline
University of KwaZulu-Natal
Lecture Outline
Operating System Basics
Types of Operating Systems
Tasks, Process and Threads
Multiprocessing and Multitasking
Task Scheduling
NB: Free – version of the real time operating system (i.e. FreeRTOS) is available for downloading.
Specifically made for specific microcontrollers and microprocessors.
URL: https://www.freertos.org/a00104.html

This is helpful when you want to run a kernel system on an embedded platform. We can also
program a specific processor and simulate these kernels on Atmel studio using a tracealyzer to
view the outputs/outcomes of the system.
What to expect from an OS?
An Operating System (OS) acts as a bridge between the user applications/tasks
and the underlying system resources through a set of system functionalities and
services.
The OS manages the system resources and makes them available to the user
applications/tasks on a need basis.
It’s primary function is to:
Make the system convenient to use
Organise and manage the system resources efficiently and correctly

So, the OS handles or manages the following:


Process (Task) Management
Process Priority Management
Resource Management
What to expect from an OS?
So, the OS handles or manages the following:
Process (Task) Management
Pre-emptive tasks
Non pre-emptive tasks
Process Priority Management
Scheduling Process
Resource Management
I/O Ports
Critical Sections of Code
Interrupts
Memory blocks
Timers
What to expect from an OS?
So what handles or manages the interaction between the system resources and
the communication among the hardware and other system services?
The answer to that?
The kernel is the core of the operating system and it is responsible to manage
these interactions
Kernel contains a set of system
libraries and services
What to expect from an OS?
Memory Management handles and keeps track of utilized memory. This memory
refers to the volatile memory (RAM) where processes are loaded, variables and
shared data associated with each process are stored.
Process management deals with the managing of the processes/ tasks. It sets up
the memory space for the process, loading the process’s code into the memory
space, allocating system resources, scheduling and managing the execution of the
process.
File system management handles a file as a collection of related information. The
file could be a executable program, text files, image files word document,
audio/video files, etc.
I/O system (Device) Management deals with routing the I/O requests coming
from different user applications to the appropriate I/O devices of the system.
Time (Interrupt handler) management provides mechanism for all external
/internal interrupts generated by the system.
What to expect from an OS?
We also get Monolithic- and Micro-Kernels
Monolithic Kernels
All the kernel services run in the kernel space. A tight internal integration of
the kernel modules allows for effective utilization of the low-level features of
the underlying system. E.g. Linux, Solaris, MS-DOS Kernels.
Drawbacks of it, any error or failure in any one of the kernel modules leads to
the crashing of the entire kernel application.
Micro Kernels
Only incorporates only the essential set of operating system services into the
kernel. The rest of the OS services are implemented in programs known as
“servers” which runs in the user space. This offers a highly modular design
and OS neutral abstraction to the kernel. E.g. Mach, QNX, Minix 3 kernels.
What types of OS are available?
Well, there are two types of Oss
General Purpose OS (GPOS) and Real Time OS (RTOS)
So
General Purpose OS has a kernel is a more generalized kernel and it contains all kinds of
services required for executing generic applications. E.g. Windows 10.
They are non-deterministic in behaviour.
Real Time OS implies that there are deterministic in timing behaviour.
Deterministic in timing behaviour means that the OS services consumes only known and
expected amounts of time regardless of the number of services (i.e. Time predictability).
The RTOS has a real time kernel that is highly specialized and it contains only minimal set
of services required for running the user applications/tasks (i.e. Prioritization of processes
is strictly managed).
There is no or minimal blocking of interrupts
What types of OS are available?
Real Time Behaviour can be viewed as:
Soft Real Time where time schedules may be missed (occasionally) without
disaster.
Missing deadlines for a task are acceptable.
As long as the frequency of missed deadlines are within compliance limit of
Quality of Service (QoS)
E.g. Automatic Teller Machine (ATM) or Audio/Video playback system delayed
by a fraction of a second
Hard Real Time where time schedules may NEVER be missed.
Real Time OS are restricted to adhere to the timing constraints for a task.
Meeting deadlines for a task without any slippage.
E.g. The airbag control system should deploy the airbags when the vehicle
meets a severe accident or anti-lock brake system (ABS)
We know about RTOS but what is FreeRTOS
FreeRTOS is a class of RTOS that is designed to be minimal enough deploy on a
microcontroller although its use is not limited to microcontroller applications.
Microcontrollers are used in deeply embedded applications that normally have
very specifically defined or dedicated job to do.
Therefore, FreeRTOS only provides the core real time scheduling functionality,
inter-task communication, timing and synchronization primitives.
This is basically a real time kernel.
You may download the latest version of the FreeRTOS V10 online
This is ideal for student project use
You can download it onto any microcontroller and real time scheduling of tasks.
What is Tasks, Process and Threads
Tasks
The term task refers to something that needs to be done.
In our daily routine, we are bound by tasks that we need to execute or do.
In addition to that we have order of priority and schedule/timeline for doing those tasks.
So a task as a “job” in the OS context
 Process
A process is a program or part of it that needs to be executed.
A process requires various system resources like CPU for executing the process, memory for
storing the code corresponding to the process and associated variables, I/O devices for
information exchange, etc.
Thus, a process is a sequential in execution.
Threads
We get a thread which is the primitive that execute code.
A thread is a single sequential flow of control within a process (i.e. a light weight process)
A process can have many threads of execution and they share same the address space (i.e. share
memory)
Multiprocessing and Multitasking
Multiprocessing describes the ability of executing multiple processes
simultaneously. A system capable of performing multiprocessing are known as
multiprocessor system.

Whereas Multitasking involves the switching of execution among multiple tasks.


Depending on how we execute these multiple tasks, we can classify them.
Pre-emptive Multitasking
Every task/process gets a chance to execute.
Non-pre-emptive Multitasking
Executes until it terminates.
Task Scheduling
Already we know we can do multitasking
Multitasking involves the execution switching among the different tasks
So there should be a mechanism in place to share CPU among the different tasks
and decide which process/ task is to be executed at a given point in time.
The process/task scheduling decision may take place when a process switches its
state to:
1. Ready
2. Blocked/Waiting
Tutorial - Find out how do we setup
3. Running the FreeRTOS to execute a simple task
4. Completed/Terminated and create a flowchart or state
diagram for the simple task.

You might also like