Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 6 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.
Chuck
1 Answer
10 years, 6 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.