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

Unnatural task form

Posted by Nobody/Anonymous on May 15, 2006
Hi, I think that endless-loop form of task function is somewhat weird.

Why not automatically put NULL and pointer to vTaskDelete on the stack of newly created task?

This way you get plain and simple void function as task code which may end-by-return...

Regards

RE: Unnatural task form

Posted by Nobody/Anonymous on May 15, 2006
Most tasks are implemented as an endless loop. If you want the task to run just once, then probably not a good candidate for a task. If you want the task to delete, just place vTaskDelete(NULL) at the end of the function and you have not wasted any stack.

RE: Unnatural task form

Posted by Nobody/Anonymous on May 15, 2006
Well, I will defend my point of view:

I didn't mean to run task once. It is just more portable and safe (what happens now if u return from task?) to have the task cleaned up automatically. The four bytes (AVR) of data (16b NULL + pointer to vTaskDelete) is not much for ability to just "return" from task.

Maybe FreeRTOS author will answer this from professional's point of view.

RE: Unnatural task form

Posted by Nobody/Anonymous on May 15, 2006
If this forum was like some of the others, you'd get rained on now. The endless loop task structure is the way it is done in most if not all multitasking environments. Certainly all I have ever seen. It is just as "safe" as any other form. Just follow the rules. The rest of us don't want the added overhead of support for those who don't want to do it the way the documentation says it should be done. If I were Richard, I wouldn't waste my time arguing with you about this.

RE: Unnatural task form

Posted by Richard on May 15, 2006
Hmm, I don't want to sit on the fence too much, but I don't really see it as a big issue. It is just an implementation choice.

Placing a jump to a delete function on the return stack is valid and neat, but does require more stack (albeit a few bytes, remember FreeRTOS runs on some tiny processors). I don't see how this gets around having most tasks as an infinite loop however.

The current implementation will allow users to crash the code by running off the bottom of a task. Doing so would show a lack of understanding of the system they were programming so I doubt this would be their only problem ;-) There are lots of ways you can cause a crash, and as a small fast implementation FreeRTOS does not try to guard against them all. Placing a vTaskDelete call outside of the loop is not a big issue, and more explicit of how you intend the task to function.

So I don't have strong feelings either way. FreeRTOS provides all the source code so you can make your application function however you wish by editing if you so desire.

Regards.


RE: Unnatural task form

Posted by John W. on May 15, 2006
I think I'm repeating here - but it seems that the functionality of what 'nobody' wants is already in FreeRTOS. vTaskDelete() gives the ability asked for.

As Richard has stated - the source code is there. In port.c - you can make the stack behave any way you want. There are issues of both compiler (tool-sets) and the target MCU. It doesn't seem to be a very portable approach IMHO, but the source is there for you to modify as you wish.

As FreeRTOS runs on a lot of RAM constrained systems - I think (IMHO) that leaving the stack alone is the way to go vs. adding more args on the stack.

Just my 2 cents,
John W.


[ 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