Embedded Systems Ch-4
Embedded Systems Ch-4
Chapter Four
Real Time Operating Systems (RTOS)
What is an OS?
• An organized collection of software extensions of hardware that serve
as...
➢control routines
for operating a
computer (for
example, to gain
access to computer
resources (like file
I/O))
➢an environment
for execution of
programs
A more formal definition of OS!
Operating system is a piece of software which
controls all the computer’s resources and provides
the base upon which the application programs can
be written
Where your OS sits in your System?
compilers
databases
word processors
CPU
memory
I/O devices
TYPES OF OPERATING SYSTEMS
➢Stand-Alone Operating system
➢Network Operating systems
➢Embedded Operating systems
Stand-Alone Operating system
It is a complete operating system that works on a desktop or
notebook computer.
Examples of stand-alone operating systems are:
➢DOS (Disk Operating System) – runs from a disk drive
➢Windows 2000 professional – client version of windows,
first released by Microsoft in February 2000.
➢Mac (Macintosh) OS X –is a Unix-like operating system
developed and marketed by Apple Inc. since 2001.
Network Operating systems
It is an operating system that provides extensive support for
computer networks. A network operating system typically
resides on a server.
Examples of a network Operating system are:
➢Windows 2000 server
➢Unix – first developed in 1960s.
➢Linux - In fact, one of the most popular platforms on the
planet, Android, is powered by the Linux operating system.
➢Solaris –UNIX-based operating system of Sun
Microsystems
Embedded Operating system
You can find this operating system on handheld computers
and small devices. It resides on a ROM chip.
Examples of embedded operating systems are :
➢ Windows CE – windows embedded compact - is an
operating system subfamily developed by Microsoft as
part of its Windows Embedded family of products.
➢ Pocket PC 2002
➢ Palm OS
What is RTOS?
• An operating system that supports real-time applications and
embedded systems.
• Real-time applications have the requirement to meet task deadlines
in addition to the logical correctness of the results.
➢All the process and threads in RTOS has got bounded latencies –
which means –a process/thread will get executed within a specified
time limit
.
User interaction is the main focus of Most RTOSs are designed to run on
GPOS design, Some latency is microcontrollers, and include a
acceptable (so long as users don’t scheduler, resource management,
notice a long lag time). and device drivers.
Classification of real time systems(RTS)
➢C++ and Ada are the next more popular for large projects.
Task prototype
Creating Tasks
• Tasks are created using the FreeRTOS xTaskCreate() API function.
• pvTaskCode: The pvTaskCode parameter is simply a pointer to the function that
implements the task (in effect, just the name of the function);
• pcName: A descriptive name for the task. This is not used by FreeRTOS in any
way. It is included purely as a debugging aid;
usStackDepth: Each task has its own unique stack Prototype
that is allocated by the kernel to the task when the task xTaskCreate( TaskFunction_t
is created. The value specifies the number of words the pvTaskCode, const char *
stack can hold, not the number of bytes. For example, const pcName, uint16_t
if the stack is 32-bits wide and usStackDepth is passed usStackDepth, void
in as 100, then 400 bytes of stack space will be *pvParameters,
allocated (100 * 4 bytes) in RAM. Use this wisely UBaseType_t uxPriority,
because Arduino Uno has only 2Kbytes of RAM. TaskHandle_t
*pxCreatedTask );
Cont.
• pvParameters: A value that is passed as the parameter to the created task
(can be NULL).
• uxPriority: Defines the priority at which the task will execute. Priorities
can be assigned from 0, which is the lowest priority to the highest priority;
• pxCreatedTask: can be used to pass out a handle to the task being created.
This handle can then be used to reference the task in API calls that, for
example, change the task priority or delete the task. If your application has
no use for the task handle, then pxCreatedTask can be set to NULL;
• There are two possible return values: pdPASS or pdFAIL. Fail indicates
that the task has not been created because there is insufficient heap memory
available for FreeRTOS to allocate enough RAM to hold the task data
structures and stack
Creating a Delay
• Most of the code needs delay function to stop the running task but in
RTOS it is not suggested to use Delay() function as it stops the CPU
and hence RTOS also stops working. So FreeRTOS has a kernel API
to block the task for a specific time.
• This API can be used for delay purposes. This API delay a task for a
given number of ticks. The actual time for which the task remains
blocked depends on the tick rate.
• The constant portTICK_PERIOD_MS can be used to calculate real-
time from the tick rate.
• This means if you want a delay of 200ms, just write this line
Example1 (without RTOS)
With RTOS
Example 2 (Tasks and priority)