how to destroy only one task

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to destroy only one task

911 Views
sudhakarp
Contributor V

hi..

now i am working on frdmk64 controller. actually i edited hello example project. in this project i created 3 task but i want to destroy one task after some time but its destroyed all task. i attached my code also.

 

sample code:

const TASK_TEMPLATE_STRUCT  MQX_template_list[] =

{

   /* Task Index,   Function,   Stack,  Priority, Name,     Attributes,          Param, Time Slice */

    { WORLD_TASK,   world_task, 700,   8,        "world",  MQX_AUTO_START_TASK, 0,     0 },

    { HELLO_TASK,   hello_task, 700,   9,        "hello",  MQX_AUTO_START_TASK, 0,     0 },

    { TEST_TASK,  test_task, 700,   10,        "test",  0, 0,     0 },

    { 0 }

};

 

 

test_tid = _task_create(0, TEST_TASK, (uint32_t) &task_p);

                if (test_tid == MQX_NULL_TASK_ID)

                 {

                      fprintf(stderr, "Fatal Error 0x%X: Unable to create test  task.", _task_get_error());

                   _task_block();

                  }

i=10;

while(1)

    {

        printf("Enter\n",i);

      

                printf("world=%d\n",i);

              

                 if(i==15)

                 {

                    _task_destroy(test_tid);

                     printf("test destroyed",i);                  

                 }

                i++;

            _time_delay(3000);

 

    }

 

my problem was its blocking WORLD_TASK and also HELLO_TASK. so how to solve this problem.

 

Original Attachment has been moved to: hello_pro.zip

0 Kudos
3 Replies

593 Views
soledad
NXP Employee
NXP Employee

Hello,

Please check the below threads and let me know if this helps!!!

Task managment - Kill various tasks

_task_abort get stuck


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

593 Views
sudhakarp
Contributor V

dear soledad,

          if i use _task_abort or _task_destroy API function all  the task are blocked. why this thing happening..? actually i used " _task_abort(test_tid);" so "test_tid " task should stop, remaining task should be run. but its blocked all task. how to avoid this problem..? give some explanation

0 Kudos

593 Views
soledad
NXP Employee
NXP Employee

Hello,

Please check the below thread and let me know if this helps

_task_abort get stuck


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos