Hi,
I'm pretty new to RTOS programming and was given a project where some work was already done (also by someone with limited RTOS experience). It's mostly code compiled from various different SDK examples. It is all working at the moment so this is not the problem. I just have some general question about thread/task creation where I couldn't find the answer in the documentation.
Our current setup is something like this:
int main() { pthread_create( ..., *thread_A, ...); // created in detached state BIOS_start(); } void *thread_A() { GPIO_init(); ... pthread_create( ..., *thread_B, ...); // created in detached state pthread_create( ..., *thread_C, ...); // created in detached state }
First of all, I'm not sure where this "thread within thread" structure came from. Is this the way to do it or is this wrong and it just didn't break yet? A colleague thought this had something to do with setting up the kernel and idle tasks and all other threads should be created within Thread_A. Also does the same apply when switching from pthreads to tasks? Can you create tasks from within other tasks or does this mess up scheduling and debugging (i.e. execution analysis)?
Our tasks basically run forever. At startup it is determined in what mode the system is running and which tasks need to be executed. Can you "bundle" tasks in another task and start this one task depending on the state (similar to the code above)? Or do you start tasks hierarchically "flat" (from the main) and decide for each task if it needs to be started or not?
Sorry for the many questions, but I couldn't find an answer in the documentation or the forum.
Thanks and greetings,
Max