while (1) loop in the main function vs. FreeRTOS

tahirnaseer wrote on Tuesday, November 11, 2014:

Hi,

I am trying to implement FreeRTOS on controller with specific API calls. In the bare controller example, there are a few commands which are used at the beginning and end of while(1) loop in main as follows:

void main (void)
{

while(1)
command1();

/*
your application code here
*/

command2();

}

It is mandatory to used command1 and command2. Where in FreeRTOS should I write calls to command1 and command2 functions?
}

rtel wrote on Tuesday, November 11, 2014:

I’m not sure I understand your question. Let me state it back to see if I have it right.

Currently you have a non-RTOS application that is structured as follows:

while( 1 )
{
    /* Must be called before application code. */
    command1();

    /* Application code goes here. */


    /* Must be called after application code. */
    command2();
}

now you want to implement the same thing but using the RTOS.

If so then the first thing to say is you could just create that function as a task and have it run. If it does not block and you have other tasks running it would have to be a low priority though.

Other than that any answer would depend on the what command1() and command2() were, what is their purpose, what are their processing requirements, and what relation (if any) do they have to the application code.

For example, does command2() use a value calculated by the application code, in which case it must be executed exactly once after each execution of the application code.

Or alternatively is command2() completely unrelated to the application code but needs to be called either periodically or as fast as possible.

Regards.