Here I came with a new post (RTOS Basics Tutorial – 1). Nowadays most companies are using RTOS. So mostly all controllers support 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 that need to know for RTOS. We have divided this tutorial into Two Parts. RTOS Basics and RTOS Advanced topics. If you want to see PART 2 please click here.
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 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 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
-
Hardware – provides basic computing resources (CPU, memory, I/O devices).
-
Operating system – controls and coordinates the use of the hardware among the various application programs for the various users.
-
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).
-
Users (people, machines, other computers).
Abstract View of System Components
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
- Shell
- Kernel
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 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.
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 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 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 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 take the 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.
-
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 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 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 loops are a fantastic solution for some systems. Like high-speed data channel, especially when events occur at widely spaced intervals and the processor is dedicated to handling the data channel.
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 wastage of CPU time.
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, and update the data, and then display it on 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 RTOS Basics – 1. The continuation of this post (PART 2) is here.
You can also read the below tutorials.
Embedded Software | Firmware | Linux Devic Deriver | RTOS
Hi, I’m SLR. I am a tech blogger and an Embedded Engineer. I am always eager to learn and explore tech-related stuff! also, I wanted to deliver you the same as much in a more straightforward way with more informative content. I generally appreciate learning by doing, rather than only learning. If you want to help support me on my journey, consider sharing my articles, or Buy me a Coffee! Thank you for reading my blog! Happy learning!