AnsweredAssumed Answered

Scheduling question for MQX

Question asked by Dongsheng Wang on Dec 2, 2014
Latest reply on Dec 2, 2014 by soledad

I tested the following project in FRDM-k64F.

 

 

/* MQX task IDs */

#define KTEST1_TASK          1U

#define CANADA_TASK          2U

#define WORLD_TASK           3U

 

 

/* MQX task stack sizes */

#define KTEST1_TASK_STACK_SIZE 1024

 

 

const TASK_TEMPLATE_STRUCT MQX_template_list[] =

{

  /* Task: Ktest1 */

  {

    /* Task number                    */  KTEST1_TASK,

    /* Entry point                    */  (TASK_FPTR)Ktest1_task,

    /* Stack size                     */  KTEST1_TASK_STACK_SIZE,

    /* Task priority                  */  8U,

    /* Task name                      */  "ktest1",

    /* Task attributes                */  (MQX_AUTO_START_TASK),

    /* Task parameter                 */  (uint32_t)(0),

    /* Task time slice                */  (uint32_t)(0)

  },     

  /* Task: CANADA */

  {

    /* Task number                    */  CANADA_TASK,

    /* Entry point                    */  (TASK_FPTR)Canada_task,

    /* Stack size                     */  KTEST1_TASK_STACK_SIZE,

    /* Task priority                  */  8U,

    /* Task name                      */  "Canada",

    /* Task attributes                */  (MQX_TIME_SLICE_TASK),

    /* Task parameter                 */  (uint32_t)(0),

    /* Task time slice                */  (uint32_t)(100)

  },

  /* Task: WORLD */

  {

    /* Task number                    */  WORLD_TASK,

    /* Entry point                    */  (TASK_FPTR)World_task,

    /* Stack size                     */  KTEST1_TASK_STACK_SIZE,

    /* Task priority                  */  8U,

    /* Task name                      */  "World",

    /* Task attributes                */  (MQX_TIME_SLICE_TASK),

    /* Task parameter                 */  (uint32_t)(0),

    /* Task time slice                */  (uint32_t)(100)

  },

  TASK_TEMPLATE_LIST_END

};

 

 

 

void Ktest1_task(uint32_t task_init_data)

{

  _task_id ktest1child;

 

 

 

 

  ktest1child = _task_create(0, CANADA_TASK, 0);

  if(ktest1child==MQX_NULL_TASK_ID)

  {

  printf("\nFailed to create task Canada\n");

  }

  else

  printf("\nSuccess to create task Canada\n");

 

 

  ktest1child = _task_create(0, WORLD_TASK, 0);

  if(ktest1child==MQX_NULL_TASK_ID)

  printf("\nfailed to create task World\n");

  else

  printf("\nsuccess to create task World\n");

 

 

  _task_block();

}

 

 

void Canada_task(uint32_t task_init_data)

{

  int counter = 0;

 

 

  printf("\nHellow Canada\n");

  while(1) {

    counter++;

    /* Write your code here ... */

 

 

  }

}

 

 

void World_task(uint32_t task_init_data)

{

  int counter = 0;

 

 

  printf("\nHellow World\n");

  while(1) {

    counter++;

    /* Write your code here ... */

 

 

  }

}

 

When I run this project, the status of task ktest1 is blocked. the status of _mqx_init_task is terminating. the status of task Canada is always active, and the status of task World is always ready, even I set the Canada_task as MQX_TIME_SLICE_TASK. It still looks like FIFO Scheduling.

Outcomes