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] [June 2012 Threads] Get task running in error trap and terminatePosted by https://www.google.com/accounts on June 10, 2012 My dsPIC processor supports error trap interrupts such as divide by zero, memory access violation, etc. If one of these occurs then it is likely the task currently running has caused it. I would like to avoid a complete processor reset and just end the appropriate task. So, I will need to get the task pointer of the currently running task and terminate it. So, the code would look something like this: void div_zero_exception() { xTaskHandle tp = xTaskGetCurrentTaskHandle(); _debug_msg("[****] Task terminated: %s due to zero division", pcTaskGetTaskName(tp)); vTaskSuspend(tp); }
This will run from the task that is being terminated - would this cause any problems? This also only suspends the task - ideally, it would be completely terminated and all memory related to the task would be freed.
RE: Get task running in error trap and terminatePosted by Richard Damon on June 11, 2012 One concern I would have is that you don't know for sure that the exception is coming from a task, it could also be coming from an interrupt handler. You also need to be careful about is killing a task at an unknown point, as you have no Idea on the status of the resources it uses.
I would also be very nervous about using a "printf" like function at the exception level. Note that in the exception handler, ALL interrupts are disabled.
RE: Get task running in error trap and terminatePosted by Richard on June 11, 2012 As per richard_damon's reply, plus:
In this case, the exception is equivalent to an interrupt, so only FreeRTOS API functions that end if "FromISR" should be called. I can't remember the exact details of the PIC24 port, so you might get away with it, but keep in mind that you will be using the API outside of its intended scope.
Suspending the currently executing task will probably result in a reschedule, so your exception may never be concluded correctly (you may never clear the exception if another task starts running, and the stacks might be left in an inconsistent state). You also have to consider how you are going to exit from the exception, if you have deleted or suspended the task that caused the exception does not cause another task to execute - what are you going to return to?
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|