We've got a task (MQX for KSDK 1.2) that stops executing, and we have yet to figure out why. It only occurs one in a blue moon, so it is hard to solve. The current solution is to use _task_set_exit_handler and _task_set_exception_handler to trap the MQX task error number, if any. Hopefully, this will give us more information about what's going wrong.
However, at the moment I'm not able to get _task_set_exit_handler to work. I've implemented like this in os_tasks.cpp:
TASK_EXIT_FPTR _task_set_exit_handler( _task_id id, TASK_EXIT_FPTR f)
{
// get info for the active task when this handler is called
_task_id active_task_id = _task_get_id();
_mqx_uint active_task_error = _task_get_error();
// don't really need this since we already have the error code
TD_STRUCT_PTR ptd_active = (TD_STRUCT_PTR)_task_get_td( active_task_error);
// now get info for the ID that was passed in -- I suppose this is for the failed task...
TD_STRUCT_PTR ptd_passed = (TD_STRUCT_PTR)_task_get_td( id);
_mqx_uint passed_task_error = ptd_passed->TASK_ERROR_CODE;
return NULL;
}
Here I'm basically checking the active task at the time the exiting task exits to see if they are the same. I then get the error code from each one, also for the purpose of comparison.
The problem I have is that when this code is executed with a breakpoint set (or if a breakpoint is added after execution), the debugger crashes:
This behavior is consistent with the known behavior where GDB crashes if a breakpoint is set in code that never gets called by the application. This implies that I'm not setting something up properly, but I do have the preprocessor setting "MQX_EXIT_ENABLED=1" in my project settings.
Has anyone else tried to use these functions and have gotten them to work?
Hi Dave:
Do you use MQX4.2 or MQX for KSDK1.3?
Regards
Daniel
Ah, sorry for missing that level of detail! MQX for KSDK 1.2.
Hi Dave:
I did a quick check with TWR-K65F180M and KSDK1.2.
I enabled MQX_EXIT_ENABLED in user_config.h , add add _mqx_exit(1) in hello task.
My observation is , when _mqx_exit is executed, I can see system jump to _bsp_exit_handler successfully. It is a correct result because in init_bsp.c. the exit handler is set.
#if MQX_EXIT_ENABLED
extern void _bsp_exit_handler(void);
/* Set the bsp exit handler, called by _mqx_exit */
_mqx_set_exit_handler(_bsp_exit_handler);
#endif
Regards
Daniel
Hi Daniel, I do not think what you have posted is what I am looking for. I'm curious to determine why a specific task has stopped executing, not that the OS itself has stopped running.