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 2006 Threads] Unnatural task formPosted 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 formPosted 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 formPosted 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 formPosted 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 formPosted 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 formPosted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|