RTOS Basics Concepts – Part 1

Nowadays most companies are using RTOS. So almost all controllers support RTOS. If we want to work with RTOS, we should know the basic things like operating systems, processes, threads, semaphore, mutex, etc.

So in this tutorial, we will cover the basic things that need to know for RTOS. We have divided this tutorial into Two Parts. RTOS Basics and RTOS Advanced topics.

This is part 1 where we are focusing on basic concepts of RTOS. In our next article, we focused on Advanced concepts of RTOS.

If any fresher going to attend an interview related to RTOS, you should read this RTOS Basics before attending. This will help you somewhat. Okay, let’s begin the RTOS Basics.

RTOS Basics Tutorial

System

A system is a process or collection of processes and it does certain clearly defined objectives in an apparently independent way.

Operating System

An operating system is a set of programs, designed to manage all the resources of the computer. In other words, a set of programs that acts as an intermediary between a user of a computer and the computer hardware.

Memory, I/O devices, communication devices, etc. are the hardware resources of the computer. File systems, virtual memory, security, etc. are software resources. Now a set of programs that are used to manage all these resources is called an operating system.

The Need for Operating System

  • Without an operating system, a user cannot run an application program on their computer, unless the application program is self-booting.

  • Execute user programs and make solving user problems easier.

  • Use the computer hardware in an efficient manner.

Computer System Components

  1. Hardware – provides basic computing resources (CPU, memory, I/O devices).

  2. Operating system – controls and coordinates the use of the hardware among the various application programs for the various users.

  3. Applications programs – define the ways in which the system resources are used to solve the computing problems of the users (compilers, database systems, video games, business programs).

  4. Users (people, machines, other computers).

Abstract View of System Components

Operating System Abstract View

Functions of Operating Systems

The main functions of an operating system are as follows:

  • Process management

  • Memory management

  • Secondary storage management

  • I/O management

  • File management

  • Protection

  • Networking management

  • Command Interpretation

Four main tasks of OS

  • Process Management
    •         Process creation
    •         Process loading
    •         Process execution control
    •         Interaction of the process with signal events
    •         Process monitoring
    •         CPU allocation
    •         Process termination
  • Inter-process Communication
    • Synchronization and coordination
    • Deadlock detection
    • Process Protection
    • Data Exchange Mechanisms
  • Memory Management

    • Services for file creation, deletion, repositioning, and protection

  • Input / Output Management

    • Handles requests and releases subroutines for a variety of peripherals and read, write, and reposition programs

Every operating system is mainly divided into two parts:

  1. Shell
  2. Kernel

RTOS Basics Tutorial

Shell

Shell is the program that handles all other programs.

For example,

  • K- shell or Born shell in UNIX
  • Explorer.exe in windows
  • Command program in DOS

Kernel

The kernel provides the most basic control over all of the computer’s hardware devices. Time management, task scheduling, memory management, file system, etc. all are monitored by the Kernel.

Kernel OS

Types of OS

  • Batch processing OS

  • Time-Sharing

  • Real-Time Operating System

  • Embedded OS

Batch Processing OS

  • In this system, the user submits the group of jobs to a central place from where it is queued as input to the computer

  • In this case, the user has no interaction with the job during its processing and the Computer’s response time is the turnaround time (The time from submission of the Job until the execution is complete, and the results are ready to return to the person who submitted the job).

Time-Sharing Systems–Interactive Computing

  • The CPU is multiplexed among several jobs that are kept in memory and on disk (the CPU is allocated to a job only if the job is in memory).

  • A job is swapped in and out of memory to the disk by various swapping algorithms Like FREQUENTLY USED, RARELY USED, etc.

  • On-line communication between the user and the system is provided; when the operating system finishes the execution of one command, it seeks the next “control statement” from the user’s keyboard.

  • An online system must be available for users to access data and code.

  • In this case, the user has full interaction with the job during its processing.

Real-Time Operating System

  • This system is designed to serve where the response time is of the essence in order to prevent Error, Misrepresentation, or disaster. E.g. Airline reservation, machine tool control, and monitoring of nuclear power stations.

  • The most important significance of RTOS is managing the resource of the computer so that a particular operation executes in precisely the same amount of time every time it occurs. Well-defined fixed-time constraints

Types of RTOS

  • Hard RTOS

  • Soft RTOS

Embedded OS

These operating systems are developed for specific applications in specific hardware.

  • E.g.Nexus’s Conix – an embedded OS for ARM Processors

  • Sun’s Java OS – a standalone virtual machine not running on top of any other OS; mainly targeted at embedded systems.

  • Palm Computing’s Palm OS – Currently the leader OS for PDA’s has many Applications and supporting companies.

  • Microsoft’s Windows CE and Windows NT Embedded OS

  • Symbian OS for most of the 2G and 3G Mobiles.

Types of System

  • Mainframe System

  • Parallel System

    • Multiprocessing System

  • Distributed System

    • Networking OS

Here I am not going to discuss all these types. We mainly concentrate on Real-Time Operating systems now.

What is a Real-Time System?

  • A system that responds to an external event in a guaranteed amount of time

  • RTS depends upon

    • The logical correctness of the computation

    • The time at which the result is produced.

  • In RTS “a late answer is a wrong answer.”

  • Real-time systems work just like a driver driving his racing car at a very high speed.

    • The driver will have to make the right decision fast and on time. A decision to turn left may not be a good idea after the turn has been missed.

    • The driver has to know his environment very well. The car would skid if the road were wet or icy.

    • The driver should know the capability of the car. If the driver tries to push it beyond its limits, the car will break down. And break down at high speed can lead to fatal accidents.

    • The driver should know what information would the various meters in the dashboard provide him.

    • The speed of the car, how much fuel is still left, the temperature of the engine, air pressure in the tires, etc are vital to a driver of such a fast car so that a valid decision can be made.

Multi-Tasking

  • Multitasking refers to the ability of a system to execute more than one task at the same time.

  • However, in reality, multitasking just creates the appearance of many tasks running concurrently.

  • Actually, the tasks are interleaves rather than concurrently.

OS Multitasking

OS VS RTOS

  • A GPOS is used for systems/applications that are not time-critical.  Example:- Windows, Linux, Unix, etc. An RTOS is used for time-critical systems. Example:- VxWorks, uCOS, etc.

  • In GPOS task scheduling is not based on  “priority” always. Whereas in an RTOS – scheduling is always priority-based.

Types of RTS

  • Hard real-time systems
    • No critical deadlines can be missed
  • Soft real-time systems

    • Occasional misses are permitted

    • The average response time for an event should be within a specified time.

Soft real-time

In soft real-time systems, missed responses are undesirable, but do not result in complete failure (e.g. video decoder, network switch). In other words, deadlines may be missed and can be recovered. Reduction in system quality is acceptable.

Hard real-time

In hard real-time systems, failure to meet constraints results in complete system failure and is, therefore, an unacceptable condition (e.g. air traffic controllers, missile guidance systems, or health monitoring systems where a missed response can have catastrophic results). In other words, the degree of tolerance for missed deadlines is extremely small or zero.

Real-Time Spectrum

Non real time         →        Soft real time         →         Hard real time

      (a)          (b)          (c)              (d)               (e)             (f)             (g)

(a) Computer simulation

(b) User interface

(c) Internet video

(d) Cruise control

(e) Telecommunication

(f) Flight control

(g) Electronic engine

What is the need for an RTOS?

There are basically three types of embedded systems.

  • Polled Loop Systems

  • Interrupt Driven Systems

  • Real-Time Operating Systems

Polled Loop Systems: (sequence of all activities)

A polled loop program is just a gigantic loop that endlessly reads inputs and takes some action based on inputs. It executes code sequentially, so no other operation can be performed. Therefore, only a single task exists that runs infinitely. No inter-task communication or scheduling is needed.

Polled loops are a fantastic solution for some systems. Like high-speed data channels, especially when events occur at widely spaced intervals and the processor is dedicated to handling the data channel.

Polled Loop Systems

Advantages:

  • Very easy to code and debug.

  • Response time is easy to determine.

Disadvantages:

  • Cannot handle asynchronous events.

  • Waste of CPU time, especially, when the program is continuously monitoring a status flag or variable.

Interrupt Driven System

An interrupt is a signal/event typically generated by a hardware device indicating that it needs the CPU service. Whenever the interrupt occurs, the corresponding service routine (ISR) is identified by taking the help of the interrupt vector table and then executed to handle that event.

This system is a better solution than a simple polled loop since the system doesn’t ask CPU time waiting for something to happen. Therefore, no waste of CPU time.

Interrupt Driven System

Disadvantage

  • As the applications grow, obviously multiple independent activities increase. For example, a simple system is designed to read the numbers pressed on the keypad, update the data, and then display it on LCD and other activities.

  • If the number of interrupts increases processing time also increases so the system may not respond correctly to interrupts or asynchronous events which produce undesired results.

Thanks for reading  RTOS Basics – 1. The continuation of this post (PART 2) is here.

You can also read the below tutorials.

Linux Device Driver TutorialsC Programming Tutorials
FreeRTOS TutorialsNuttX RTOS Tutorials
RTX RTOS TutorialsInterrupts Basics
I2C Protocol – Part 1 (Basics)I2C Protocol – Part 2 (Advanced Topics)
STM32 TutorialsLPC2148 (ARM7) Tutorials
PIC16F877A Tutorials8051 Tutorials
Unit Testing in C TutorialsESP32-IDF Tutorials
Raspberry Pi TutorialsEmbedded Interview Topics
Reset Sequence in ARM Cortex-M4BLE Basics
VIC and NVIC in ARMSPI – Serial Peripheral Interface Protocol
STM32F7 Bootloader TutorialsRaspberry PI Pico Tutorials
STM32F103 Bootloader TutorialsRT-Thread RTOS Tutorials
Zephyr RTOS Tutorials - STM32Zephyr RTOS Tutorials - ESP32
AUTOSAR TutorialsUDS Protocol Tutorials
Product ReviewsSTM32 MikroC Bootloader Tutorial
VHDL Tutorials
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Table of Contents