Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Embedded RTOS in C++

Embedded RTOS in C++

Many of the RTOS on the market (also in the open source world) are today written in C. There are few exceptions, which are completely written in C++. For some there also exist C++ wrappers. What advantages (and potential disadvantages) you get by using a RTOS written in C++?
We will compare scmRTOS (written in C++) with FreeRTOS (written in C).

Stefan Petersen

February 20, 2020
Tweet

More Decks by Stefan Petersen

Other Decks in Programming

Transcript

  1. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Embedded RTOS in C++ Example comparing scmRTOS (C++) and FreeRTOS (C) Stefan Petersen Stockholm C++ Meetup (part of SwedenCpp), 2020 Released under Creative Commons BY-NC-SA 3.0 CC BY: $ \ C
  2. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Deconstruction Let us deconstruct the title to see what it actually means: • RTOS (Real-Time Operating System) • C++ • microcontrollers (MCU’s)
  3. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus RTOS (Real-Time Operating System) A real-time operating system (RTOS) is any operating system (OS) intended to serve real-time applications that process data as it comes in, typically without buffer delays. Processing time . . . are measured in tenths of seconds or shorter. . . . . . has well defined fixed time constraints. . . . . . . Most RTOS’s use a pre-emptive scheduling algorithm. . . . A key characteristic of an RTOS is the level of its consistency concerning the amount of time it takes to accept and complete an application’s task; the variability is jitter.. . . can meet a deadline deterministically. . . https://en.wikipedia.org/wiki/Real-time_operating_system
  4. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus C++ Most projects for MCU’s are today in C: • Vendor libraries (SDK) are usually C only • Lots of example on the internet for C style solutions • Simplification. “Time to Hello World” (Michael Caisse) • Most RTOS’s are written for and in C.
  5. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus C++ (contd.) Maybe you can’t use the whole of the C++ standard on a microcontroller, but at least it gives us: • Type safety • Templating • Lambda • Constexpr • Iterators • Constructors/Destructors • . . .
  6. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Microcontrollers In this talk I limit myself to ARM Cortex-M series. Compared to your desktop PC: • Limits in CPU speed • Limits in flash size (program memory) • Limits in RAM size, no heap • Simple, direct connection to hardware (lights, buttons etc) ⇒ programming “close to the metal” • Limited IO (serial port) • -fno-exceptions -fno-rtti
  7. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Microcontrollers In this talk I limit myself to ARM Cortex-M series. Compared to your desktop PC: • Limits in CPU speed • Limits in flash size (program memory) • Limits in RAM size, no heap • Simple, direct connection to hardware (lights, buttons etc) ⇒ programming “close to the metal” • Limited IO (serial port) • -fno-exceptions -fno-rtti
  8. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Microcontrollers In this talk I limit myself to ARM Cortex-M series. Compared to your desktop PC: • Limits in CPU speed • Limits in flash size (program memory) • Limits in RAM size, no heap • Simple, direct connection to hardware (lights, buttons etc) ⇒ programming “close to the metal” • Limited IO (serial port) • -fno-exceptions -fno-rtti
  9. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Microcontrollers In this talk I limit myself to ARM Cortex-M series. Compared to your desktop PC: • Limits in CPU speed • Limits in flash size (program memory) • Limits in RAM size, no heap • Simple, direct connection to hardware (lights, buttons etc) ⇒ programming “close to the metal” • Limited IO (serial port) • -fno-exceptions -fno-rtti
  10. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Microcontrollers In this talk I limit myself to ARM Cortex-M series. Compared to your desktop PC: • Limits in CPU speed • Limits in flash size (program memory) • Limits in RAM size, no heap • Simple, direct connection to hardware (lights, buttons etc) ⇒ programming “close to the metal” • Limited IO (serial port) • -fno-exceptions -fno-rtti
  11. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Microcontrollers In this talk I limit myself to ARM Cortex-M series. Compared to your desktop PC: • Limits in CPU speed • Limits in flash size (program memory) • Limits in RAM size, no heap • Simple, direct connection to hardware (lights, buttons etc) ⇒ programming “close to the metal” • Limited IO (serial port) • -fno-exceptions -fno-rtti
  12. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Microcontrollers In this talk I limit myself to ARM Cortex-M series. Compared to your desktop PC: • Limits in CPU speed • Limits in flash size (program memory) • Limits in RAM size, no heap • Simple, direct connection to hardware (lights, buttons etc) ⇒ programming “close to the metal” • Limited IO (serial port) • -fno-exceptions -fno-rtti
  13. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus What options are there? Non exhaustive search for open source C++ RTOS on https://en.wikipedia.org/wiki/Comparison_of_real-time_ operating_systems https://www.osrtos.com/ • BOOS Core (http://www.baigudin.software/boos/) (odd architectures) • distortos (http://distortos.org/) • miosix (http://www.miosix.org/) • scmRTOS (https://github.com/scmRTOS) • CRECT gets an honourable mention (Emil Fresk, Luleå) (https://github.com/korken89/crect)
  14. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus std::thread • The optimal would be to be able to use std::thread et al available in C++ already • Piotr Grygorek have started that, using FreeRTOS • Not easy nor optimal • std::thread is not designed with RTOS in mind • My feeling is that std::thread is based on pthreads https://github.com/grygorek/FreeRTOS_cpp11 https://www.codeproject.com/Articles/1278513/ Cplusplus11-FreeRTOS-GCC
  15. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus scmRTOS https://github.com/scmRTOS • MIT License • Written by a couple of Russian guys (I’m not involved at all) • Has good documentation (in “Runglish” and Russian) • Split up in three parts: • Core • Ports (or rather sample projects with ports) • Documentation • Simple enough for me to grasp the major parts • Generates small and fast code • Check the branch develop
  16. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus FreeRTOS https://freertos.org/ • License, GPL...ish • Single guy company, bought up by Amazon • Several different commercial options (openRTOS/safeRTOS) • Very widespread, ported to very many platforms • Several chip vendors ship it as part of their SDK • Has good documentation, both books and website • Many macros and “versions” of the same commands (foot gun) • Hungarian notation. . .
  17. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Details on how to use it We will compare how to use some of the elementary functions of respective RTOS: • Process/threads/task • Mutexes • Signals • Queues What can an RTOS provide? • Software timers • File system • Protocols like TCP/IP • Memory management
  18. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Details on how to use it We will compare how to use some of the elementary functions of respective RTOS: • Process/threads/task • Mutexes • Signals • Queues What can an RTOS provide? • Software timers • File system • Protocols like TCP/IP • Memory management
  19. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Details on how to use it We will compare how to use some of the elementary functions of respective RTOS: • Process/threads/task • Mutexes • Signals • Queues What can an RTOS provide? • Software timers • File system • Protocols like TCP/IP • Memory management
  20. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Details on how to use it We will compare how to use some of the elementary functions of respective RTOS: • Process/threads/task • Mutexes • Signals • Queues What can an RTOS provide? • Software timers • File system • Protocols like TCP/IP • Memory management
  21. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Details on how to use it We will compare how to use some of the elementary functions of respective RTOS: • Process/threads/task • Mutexes • Signals • Queues What can an RTOS provide? • Software timers • File system • Protocols like TCP/IP • Memory management
  22. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Details on how to use it We will compare how to use some of the elementary functions of respective RTOS: • Process/threads/task • Mutexes • Signals • Queues What can an RTOS provide? • Software timers • File system • Protocols like TCP/IP • Memory management
  23. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Process/threads/task • Conceptually standalone unit. • Needs a stack with size, implicit or explicit. • Hard to estimate size • Leads to over provisioning • Leads to “waste of memory” • Switching time sets the bar of RT (real time) in RTOS.
  24. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Process, FreeRTOS https://www.freertos.org/a00125.html BaseType_t xReturned; TaskHandle_t xHandle = NULL; /* Create the task, storing the handle. */ xReturned = xTaskCreate( vTaskCode, "NAME", STACK_SIZE, ( void * ) 1, tskIDLE_PRIORITY, &xHandle ); if( xReturned == pdPASS ) { /* The task was created. */ vTaskDelete( xHandle ); }
  25. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Process, FreeRTOS, continued https://www.freertos.org/xTaskCreateStatic.html #define STACK_SIZE 200 StaticTask_t xTaskBuffer; StackType_t xStack[ STACK_SIZE ]; /* Function that implements the task being created. */ void vTaskCode( void * pvParameters ) { for( ;; ) { /* Task code goes here. */ } }
  26. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Process, FreeRTOS, continued /* Function that creates a task. */ void vOtherFunction( void ) { TaskHandle_t xHandle = NULL; /* Create the task without using any dynamic memory allocation. */ xHandle = xTaskCreateStatic( vTaskCode, "NAME", STACK_SIZE, ( void * ) 1, tskIDLE_PRIORITY, xStack, &xTaskBuffer ); /* Use the handle to suspend the task. */ vTaskSuspend( xHandle ); }
  27. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Process declaration, scmRTOS ... typedef OS::process<OS::pr8, 600> TPos2ReplyProcess; typedef OS::process<OS::pr9, 600> TSkerReplyProcess; typedef OS::process<OS::pr10, 768> TModemProcess; ...
  28. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Process implementation, scmRTOS namespace OS { template<> OS_PROCESS void TSkerReplyProcess::exec() { for(;;) { pbuf_t *pbuf = nullptr; serial::hdlc_rx_sker_channel.pop(pbuf); send_reply(’s’, pbuf); pbuf_free(pbuf); } } } TSkerReplyProcess SkerReplyProcess("SKER Re");
  29. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Mutexes • Comes from “mutual exclusion” • Only one process at a time can be in a critical section • Take must always be followed by a Release (pair) • Can cause deadlocks if not careful • Don’t have to wait mutex release, just check or have a timeout. . .
  30. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Mutexes, FreeRTOS SemaphoreHandle_t xSemaphore; /* Create a mutex type semaphore. */ xSemaphore = xSemaphoreCreateMutex(); { /* See if we can obtain the semaphore. If the semaphore is not available wait 10 ticks to see if it becomes free. */ if( xSemaphoreTake( xSemaphore, ( TickType_t ) 10 ) == pdTRUE ) { /* We were able to obtain the semaphore and can now access the shared resource. */ /* ... */ /* We have finished accessing the shared resource. Release the semaphore. */ xSemaphoreGive( xSemaphore ); } }
  31. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Mutexes, FreeRTOS, contd. { xSemaphoreTake( xSemaphore, portMAX_DELAY); varA += 1; xSemaphoreGive( xSemaphore ); } { xSemaphoreTake( xSemaphore, portMAX_DELAY); varA += 1; if (varA == broken) { return; } varA += 3; xSemaphoreGive( xSemaphore ); }
  32. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Mutexes, FreeRTOS, contd. { xSemaphoreTake( xSemaphore, portMAX_DELAY); varA += 1; xSemaphoreGive( xSemaphore ); } { xSemaphoreTake( xSemaphore, portMAX_DELAY); varA += 1; if (varA == broken) { return; } varA += 3; xSemaphoreGive( xSemaphore ); }
  33. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Mutexes, FreeRTOS, contd. { xSemaphoreTake( xSemaphore, portMAX_DELAY); varA += 1; xSemaphoreGive( xSemaphore ); } { xSemaphoreTake( xSemaphore, portMAX_DELAY); varA += 1; if (varA == broken) { xSemaphoreGive( xSemaphore ); return; } varA += 3; xSemaphoreGive( xSemaphore ); }
  34. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Mutexes, scmRTOS OS::TMutex my_mutex; ... { OS::TMutexLocker lock(my_mutex); varA += 1; } { OS::TMutexLocker lock(my_mutex); varA += 1; if (varA == broken) { return; } varA += 3; }
  35. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Mutexes, scmRTOS OS::TMutex my_mutex; ... { OS::TMutexLocker lock(my_mutex); varA += 1; } { OS::TMutexLocker lock(my_mutex); varA += 1; if (varA == broken) { return; } varA += 3; }
  36. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Signals • Simple signals between process. • “I’m done” or “There is data”. • I use it for interrupt signalling for instance. 1. Process waiting for signal 2. Interrupt comes in, generates a signal and interrupt is done 3. The process starts processing the data from the interrupt • Can be a counting version.
  37. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Signals, continued • Also special version if you are signalling in interrupt context or not • In FreeRTOS a similar operation is called EventGroup • In FreeRTOS there is also direct to task signalling mechanism • Implemented task signalling to Atom Threads, pull request stale since 2016 :-(
  38. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Signals, FreeRTOS, declaring /* Declare a variable to hold the handle of the created event group. */ EventGroupHandle_t xEventGroupHandle; /* Declare a variable to hold the data associated with the created event group. */ StaticEventGroup_t xCreatedEventGroup; /* Attempt to create the event group. */ xEventGroupHandle = xEventGroupCreateStatic( & xCreatedEventGroup ); /* pxEventGroupBuffer was not null so expect the event group to have been created? */ configASSERT( xEventGroupHandle );
  39. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Signals, FreeRTOS, signalling #define BIT_0 ( 1 << 0 ) #define BIT_4 ( 1 << 4 ) ... EventBits_t uxBits; /* Set bit 0 and bit 4 in xEventGroup. */ uxBits = xEventGroupSetBits( xEventGroup, BIT_0 | BIT_4 );
  40. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Signals, FreeRTOS, waiting EventBits_t uxBits; const TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS; /* Wait a maximum of 100ms for either bit 0 or bit 4 to be set within the event group. Clear the bits before exiting. */ uxBits = xEventGroupWaitBits( xEventGroup, /* The event group */ BIT_0 | BIT_4, /* The bits to wait for. */ pdTRUE, /* Should be cleared before return. */ pdFALSE, /* Don’t wait for both bits */ xTicksToWait );/* Wait a maximum of 100ms */
  41. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Signals, scmRTOS OS::TEventFlag scc_interrupt_event; ... for(;;) { scc_interrupt_event.wait(); // alternative bool timed_out = scc_interrupt_event.wait(100); ... scc_interrupt_event.signal(); } ... OS_INTERRUPT void EXTI0_IRQHandler() { OS::TISRW ISR; scc_interrupt_event.signal_isr(); exti0.clear(); }
  42. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Queues • Used to send data between process • Single direction • Handling for when when queue is empty and when it is full • Can both “stop” process or just do a check • Called “channel” in scmRTOS. • Spoiler. . . Type safety for the win.
  43. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Queues, FreeRTOS #define QUEUE_LENGTH 10 #define ITEM_SIZE sizeof( uint64_t ) static StaticQueue_t xStaticQueue; /* The array to use as the queue’s storage area. This must be at least uxQueueLength * uxItemSize bytes. */ uint8_t ucQueueStorageArea[ QUEUE_LENGTH * ITEM_SIZE ]; void vATask( void *pvParameters ) { QueueHandle_t xQueue; xQueue = xQueueCreateStatic( QUEUE_LENGTH, ITEM_SIZE, ucQueueStorageArea, &xStaticQueue ); configASSERT( xQueue ); }
  44. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Queues, FreeRTOS, continued BaseType_t xQueueSend(QueueHandle_t xQueue, const void * pvItemToQueue, TickType_t xTicksToWait); if( xQueueSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS ) { /* Failed to post the message, even after 10 ticks. */ }
  45. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Queues, scmRTOS class SomeClass_t { ... }; constexpr size_t QUEUE_SIZE = 32; OS::channel<SomeClass_t, QUEUE_SIZE> tx_channel; ... // Insert data SomeClass_t SomeData = {...}; tx_channel.push(SomeData); ... bool timed_out = tx_channel.pop(SomeData, 1000); ... tx_channel.pop(SomeData); ...
  46. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Extending scmRTOS using inheritance Since scmRTOS is written in C++ and modularised with classes, it is quite easy to extend. We inherit from OS::TService and fill in our operations. . . . . . ish
  47. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Extending scmRTOS using inheritance Since scmRTOS is written in C++ and modularised with classes, it is quite easy to extend. We inherit from OS::TService and fill in our operations. . . . . . ish
  48. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Extending scmRTOS using inheritance Since scmRTOS is written in C++ and modularised with classes, it is quite easy to extend. We inherit from OS::TService and fill in our operations. . . . . . ish
  49. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Extending scmRTOS using inheritance ... #include "scmRTOS.h" #include "os_services.h" namespace OS { class TEventFlagCount : protected TService { public: explicit TEventFlagCount(uint32_t init_val = 0) : ProcessMap(0), Count(init_val) { } bool wait(timeout_t timeout = 0); INLINE void signal(); INLINE void clear() { TCritSect cs; Count = 0; } INLINE void signal_isr(); INLINE bool is_signaled() { TCritSect cs; return Count > 0; } protected: volatile TProcessMap ProcessMap; volatile uint32_t Count; }; }
  50. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Extending scmRTOS using inheritance, continued #include "eventflag_cnt.hpp" bool OS::TEventFlagCount::wait(timeout_t timeout) { TCritSect cs; if(Count > 0) // if flag already signaled { Count -= 1; // clear flag return true; } else { cur_proc_timeout() = timeout; suspend(ProcessMap); if(is_timeouted(ProcessMap)) return false; // waked up by timeout or by externals cur_proc_timeout() = 0; return true; // otherwise waked up by signal() or signal_isr() } }
  51. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Conclusions • Lots of boiler plate code for error handling in C (FreeRTOS). • FreeRTOS available for all platforms • Type safety in C++ • Template in C++ • Constructor/destructor in C++ • Inheritance in C++ • Bool(ean) in C++ • Order of execution of global constructors missing in C++
  52. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Conclusions • Lots of boiler plate code for error handling in C (FreeRTOS). • FreeRTOS available for all platforms • Type safety in C++ • Template in C++ • Constructor/destructor in C++ • Inheritance in C++ • Bool(ean) in C++ • Order of execution of global constructors missing in C++
  53. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Conclusions • Lots of boiler plate code for error handling in C (FreeRTOS). • FreeRTOS available for all platforms • Type safety in C++ • Template in C++ • Constructor/destructor in C++ • Inheritance in C++ • Bool(ean) in C++ • Order of execution of global constructors missing in C++
  54. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Conclusions • Lots of boiler plate code for error handling in C (FreeRTOS). • FreeRTOS available for all platforms • Type safety in C++ • Template in C++ • Constructor/destructor in C++ • Inheritance in C++ • Bool(ean) in C++ • Order of execution of global constructors missing in C++
  55. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Conclusions • Lots of boiler plate code for error handling in C (FreeRTOS). • FreeRTOS available for all platforms • Type safety in C++ • Template in C++ • Constructor/destructor in C++ • Inheritance in C++ • Bool(ean) in C++ • Order of execution of global constructors missing in C++
  56. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Conclusions • Lots of boiler plate code for error handling in C (FreeRTOS). • FreeRTOS available for all platforms • Type safety in C++ • Template in C++ • Constructor/destructor in C++ • Inheritance in C++ • Bool(ean) in C++ • Order of execution of global constructors missing in C++
  57. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Conclusions • Lots of boiler plate code for error handling in C (FreeRTOS). • FreeRTOS available for all platforms • Type safety in C++ • Template in C++ • Constructor/destructor in C++ • Inheritance in C++ • Bool(ean) in C++ • Order of execution of global constructors missing in C++
  58. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Conclusions • Lots of boiler plate code for error handling in C (FreeRTOS). • FreeRTOS available for all platforms • Type safety in C++ • Template in C++ • Constructor/destructor in C++ • Inheritance in C++ • Bool(ean) in C++ • Order of execution of global constructors missing in C++
  59. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Conclusions • Lots of boiler plate code for error handling in C (FreeRTOS). • FreeRTOS available for all platforms • Type safety in C++ • Template in C++ • Constructor/destructor in C++ • Inheritance in C++ • Bool(ean) in C++ • Order of execution of global constructors missing in C++
  60. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Conclusions, continued scmRTOS is a good project: • if you want a simple, extendable RTOS in C++ • if you need a reference project to start embedded programming in C++
  61. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Conclusions, continued scmRTOS is a good project: • if you want a simple, extendable RTOS in C++ • if you need a reference project to start embedded programming in C++
  62. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Conclusions, continued scmRTOS is a good project: • if you want a simple, extendable RTOS in C++ • if you need a reference project to start embedded programming in C++
  63. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Questions Thank you! Questions? Contact: spe (at) ciellt (dot )se
  64. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Projects where I’ve used scmRTOS Projects I have used scmRTOS in, so far: • GIF viewer in button format, running on nRF52 (BLE) and a round display • Two wire “modem” with home made polling protocol using HDLC for the “men in green” • Radio scanner used in car races in the US (not released yet)
  65. Deconstructing Examples of RTOS’s Implementation, FreeRTOS vs scmRTOS Extending Finale

    Bonus Bonus, additions and updates to scmRTOS Updates and additions I have made to scmRTOS, so far: • Updated to newer CMSIS (register) • Removed TCBuf (complaints from cppcheck, removed) • Implemented counting signalling (eventflag_cnt) • Implemented event flags, bitmask for signalling • Implemented software timer