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.
11 years, 4 months ago.
How to reference the 'main' thread when using RTOS ?
I am using RTOS and I would like to set a signal for the 'main thread'. However, there is no function or object to refer to for the main thread which executes the main() function. Any ideas how I could set that signal (without having to create a new thread and put everything into the new thread) ?
3 Answers
11 years, 2 months ago.
Possibly this is what you are trying to achieve. I can't see how to do it with the signal_set and signal_wait methods. Incedently, does anyone know what the signal (0x1) is? Can other signal values be used and if so are they separate or can you use a mask to set, or more likely, wait on different signals simultaneously? I can't find any real documentation on how these should be used.
main.ccp
#include "mbed.h" #include "rtos.h" DigitalOut led(LED1); osThreadId mainThreadID; void signal_thread(void const *argument) { while (true) { Thread::wait(1000); osSignalSet(mainThreadID, 0x1); } } int main (void) { mainThreadID = osThreadGetId(); Thread thread(signal_thread); while (true) { // Signal flags that are reported as event are automatically cleared. osSignalWait(0x1, osWaitForever); led = !led; } }
11 years, 4 months ago.
Main is the main(principal) thread of the application. You can't refer the main thread. If you want you can reset the mbed and the aplication will start over. If you need data before reset save that data to memory and load-it when the application restart.
11 years, 4 months ago.
@Alexandru Pahomi can you explain specifically how to retrieve the data used before reset()? like give an example. let's say I have : int data = 5; then I do mbedreset(). What do I do next to retrieve data?