RTEMS C++ examples?

Chris Johns chrisj at rtems.org
Fri Jul 26 01:03:33 UTC 2019

On 25/7/19 2:56 pm, groups at chichak.ca wrote:
> I’m working on a bit of a hobby project right now and someone bullied me into trying C++. Fine. Plus I did say that I’d try it in anger at some point.

Good on them. My first large application run on RTEMS was a ported C++
application in the mid '90s. It was moved from an old cfront 3.0 compiler to gcc
and RTEMS.

> So far I’ve managed to get a simple Init going that creates two tasks. I haven’t tried it yet, since it was 2AM when I finally got the right sequence of extern “C”s in place to get it to compile.


> Once I get something that demonstrates that the tasks are truly running and have some sort of demonstrable C++ nature, I’ll send someone a zip of the project file set and maybe I could learn some better idioms to get this stuff going and we can all learn from this.

As far as I can see the C++11 and later thread support does not let us set POSIX
attributes like the stack size or real-time modes when creating threads which is
a shame but some other pieces of libstdc++ should work nicely. I suggest you
take a look at the mutex interface [1] ...

#include <mutex>

std::recursive_mutex rlock;

void foo(blahs& blah)
   // hold the mutex while in this function
   std::lock_guard<std::recursive_mutex> guard(rlock);
   blah.blah().blah = "blah";


[1] https://en.cppreference.com/w/cpp/thread/recursive_mutex

More information about the users mailing list