FreeRTOS - More About it!

The Essence of FreeRTOS — IoT — Episode #04

J3
Jungletronics
5 min readJan 5, 2020

--

This is the sequence dealt right here:

Hi, Let’s just get going!

In biology, the kernel is a softer, usually edible part of a nut, seed, or fruit stone contained within its hard shell. Synonyms are essence; gist; core.

Fig 1. Did you know that two types of (Medicinal/Cosmetic) oil can be produced from the oil palm fruit? The kernel actually is the central or most important part of something :)

In technology, the kernel is a computer program that is the core of a computer’s operating system, with complete control over everything in the system. The kernel facilitates interactions between hardware and software components. The CPU essential service. This is monolithic kernels.

In the Microcontroller world, a better term would be microkernel.

A microkernel is a minimal kernel. Microkernel rhymes with microcontrollers!

The microkernel approach consists of defining a simple abstraction over the hardware including those normally provided by the kernel, such as networking (TCP/IP Stacks), which are implemented in user-space programs, referred to as servers.

FreeRTOS is a kernel and around it, there is a collection of microkernels services (servers).

FreeRTOS is a market-leading Real-Time Operating System (RTOS) for microcontrollers and small microprocessors that allow users access to the computer seemingly simultaneously. Multitasking is the word!

FreeRTOS is a recent (2017) notable Amazon acquisition!

Each executing program is a task (or thread) under control of the operating system. If an operating system can execute multiple tasks in this manner it is said to be multitasking.

A conventional processor can only execute a single task at a time.

Fig 2. The upper diagram demonstrates the perceived concurrent execution pattern, and the lower the actual multitasking execution pattern ( https://www.freertos.org/implementation/a00004.html)

ESP-32 is a dual-core IoT board that comes with an integrated TCP/IP protocol stack and can do parallel processing. This is awesome! (More about ESPs’ family please read this post).

Fine! Now, how about the scheduler?

The scheduler is the part of the kernel responsible for deciding which task should be executed at any particular time. The kernel can suspend and later resume a task many times during the task lifetime. (to read more about the preemptive schedule please see this post).

FreRTOS can do both, preemptive or nom-preemptive algorithms.

Other OS for microcomputer, like OSA-RTOS, dealt in this post, is essentially nom-preemptive only.

But the purpose of microcontrollers practicing with Expressif infrastructure, proposed in these IoT series, will be dealt with a preemptive algorithm only. This is what the nanotechnology industry is used to 😜.

With the preemptive algorithm, each task (thread) has the right to enjoy a minimal amount of available resources — time, hip, stack, http, net link, or whatever resource… — that are provided via the scheduler control.

It’s like virtual-Hobin-Wood-heroes services for the microcontroller! It will avoid memory leaks; memory allocated on the heap should always be freed when no longer needed. And it is low-memory-footprint! This is some of FreeRTOS’s role!

So far so good!

Now, how these resources are shared between the tasks?

By means of Context Switching!

As a task executes it utilizes the processor/microcontroller registers and accesses RAM and ROM just as any other program. These resources together (the processor registers, stack, etc.) comprise the task execution context.

Consider the example of a task being suspended immediately before executing an instruction that sums the values contained within two processor registers. While the task is suspended other tasks will execute and may modify the processor register values. Upon resumption the task will not know that the processor registers have been altered — if it used the modified values the summation would result in an incorrect value.

To prevent this type of error it is essential that upon resumption a task has a context identical to that immediately prior to its suspension. The operating system kernel is responsible for ensuring this is the case.

Finally, Real-Time Operating systems (RTOSes) achieve multitasking using these above principals — but their objectives are very different from those of non-real time systems. The different objective is reflected in the scheduling policy.

More about scheduling policy here is a good source of information!

That’s enough for now!

In the next episode let’s deal with real coding!

See you soon!

Bye o/

IoT Episodes Posts:

1° Episode — IoT — Meet IoT Boards: ESP8266 & ESP32 — Which are the best? ESPs or RPis or Arduinos Boards?

2° Episode — IoT — FreeRTOS Why To Use It? — IoT Projects? What is it?

3º Episode — IoT — FreeRTOS — We are all Preemptive Scheduler! — Some Important Concept for Real-Time Operating System (RTOS)

4 ° Episode — IoT — FreeRTOS - More About it! — The Essence of FreeRTOS

5° Episode — IoT — FreeRTOS A Real Real-Time TV Transmissions Fundamental Understanding of FreeRTOS Apps

More About Kernels

PALM KERNEL OIL — ORGANICPalm kernel oil is a universal oil used primarily in the soaping and food industries. After being extracted from the kernel (seed) of the palm tree, the oil is then refined, resulting in a white to off-white colored oil that carries a bland to nonexistent odor and taste. As a result of the oil’s high level of saturated fatty acids, organic palm kernel oil is a solid at room temperature. Palm kernel oil is a stiffer product than palm fruit oil and also has a higher percentage of lauric acid

Credits & References

RTOS Fundamentals

Microgênios — Treinamento em Sistemas Embarcados — Microchip Regional Partner — Microchip Certified Brazilian Training Education Startup & Simplício-owned enterprise o/

--

--

J3
Jungletronics

Hi, Guys o/ I am J3! I am just a hobby-dev, playing around with Python, Django, Ruby, Rails, Lego, Arduino, Raspy, PIC, AI… Welcome! Join us!