Hi MQX, its in the MQXRM.pdf under _task_abort(); however, it is not complete... Page 350 for the 3.4 release.
Here is a much simpler example I just wrote up which does NOT call the exit hanlder. The TAD does say the task is terminating, but thats all....
PS: I tested the below example using _task_destroy instead of _task_abort and the task is destroyed based on TAD. But this is no good as it cannot fclose everything and clearn up other special functions..
/**HEADER********************************************************************
*
* Copyright (c) 2008 Freescale Semiconductor;
* All Rights Reserved
*
* Copyright (c) 1989-2008 ARC International;
* All Rights Reserved
*
***************************************************************************
*
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************
*
* $FileName:
* $Version :
* $Date :
*
* Comments:
*
* Test task_abort, start a task, then abort it
*END************************************************************************/
#include <mqx.h>
#include <bsp.h>
#include <fio.h>
#if ! BSPCFG_ENABLE_IO_SUBSYSTEM
#error This application requires BSPCFG_ENABLE_IO_SUBSYSTEM defined non-zero in user_config.h. Please recompile BSP with this option.
#endif
#ifndef BSP_DEFAULT_IO_CHANNEL_DEFINED
#error This application requires BSP_DEFAULT_IO_CHANNEL to be not NULL. Please set corresponding BSPCFG_ENABLE_TTYx to non-zero in user_config.h and recompile BSP with this option.
#endif
//Main task
void main_task(uint_32);
//Task 2
void task2(uint_32);
//Exit handlers for tasks
void task2_exit_handler(void);
TASK_TEMPLATE_STRUCT MQX_template_list[] =
{
{5, main_task, 1500, 6, "main_task", MQX_AUTO_START_TASK, 0, 0},
{6, task2, 1500, 6, "task2", 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
};
/*TASK*-----------------------------------------------------
*
* Task Name : hello_task
* Comments :
* This task prints " Hello World "
*
*END*-----------------------------------------------------*/
void main_task (uint_32 initial_data)
{
_task_id task2_id_;
printf("main_task: creating task2\n");
task2_id_ = _task_create(0 , 6, 0);
//Wait for 2 seconds before killing task2
_time_delay(2000);
printf("main_task: aborting task2\n");
_task_abort(task2_id_);
printf("Waiting for tasks to abort\n"); //TASKS STOP, BUT THE EXIT HANDER NEVER RUNS
_time_delay(5000);
printf("MQX Will now exit\n");
_mqx_exit(0);
}
void task2(uint_32)
{
_task_set_exit_handler(_task_get_id(), task2_exit_handler);
printf("Task 2: Starting task2\n");
for(;;) _time_delay(0100);
}
//Looks after closing up resources for task2
void task2_exit_handler(void)
{
printf("****Task2 exit handler!****\n");
fflush(stdout);
}
Here is stdout log, its clear to see the exit handler does not work:
main_task: creating task2
Task 2: Starting task2
main_task: aborting task2
Waiting for tasks to abort
MQX Will now exit
Message Edited by CarlFST60L on 2009-10-27 12:12 AM
Message Edited by CarlFST60L on 2009-10-27 12:12 AM
Message Edited by CarlFST60L on 2009-10-27 12:20 AM