5 years, 10 months ago.

Signalling the "main" thread in RTOS

As I understand it, "main" is a defined thread when running the RTOS.

How do I reference the main thread, for example to set a signal in another thread?

I tried main.signal_set(0x1); for example but this does not compile, saying "main" is undefined.


1 Answer

5 years, 10 months ago.

You can't call main.signal_set(0x1) because main is not a Thread object, it's just a function. What you need to do is figure out main's thread ID by calling Thread::gettid() within the main thread. This will give you an osThreadId variable that you can use with the regular CMSIS-RTOS functions. Calling osSignalSet(yourMainThreadID, 0x1) will do the trick.

Accepted Answer