RTOS Overview

To open the tutorial about building RTOS from scratch, I will introduce some basic concepts about RTOS.

1. What are Real-time systems?

Real-time systems are system whereby the correctness of the computed values and their timeliness are at the forefront. In Real time system, response should be guaranteed within a specified timing constraint or system should meet the specified deadline.

There are 2 types of Real Time system: Hard Real Time system and Soft Real Time system.

In hard real-time systems, missing deadlines is not an option. In fact, in many cases, missing a deadline often results in catastrophe, which may involve human lives. In soft real-time systems, missing deadlines is generally not as critical.

Now with the purpose building our own RTOS, I will show you some basic concept related to it.

2. Foreground/Background System

We see a lot of small systems are designed as foreground/background systems or super-loops.

In this system, an infinite loop that calls modules (tasks) to perform the desired operations (background). Interrupt Service Routines (ISRs) handle asynchronous events (foreground).

This design is same as the interrupt driven model I showed you in Microcontroller Software Development Process. And you can see when some ISR have same priority, or the time to process high priority ISR is too long, other ISRs don’t have time to execute then the result is still bad responsiveness.

3. Real-Time Kernels

To resolve above problems, the real-time application will be split into tasks, each responsible for a portion of the job. A task (or thread) is a simple program that thinks and acts like it has the CPU for itself all the time. By this way, the responsiveness is reached at very good result.

And the real-time kernel, which is a software that manages the time and resources of a microprocessor, was born for the management of tasks. Its duty is scheduling and switching CPU between several tasks, also called multitasking.

One of the most important aspects of multitasking is that is allows us to manage the complexity inherent in real-time applications.

With this design of preemptive kernel, the most important tasks will always be run first.

Below are the list of kernel functions:

  • Scheduling: preemptive scheduling, round-robin scheduling …
  • Context Switching
  • Interrupt Management
  • Resource Management
  • Synchronization: semaphores …
  • Message Passing: message queues …

4. RTOS (Real-Time Operation System)

A Real Time Operation System generally contains a real-time kernel and other higher level services such as file management, protocol stacks, a Graphic User Interface (GUI), and other components.

5. What can we do with RTOS?

There are a list of RTOS are provided such as FreeRTOS, uCOS-II, uCOS-III, … Their documents help us to build our Real-Time application very easily, the remain job is our implementation on each task. I will show you basic usage of these RTOS in other posts.

And to make the things more interesting, I will show you how to create a minimum Real-Time Kernel from scratch with essential features as scheduler, communication between task, system resource managing. It help you to understand content inside RTOS much more easily.

Hope to see you soon.

Leave a Reply

Your email address will not be published. Required fields are marked *