Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Why would you need a RTOS

Status
Not open for further replies.

John99407

Junior Member level 3
Joined
Jul 14, 2019
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
240
Hiii

I do not have good idea on RTOS . real-time system has time-critical deadlines that must be met;


why RTOS only?. What it does ? does it complete task in deadline ?
 

If you have a real-time app (i.e that it must respond within a specified period of time) then I would leave an RTOS alone.
In my experience an RTOS can make programming a little easier if all of the tasks can be broken down to time-sliced components and/or each task will give up the processor in a cooperative manner (via semaphores and the other mechanisms the RTOS may provide). I've not seen any task that uses an RTOS that could not also have been written as a series of calls from the main loop with properly written and cooperative sub-tasks.
Even with an RTOS you need to resort to ISRs to things that must be responded to quickly.
You have not told us anything useful about what you are trying to do but if you need to learn an RTOS on top of everything else for a real-time then I would suggest that you stick to the real-time aspects and leave the RTOS until later (if at all).
Susan
 
Even with an RTOS you need to resort to ISRs to things that must be responded to quickly.
You have not told us anything useful about what you are trying to do but if you need to learn an RTOS on top of everything else for a real-time then I would suggest that you stick to the real-time aspects and leave the RTOS until later (if at all).
Susan
real-time aspects means system should be complete task within deadline. What happen when it fail to complete task in deadline? Does the task go to the Suspend State?
 

Hi,

Real time tssks:
*audio processing. Any incoming data needs to be processed.
- Often data by data in a filter. One data in, one data out.
- or as packets in an compression/decompression like MPEG.
If it fails to process the data within the given time, then you loose data. The sound will stutter.

Most of my applications are real time applications. Measurement devices and regulation loops.
Maybe 8 channels of audio data with some kilohertz of sampling rate each channel.
Not a single value should be missed in a 7/24 operation. But at the same time the data needs to be analyzed, continously.
At the same time: input keys need to be sampled and processed, data written on display, communication via USB needs to be processed, several sensors on a bus need to be handled.....all seems to be processed at the same time.

Klaus
 

real-time aspects means system should be complete task within deadline. What happen when it fail to complete task in deadline? Does the task go to the Suspend State?
There are two issues here: 1) what happens if you don't process all of the data fast enough and 2) what happens to the task at the end of the RTOS time slice.
The first issue has nothing to do with an RTOS but everything to do with the context of your app. If you can't process some of the data fast enough then you might lose it for ever - and the consequences of that vary from "who cares" to "loss of life". I have a system that as a BLE server that advertises for 5 seconds and, if the client does not connect and read the data within that time, the data is lost for ever and the whole systems has to wait another 10 minutes for the server to advertise again. I really don't care if the data is lost but it is still "real time".
If the app was monitoring someone's heart and it can't process the data fast enough, then missing a sample may cause the system to do something that kills the patient!
The 2nd issue depends on the RTOS; the one's I've used will suspend the task until the next timeslice or whenever no other task can run, and then it resumes the task from where it left off. However it can depend on the RTOS you are using and how you set it up.
Susan
 
Hi,

Real time tssks:
*audio processing. Any incoming data needs to be processed.
- Often data by data in a filter. One data in, one data out.
- or as packets in an compression/decompression like MPEG.
If it fails to process the data within the given time, then you loose data. The sound will stutter.

Klaus

When do you consider a system to be a real time system?

Each task has a deadline by which it must complete. If the deadline of the task is less then 15ms, will it be a real time system ?
 

Hi,

When do you consider a system to be a real time system?

Each task has a deadline by which it must complete. If the deadline of the task is less then 15ms, will it be a real time system ?

There is no limit of absolute time.

One of the most complex systems may be weather forecast calculation. They run every couple of hours and need to be finished before the whether news are spoken.
If I´m not mistaken such a calculation may take several hours.
If it is started peridically at a dedicated time (let´s say every 4 hours) and it needs to be finished after 3.5 hours .. you may call it a real time requirement.

Most of real time applications run in microseconds up to hundreds of milliseconds.

An example: audio processing using an FFT.
Let´s say sampling frequency is 44.100kHz and FFT size is 1024 samples.
Then you have two "real time tasks" running at the same time.
* Sampling of audio data, conversion, read date and store data in an array. Every single sample needs to be stored within 1/44100 s = about 22.5us. If one such a progress takes longer, than that you may have lost data.
* and there is the FFT task. It needs to run every 1024 samples = 23.2ms. If the FFT calculation takes longer than that (mind: it will be periodically interrupted by the "sampling" task above) .. you will loose data. Worst case a complete FFT.
Even worse if your system hangs because of this timing problem.

Klaus
 

Hi,

There is no limit of absolute time.

Most of real time applications run in microseconds up to hundreds of milliseconds.

Even worse if your system hangs because of this timing problem.

Klaus

Klaus Thanks, you have provided very useful information. digital signal processing for the communication is out of my work area. Have you designed real time systems other than for digital signal processing?
 

Hi,

digital signal processing for the communication is out of my work area. Have you designed real time systems other than for digital signal processing?
I´m confused a bit.

when one writes software the usual flow is:
input --> processing --> output.

So for sure "input" may mean: analog measurement data, digtal sensor date, video data.... this is all the case with my applications.
Now I ask myself: "is there software, that does not process data"? and "Is pressing a key no signal"?

In either case: All my real time applications do process data. (I asume: like all measurement and regulation applications.).
But this does not mean that I use RTOS. In most (all?) applications we do this with interrupt controlled time slices (processed in main loop context) and independetly running ISRs.

Klaus
 

Hi,
But this does not mean that I use RTOS. In most (all?) applications we do this with interrupt controlled time slices (processed in main loop context) and independetly running ISRs.

Klaus

Do you use interrupts to run any task for specific time?

I assume if we have complete three task with different priority

3-Tasks(Task1, Task2 and Task) are created with priorities 3, 2,1 and schedule time 20ms, 30ms, and 25 ms

you will set interrupt for 20 ms to run task 1 , interrupt for30ms to run task 2 and interrupt for 25 ms for task 3
 

Usually the interrupts are responsible for timing when the tasks are switched. Typically a timer generates the interrupt at some period and the ISR does whatever is necessary to save the present context and switch to the new task. The period can be fixed or adapt to the requirements of the program.

Done fast enough it gives the impression the processor is running several programs at once when in reality it is actually only running one at a time but selecting that one out of several.

Brian.
 

Done fast enough it gives the impression the processor is running several programs at once when in reality it is actually only running one at a time but selecting that one out of several.

Brian.
What do we need to set priority in program ?

suppose 3-Tasks(Task1, Task2 and Task) with priorities 3, 2,1


Code:
   int main ()
   {
      intilize();
	  
	  while ()
	  {
	  }
	  return 0;
   }
   
    ISR1() // do the task1 for 20ms
    {
	  do task1;
	}	
	  
    ISR2()  /// do the task2 for 30ms
    {
	  do task2;
	}

   	ISR3()  /// do the task3 for 25ms
    {
	  do task3;
	}
 

Hi,

Do you use interrupts to run any task for specific time?
Yes, as said already.

*************
Your 20/25/30 ms tasks.
I'd setup a timer to interrupt every 5ms.
Within the ISR there run three counters. To start the tasks every 4/5/6 runs.

Klaus
 

Don't use three ISRs, use one ISR and trigger it from a timer. That way you can dynamically change how long each task needs from within the program by loading different timer start values.

Note that 'priority' is the term usually used to decide how urgent a routine is needed rather than how long it can execute for.

Brian.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top