RTOS Basics Concepts – Part 1

Hi all… Hope you are doing well… Here i came with new post (RTOS Basic Tutorial – 1). Now a days most of the companies are using RTOS. So mostly all controllers supports RTOS. If we want to work with RTOS we should know the basic things like operating system, process, threads, semaphore, mutex etc. So in this tutorial we will cover the basic things need to know for RTOS. We have divided this tutorial into Two Parts. If you want to see PART 2 please Click Here.

If any fresher going to attend interview that related with RTOS you should read this before attend. This will help you some what. Okay, let’s begin.

RTOS Basic 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 that designed to manages 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 which are used to manage all these resources is called an operating system.

Need of 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

1-2 RTOS Basics Concepts - Part 1

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, reposition and protection
  • Input / Output Management

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

Every operating system mainly divided into two parts

  1. Shell
  2. Kernel

2-2 RTOS Basics Concepts - Part 1

Shell

Shell is the program which handles all other programs.

For example,

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

Kernel

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

3-2 RTOS Basics Concepts - Part 1

Types of OS

  • Batch processing OS

  • Time Sharing

  • Real Time Operating System

  • Embedded OS

1. Batch Processing OS

  • In this system the user submits the group of jobs to a central place from where it is queued as an 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 for return to the person who submitted the job).

2. 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 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.

  • On-line 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.

3. 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 station.

  • 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

4. Embedded OS

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

  • 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 System. 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 system work like just like a driver driving his racing car at a very high speed.

    • The driver will have to take right decision fast and in 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 all information would the various meters in the dashboard provide him.

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

Multi-Tasking

  • Multi-tasking 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.

4-2 RTOS Basics Concepts - Part 1

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. Where as 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 from. 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, 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 of 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 endlessly reads inputs and takes some action based upon 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 needed.

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

5-2 RTOS Basics Concepts - Part 1

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 is occurred corresponding service routine (ISR) is identified by taking the help of interrupt vector table and then executed to handle that event.

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

6-2 RTOS Basics Concepts - Part 1

Disadvantage

  • As the applications grows, obviously multiple independent activities increases. For example a simple system is designed to read the numbers pressed in keypad, and update the data and then display it in LCD and doing 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 guys 🙂  If you have any doubts please contact us. The continuation of this post (PART 2) is Here.. Hope you are enjoying this.

Download our new Android app. You can learn all Embedded Tutorials from your Android Phone easily.

Click Here to Download App!