Author Topic: First RTOS project and first impressions  (Read 1325 times)

0 Members and 1 Guest are viewing this topic.

Offline e100Topic starter

  • Frequent Contributor
  • **
  • Posts: 566
First RTOS project and first impressions
« on: August 01, 2022, 01:20:23 pm »
Would it be fair to describe projects that use an RTOS as a delicate balancing act that aims to keeps producers, consumers and the interrupt timer watchdog happy?

My experience (as a beginner) is that contrary to expectations you cannot just add a new chunk of functionality as a separate task and expect it to happily co-exist without affecting other things. In addition anything that disables interrupts has the potential to trigger unexpected reboots. You have to be acutely aware of how the tasks interact which seems to contradict the claim that an RTOS allows blocks of functionality to be developed in isolation. Perhaps I'm doing things wrong, but as I said these are just my first impressions having come from superloop land.
« Last Edit: August 01, 2022, 04:28:40 pm by e100 »
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3359
  • Country: nl
Re: First RTOS project and first impressions
« Reply #1 on: August 01, 2022, 01:58:50 pm »
An RTOS is not some kind of magic wand that you wave at a problem to make it vanish.
Nor does it compensate for bad programming practices.
When I write ISR's for example they are never longer then a few hundred opcodes, and they execute in a a few tens of mircoseconds at most.

An RTOS also adds extra complexity, and it does take some studying to be able to work effectively with an RTOS. And RTOS does separate tasks from each other, and as long as those tasks live in their own bubble they are pretty much independent, but if a task can not communicate with other tasks it is not of much use. All interactions with other tasks has to be scrutinized carefully, but you can only do so if you if you have a fairly good knowledge of what an RTOS is, how it works, and where the limits are. Learning this takes a fair bit of study and practice. Below is a link to some exercise material, and it also has links to other aspects of an RTOS.

https://en.wikipedia.org/wiki/Dining_philosophers_problem
 
The following users thanked this post: nctnico

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26906
  • Country: nl
    • NCT Developments
Re: First RTOS project and first impressions
« Reply #2 on: August 01, 2022, 03:15:00 pm »
Over the years one of my observations is that programmers go through several stages as they gain more experience:

- Superloop
- Seperate processes
- Back to superloop combined with parallel threads
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 
The following users thanked this post: JPortici

Offline woofy

  • Frequent Contributor
  • **
  • Posts: 334
  • Country: gb
    • Woofys Place
Re: First RTOS project and first impressions
« Reply #3 on: August 01, 2022, 03:57:07 pm »
Over the years, I've looked at using an RTOS a few times, even wrote a simple one for the Z80 once though that was more of a round robin scheduler. I've never really felt they offered me anything worthwhile though, just "in my way".
Most RTOS implementations are likely to be on micro-controllers that do not have any form of memory protection or privileged mode. A task can write anything anywhere potentially nuking the entire system.
My own preferred method is super-loop and interrupts. That way all of the code, hardware (and responsibility) are mine.

Online peter-h

  • Super Contributor
  • ***
  • Posts: 3697
  • Country: gb
  • Doing electronics since the 1960s...
Re: First RTOS project and first impressions
« Reply #4 on: August 02, 2022, 10:34:18 am »
I am using FreeRTOS and would never go back to the old ways. Makes coding so much easier.

But it takes a fair bit of setting up.

I too wrote my own Z80/Z180/Z280 RTOS, in the 1980s, and it made product development (of complicated comms protocol converters, back then) much easier.

Quote
A task can write anything anywhere potentially nuking the entire system.

That's always the case. There were all kinds of idealistic approaches in the 1980s, with MMUs offering protection etc, but it has all been abandoned :) And simple chips like the ST ARM32 can't do it anyway.

Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19507
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: First RTOS project and first impressions
« Reply #5 on: August 02, 2022, 11:43:01 am »
Would it be fair to describe projects that use an RTOS as a delicate balancing act that aims to keeps producers, consumers and the interrupt timer watchdog happy?

Only in the sense that's true for all real-time systems, both soft and hard realtime, and software and hardware.

Quote
My experience (as a beginner) is that contrary to expectations you cannot just add a new chunk of functionality as a separate task and expect it to happily co-exist without affecting other things. In addition anything that disables interrupts has the potential to trigger unexpected reboots. You have to be acutely aware of how the tasks interact which seems to contradict the claim that an RTOS allows blocks of functionality to be developed in isolation. Perhaps I'm doing things wrong, but as I said these are just my first impressions having come from superloop land.

Ah. Someone that believes that technology X is a magic bullet.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19507
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: First RTOS project and first impressions
« Reply #6 on: August 02, 2022, 11:46:10 am »
Over the years one of my observations is that programmers go through several stages as they gain more experience:

- Superloop
- Seperate processes
- Back to superloop combined with parallel threads

For real-time systems, that's not too inaccurate :)

I'd add:
- understand the benefits of specifying, designing and implementing systems using events, states, and processing events (i.e. FSMs)
- each thread processes one event to completion before starting on another
- one thread per core, if possible
- storing process state in an object/struct, not in the program counter associated with a thread
- one level of interrupts (plus powerfail interrupt)
- one level of thread priority
« Last Edit: August 02, 2022, 11:51:36 am by tggzzz »
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19507
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: First RTOS project and first impressions
« Reply #7 on: August 02, 2022, 11:57:49 am »
Over the years, I've looked at using an RTOS a few times, even wrote a simple one for the Z80 once though that was more of a round robin scheduler. I've never really felt they offered me anything worthwhile though, just "in my way".
Most RTOS implementations are likely to be on micro-controllers that do not have any form of memory protection or privileged mode. A task can write anything anywhere potentially nuking the entire system.
My own preferred method is super-loop and interrupts. That way all of the code, hardware (and responsibility) are mine.

Realtime systems encompass far more than that! They include everything from hardware to software, from embedded to applications running in standard operating systems such as Unix.

It is rare that one person or even team writes all the code nowadays. Usually there is, at a minimum, a library of some sort in the code.

See my comments (and nctnico's) in reply #6 https://www.eevblog.com/forum/microcontrollers/first-rtos-project-and-first-impressions/msg4334740/#msg4334740
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf