Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


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 ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner