Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

about Task and Classical Function

Posted 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 Function

Posted 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 Function

Posted 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 Function

Posted 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).


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists