FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [May 2014 Threads] about Task and Classical FunctionPosted by fabrice48 on May 30, 2014 i began with freertos, and read two times the tutorial book, very nicely written and interessting.
i'm not sure about on thingn perhaps my question will be strange for RTOS Guru but i need to understand :
in freertos, all is a task.
But in 'C' language we have function.
in a CORRECT FREERTOS programm, is ALL a TASK or i can declare classical C function and call them from a TASK.
About function i mean a function without infinite loop, just a function who do something then terminate and return 'to the caller' here, a task for example ????
about Task and Classical FunctionPosted by davedoors on May 30, 2014 A function that implements a task can't return to its caller, because there is no caller. If you want to end a task you simply call vTaskDelete(NULL) at the end of the function.
But inside the task you can call normal C functions that return without any problems. Example
void vThisIsATask(void *px)
{
while(1)
{
// Normal C functions can be called here.
ThisIsACFunction();
ThisIsAnotherCFunction();
}
// Must not exit, but if you leave the while(1) you can delete the task
vTaskDelete(NULL);
}
about Task and Classical FunctionPosted by fabrice48 on May 30, 2014 ok, it's more clear for me,
can i ask you an advice :
in your experience end opinion how can i choose between a C function and a C function that is a task.
i mean what "kind" of code muste be on the one but never to the other ?
about Task and Classical FunctionPosted by richard_damon on May 30, 2014 A function that returns will never be a "task".
A function that never returns will rarely be anything but a task function.
A task will generally be in a loop, blocking on some resource, and when it get it, does some operation, and then normally go back and waits for the next request from that resource, or sometimes just terminating itself (if it was created as a "one shot" operation)
One the other hand, a function gets called, does something and then returns to the caller.
It is possible to fake something like a function with a task by sending it a request, and then immediately waiting for a reply. But this is generally inefficient.
Normally I create a task for each data stream from somewhere that needs to be processed, plus tasks for any periodic operations that might take some time to execute (quick periodic operations will become timer callbacks, that run as part of the time task).
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|