- This topic has 0 replies, 1 voice, and was last updated 1 month, 2 weeks ago by
Logan Moon.
-
AuthorPosts
-
February 6, 2025 at 10:23 pm #16820
(This message was transferred over from our old forum)
Posted August 19, 2015
By Todd DeBoer
[hr]
On 6/22/10 wella asked, “I need to re-flash LPC2478 device and I would like allocate a 4096B memory buffer from UEZMemAlloc(internal SRAM heap). However in the running system, there is no guarantee that some free space can be found. For this reason I would like to delete all tasks(their stacks) and message queues.Do you think this procedure is correct? I am using FreeRTOS as the underlying OS.
Thank you for your suggestions.
Martin
/*—————————————————————————*
* Routine: UEZStop
*—————————————————————————*
* Description:
* Stop all activity of UEZ, release memory used for tasks and queues.
*
* Outputs:
* None
*—————————————————————————*/
void UEZStop(void)
{
T_uezTask currentTask;uint32_t index;
T_uezError found;
typedef union
{
T_uezHandle taskHandle;
T_uezHandle queueHandle;
} HANDLE;HANDLE handle;
// Get current task ID to avoid self-kill.
currentTask = UEZTaskGetCurrent();// Find tasks, stop them and delete.
index = 0;
do
{
found = uEZHandleFindOfType(UEZ_HANDLE_TASK, &handle.taskHandle, &index);// Didn’t find task? Return 0
if (found != UEZ_ERROR_NONE)
{
break;
}if (handle.taskHandle == currentTask)
{
// Continue in searching task.
continue;
}
else
{
UEZTaskSuspend(handle.taskHandle);
UEZTaskDelete(handle.taskHandle);
// Give some time to delete task.
UEZTaskDelay(1);
}
} while (true);// Find queues and delete.
index = 0;
do
{
found = uEZHandleFindOfType(UEZ_HANDLE_QUEUE, &handle.queueHandle, &index);// Didn’t find task? Return 0
if (found != UEZ_ERROR_NONE)
{
break;
}// Delete queue
UEZQueueDelete(handle.queueHandle);
} while (true);return;
}”
[hr]
(Follow up post)Answered:
Wow, that’s a pretty extreme move. I suppose that would work. This almost seems more like something that should be handled at the application level than at the UEZ source code level, though. Also, this routine assumes that the current task does not have any queues, which may not be a proper assessment in all cases.
If handled at the application level, you might be able to carve out a more appropriate block of memory that isn’t as destructive to the whole system.
-
AuthorPosts
- You must be logged in to reply to this topic.