Bare Metal vs. RTOS vs. OS

Thread Starter

Kittu20

Joined Oct 12, 2022
462
I'm looking for help to understand the benefits of each of the programming techniques presented in this web page.

https://www.nabto.com/bare-metal-vs-rtos-vs-os/

I know some real world applications ( like fire alarm, LED blinking, LCD display, water level indicator..etc) in which bare metal technology is used.

I have searched a lot for real world application for RTOS and OS but I can't find examples of real world applications for RTOS and OS.

Do you know of any real world applications where it is beneficial to use an RTOS and an OS?

We'll discuss more when we have examples of real world applications
 

WBahn

Joined Mar 31, 2012
29,976
You typed this on an example of where OS is used. Windows, Linux, MacOS, Android are all examples of operating systems.

An RTOS, as the name implies, is for systems that have real-time performance constraints, particularly in terms of the ability to meet timing requirements. Lots of controllers in robotics and similar systems use an RTOS platform.
 

Thread Starter

Kittu20

Joined Oct 12, 2022
462
You typed this on an example of where OS is used. Windows, Linux, MacOS, Android are all examples of operating systems.
Do you consider all of these to be an embedded system on which an operating system runs? I asked because I read in some article that they don't consider them as embedded systems.


An RTOS, as the name implies, is for systems that have real-time performance constraints, particularly in terms of the ability to meet timing requirements. Lots of controllers in robotics and similar systems use an RTOS platform.
Robotics is huge filed. I am looking for a specific real world example. I just want to know that what would be the advantage of using RTOS in the application. We can discuss the rest once we have a specific real world example.
 

WBahn

Joined Mar 31, 2012
29,976
Do you consider all of these to be an embedded system on which an operating system runs? I asked because I read in some article that they don't consider them as embedded systems.
Your question didn't say anything about embedded systems.

But, yes, these operating systems are frequently used in embedded systems. A common example is the PC/104 family of embedded controllers.

Robotics is huge filed. I am looking for a specific real world example. I just want to know that what would be the advantage of using RTOS in the application. We can discuss the rest once we have a specific real world example.
Then consider a jet engine controller. Or the engine computers in most modern cars. Or the control systems for a nuclear power plant. Or any other power plant. Or an oil refinery. Or a space probe. Or a large telescope. Or a cellphone base station. The list goes on and on and on.
 

Thread Starter

Kittu20

Joined Oct 12, 2022
462
Then consider a jet engine controller. Or the engine computers in most modern cars. Or the control systems for a nuclear power plant. Or any other power plant. Or an oil refinery. Or a space probe. Or a large telescope. Or a cellphone base station. The list goes on and on and on.
Thank you very much for giving some examples.

In the list of examples you have provided, All these applications are very large and complex. it is difficult for me to understand at my level of knowledge what would be the benefit of implementing an RTOS in examples.

I'm searching for examples ( complex but small) in which I can do some research to find out what would benefit of using an RTOS. ( Timing, priority)
 
Last edited:

WBahn

Joined Mar 31, 2012
29,976
The advantage of an RTOS is that it allows you to implement larger and more complex embedded systems than is practical with bare metal, while still maintaining sufficient control over the timing to be able to satisfy performance or safety critical tasks on time in a deterministic manner (which is not the case with a normal OS). So asking for examples of where an RTOS would be beneficial in a small system is rather problematic.
 

BobTPH

Joined Jun 5, 2013
8,804
You use an RTOS when you have an application which you would have to write an RTOS to implement and you don’t have the expertise, time, money, desire, profit margin, etc to write own.
 

Thread Starter

Kittu20

Joined Oct 12, 2022
462
The advantage of an RTOS is that it allows you to implement larger and more complex embedded systems than is practical with bare metal, while still maintaining sufficient control over the timing to be able to satisfy performance or safety critical tasks on time in a deterministic manner (which is not the case with a normal OS). So asking for examples of where an RTOS would be beneficial in a small system is rather problematic.
What do you think about the below example

There are four rooms in one office and one reader is fixed at the door of each room.
When a person holding a valid card, scan his card in front of the reader, the door opens for 3 seconds and he can enter into the room, After this the door will automatically close .

If the person wants to come out of the room then he has to press the button on the door which will open the door for 3 seconds and he can come out. After this the door will automatically close.

The whole system consists of a microcontroller that has four UARTs, all they are connected to four RFID readers. The system has four switches and an four electronic door lock system. When the card is scanned in front of the RFID reader, the microcontroller receives 12 characters from the reader over UART. 9600 baud UART.

If there are four people in front of every door then there should be control every door
 

MrChips

Joined Oct 2, 2009
30,706
What is your definition of “real time”?

If your computerized door locks can respond in 200ms is that “real time”?
 

WBahn

Joined Mar 31, 2012
29,976
What do you think about the below example

There are four rooms in one office and one reader is fixed at the door of each room.
When a person holding a valid card, scan his card in front of the reader, the door opens for 3 seconds and he can enter into the room, After this the door will automatically close .

If the person wants to come out of the room then he has to press the button on the door which will open the door for 3 seconds and he can come out. After this the door will automatically close.

The whole system consists of a microcontroller that has four UARTs, all they are connected to four RFID readers. The system has four switches and an four electronic door lock system. When the card is scanned in front of the RFID reader, the microcontroller receives 12 characters from the reader over UART. 9600 baud UART.

If there are four people in front of every door then there should be control every door
What do you mean, what do I think about it?

I don't know what you mean by "there should be control every door".

I certainly don't see anything in this example that would require an RTOS. But if you had experience with an RTOS and had suitable hardware to run it, then developing a solution using one might be sufficiently faster to warrant the additional hardware expense.
 

WBahn

Joined Mar 31, 2012
29,976
RTOS is all about meeting deadlines, System should respond within guaranteed time to avoid any damage
But you have to come up with what that deadline is in order for it to make any sense.

Let's say that one of the things in your system is a smoke detector. You certainly want to guarantee that if the detector goes off that your system will respond to it within ten hours. But do you need to guarantee that it will respond to it within ten microseconds? If the maximum time between when the detector senses smoke and when the controller acts on it is five seconds, is that acceptable, or not? If not, what about half a second?
 

Thread Starter

Kittu20

Joined Oct 12, 2022
462
I certainly don't see anything in this example that would require an RTOS. But if you had experience with an RTOS and had suitable hardware to run it, then developing a solution using one might be sufficiently faster to warrant the additional hardware expense.
The system also has a deadline, if four people scan their card at the same time, their door should open and close for 3 seconds at the same time.

I am not saying that it cannot be done without RTOS. But if RTOS is applied for this application then how it will be design?

At least how many threads can be created?
 

WBahn

Joined Mar 31, 2012
29,976
The system also has a deadline, if four people scan their card at the same time, their door should open and close for 3 seconds at the same time.

I am not saying that it cannot be done without RTOS. But if RTOS is applied for this application then how it will be design?

At least how many threads can be created?
What is meant by "at the same time"? Does that mean that having one door start to open one microsecond after another door is unacceptable?
 

Thread Starter

Kittu20

Joined Oct 12, 2022
462
What is meant by "at the same time"? Does that mean that having one door start to open one microsecond after another door is unacceptable?
Can you see what is the effect on the system if these four tasks are executed in sequence

Main loop start :

  1. Check if the person standing at the door 1 is scanning the card or the person sitting inside the room presses the button then the door 1 should be opened and closed for 3 seconds.

  1. Check if the person standing at the door 2 is scanning the card or the person sitting inside the room presses the button then the door 2 should be opened and closed for 3 seconds.

  1. Check if the person standing at the door 3 is scanning the card or the person sitting inside the room presses the button then the door 3 should be opened and closed for 3 seconds.

  1. Check if the person standing at the door 4 is scanning the card or the person sitting inside the room presses the button then the door 4 should be opened and closed for 3 seconds.

Repeat all forever

Edit :

You can see that the micro controller is executing these tasks in a sequence, so the task may not complete on its own time limit, each task is blocking the other task.
 

WBahn

Joined Mar 31, 2012
29,976
But why would you perform those tasks in that sequence?

Why not something like:

LOOP FOREVER:
Read each inside switch and note which ones are pushed.
Read each scanner and record which ones have valid requests.
Open any closed door with a pushed switch or valid request, recording the time.
Close any door that has been open for more than three seconds.

This is a loop that can be executed so fast that it would be impossible for someone observing the doors to tell whether or not there was a difference in when any of the doors opened even if all of the buttons were pressed as close together as four people could make it. What differences did exist would be dominated by differences in the mechanical systems that operated the doors.
 

WBahn

Joined Mar 31, 2012
29,976
no one will die but system performance is affected. It would be bad system that does not meet the requirements
But what are the requirements?

"Same time" is NOT a valid requirement. It is physically impossible to meet. There will ALWAYS be a difference between them. No one can design a system to meet that requirement.

In some systems, two things that ideally should happen at the same time must happen within nanoseconds of each other in order to be acceptable. In other systems, two things that ideally should happen at the same time must only happen within the same day in order to be acceptable. The approach taken to design those two systems is VERY different.
 

Thread Starter

Kittu20

Joined Oct 12, 2022
462
But why would you perform those tasks in that sequence?

Why not something like:

LOOP FOREVER:
Read each inside switch and note which ones are pushed.
Read each scanner and record which ones have valid requests.
Open any closed door with a pushed switch or valid request, recording the time.
Close any door that has been open for more than three seconds.

This is a loop that can be executed so fast that it would be impossible for someone observing the doors to tell whether or not there was a difference in when any of the doors opened even if all of the buttons were pressed as close together as four people could make it. What differences did exist would be dominated by differences in the mechanical systems that operated the doors.
I agree with you that the tasks can be executed in sequence as you described. But my curiosity is that if RTOS is implemented in this then what will be the design solutions.

How many tasks would you have create as an application developer
 
Top