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 2008 Threads] How to restart the taskPosted by kuoping hsu on May 10, 2008 I want to restart a task, but I do not find any of direct way to do it. Currently, I delete the task and re-create it again to restart the task. It will release the memory of stack, and allocate another memory space as stack. If I restart the task several times, it has a risky to cause memory fragmentation. How should I do to restart a task?
RE: How to restart the taskPosted by Dave on May 10, 2008 If (you are using heap_2) && (the stack size allocated to the task is always the same) && (you are not dynamically creating and deleting any other objects (queues for example)) then you should not suffer from fragmentation as the same memory block will just get reused. This is easy enough to test.
RE: How to restart the taskPosted by kuoping hsu on May 11, 2008 Unfortunately, I use malloc function call (Newlib C library) to allocate memory instead of heap_2, and the other task may dynamically allocate memory when the task is restarted. I am not sure the impact of memory fragmentation on the more complicate application, so I need more safe mechanism to restart the task. Actually, I want to implement the plug-ins function in my system. It will stop the task of plug-ins, load the other code to the memory, and restart the task again to run the code of plug-ins. Maybe I can suspend the task and modify the content of TCB or whatever, and resume the task. But, dose exist any simple & portable way to do that?
RE: How to restart the taskPosted by Christopher Coley on May 11, 2008 Why not just modify the code in the task so you can set a flag or send a message to it to cause it to restart. e.g.
boolean fMyTask_Restart;
void MyTask (void *pvParameters) { for (;;) { fMyTask_Restart = FALSE;
/* Any other task initialization here */
while (!fMyTask_Restart) {
/* You main task code here */
} } }
Now any time you want to restart the task just set fMyTask_Restart to TRUE. You can also check the flag to make sure the restart occurred.
Chris
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|