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

RTOS

Uploaded by

arunachalam05r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

RTOS

Uploaded by

arunachalam05r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Our GPOS:

o Handle Task Scheduling (Multiple tasks are prioritized and


done)
o Handles Resource Management (Files and Folders and all)
o Handles Device drivers which help the GPOS access
memory and input and output peripherals
To handle these many tasks, we use an RTOS, which has a better
scheduler to organize and complete these events.
Super-loop Architecture:
o This is what most of the Embedded systems follow. This
involves lesser CPU cycles and more easy to debug than
RTOS way to execute the processes.
o To meet deadlines of doing a task – It is better to use an
Interrupt Service Routine.
o But when we use Super-loop, the problem is we can miss
data required for a third task, while a second task is being
performed by the operating system.
For a concurrent execution of tasks, we need another architecture.
That will or may involve:
Prioritizing tasks – Tasks which involve longer time can be
started at first along with tasks which involve user input.
Task – Set of program instructions loaded in memory
Thread – unit of CPU utilization with its own program counter
and stack.
Process - Instance of a computer program.
In FreeRTOS – Task = Thread.
ESP32 is the best SoC to execute RTOS architecture program in it.
It has very high clock frequency, and comparatively higher RAM
and Flash compared to Arduino UNO. (4MB Flash, 520 kB RAM, 240
MHz in ESP32 compared 32 kB Flash, 2 kB RAM, 16 MHz in Arduino
UNO). Our resources inside Arduino UNO will be very less once we
initiate scheduler.

ESP32 and FreeRTOS:

Like we have an architecture executed in ESP32 called SMP –


Symmetric Multi Processing.
What happens in an RTOS program?
The tasks are arranged as per schedule. For every tick (created by
something called time slicing), microcontroller will check the task
scheduler and check for tasks and higher priority tasks get executed
first.
If the OS creates an interrupt, then, there is one ‘Idle’ block created.
Hardware interrupts can also be introduced, but that won’t cause
any graphable change. More difficult case is in the case where one
hardware interrupt causes other hardware interrupt.
Whenever a task is completed, it goes to the suspended task.

RTOS Scheduler

Refer kernel in FreeRTOS website.


MEMORY MANAGEMENT IN RTOS:

In a general C program, memory allocation is done for three


purposes:
Static: This is where all data declared to be static is stored. This
cannot be changed all over the program. Both local and global static
variables are stored in this part of RAM.
Stack: This either grows downward from top or the vice versa. This is
where all the local variables (neither static nor dynamic, internally
created variables) are stored. Follows LIFO principle. Once that local
area is passed, it will be deleted as a whole. When data is needed,
we can just pop out it.
Heap: Stores all the dynamic variables which keeps changing in the
program. The problem is this can be global, due to which if not
stopped, it will grow continuously to cause a memory leak.
We can clearly see that if no proper precautions are taken, stack and
heap can just overwrite each other.
RTOS Memory Allocation:

Stack – The reason we gave 1024 in xTaskCreatePinnedToCore.


TCB – Rest of the parameters we gave in xTaskCreatePinnedToCore.
Kernel Object – Deals with Queues and Semaphores(Data-type).
As of now we can’t create static tasks in ESP-IDF.
And also too much of dynamic tasks may cause mixing of Stack and
Heap.
Heap structures in FreeRTOS:

You might also like