Is there any ported RTOS for STM32F407VE?

mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Is there any ported RTOS for STM32F407VE?

Post by mrburnette »

ag123 wrote: Fri Feb 14, 2020 3:23 pm but seriously even an event loop may be deemed superfluous, if ray reads this thread, he'd probably agree ;)
many other things has been done without needing an event loop
...
For sure :D


What RTOS brings to the table are semaphore and mutex. Personally, while many programmers successfully implement these concepts, they are generally absent/foreign to Arduino thinkers - excepting multi-core chips such as the ESP32 where the Arduino implementation already has freeRTOS implemented by default and can easily be extended by the project programmer:
Example

As Arduino implements the standard C-code block main() as the abstraction-wrapper loop(), most Arduino programmers are best served by avoiding RTOS and coding for a series of function calls within the loop() structure... just avoid "blocking" functions to achieve a smooth loop() transition: discussion.


Ray
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Is there any ported RTOS for STM32F407VE?

Post by ag123 »

thanks ray, :)
just 2 cents, the use of semaphore & mutexes is relevant in the context of multi-threaded (or multi-processing) apps.
for the lazy (maybe just me) people, sometimes we simply spin lock to get what we need.
e.g.

Code: Select all

while(1)
  if(done()) break;
inefficient - sure, but more commonly i insert a asm("wfi"), which is nearly the same as yield(). for single threaded mode, yield() does nothing.
and asm("wfi") simply waits for the next systick and sleeps. semaphore & mutexes would really help as the 'RT'-OS takes care of that and instead of running busy spin locks the thread just stop running and cpu timeslice is given to other threads.

imho again, event loop is simply a different way of thinking about the normal loop(), i found it sometimes useful to based around an event loop setup as one could think of say a task() that check for buttons/keys and insert those key/button presses as events in the event loop. the dispatcher then poll the event handlers passing the event as an argument. each event handler then evaluate the event e.g. the key press and decides if it needs to service it.
this is very much like gui programming in windows, java swing etc.

the use of a queue in this way has some advantages, for instance an interrupt service routine (handler) can be used to post that key/button to the queue. this can happen outside the event dispatcher loop. but that keypress would still be routed to a event handler handling the event in due course. and in addition, things are strictly sequential. Hence, synchronization isn't needed.

i'd guess it is also a reason java forbid use of threads in the event dispatcher thread as messing with threads reading from, writing to a same queue can instead cause a deadlock. the event queue and loop (dispatcher) forces serialization and sequential processing of events - in a most inefficient manner, but by just forcing that, there is less of a synchronization concern, a queue forces every event to be processed sequentially rather than possibly concurrently. this significantly simply various codes. less worries about synchronization deadlocks etc e.g. instead of spin lock for a keystroke, button press, simply wait to receive the event from the event dispatcher in the event handler
User avatar
Pito
Posts: 94
Joined: Tue Dec 24, 2019 1:53 pm

Re: Is there any ported RTOS for STM32F407VE?

Post by Pito »

This is one of the best RTOSes you may get for F407:

http://chibios.org/dokuwiki/doku.php

Best way to start is with ChibiStudio:

http://chibios.org/dokuwiki/doku.php?id ... udio:start

The author of Chibios works for STM, afaik.
Pukao Hats Cleaning Services Ltd.
Post Reply

Return to “STM32F4 based boards”