This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Scheduler / task behavior

Hey,

I`m evaluating the Industrial SDK for the AM335x. There is a smple, which I did not understand completly.

One taks is called every millisecond, a second one is called after this. So task1 is executed every ms and task2 after task1, but not after every call of task1.

this is what the task 2 does:

while (1)
   {
      unsigned int curr_port0_activity, curr_port1_activity;
      static unsigned int prev_port0_activity = 0, prev_port1_activity = 0;
      Task_sleep(25 * OS_TICKS_IN_MILLI_SEC);
      curr_port0_activity = bsp_read_dword(ESC_ADDR_TI_PORT0_ACTIVITY);
      curr_port1_activity = bsp_read_dword(ESC_ADDR_TI_PORT1_ACTIVITY);
      if (prev_port0_activity != curr_port0_activity)
      {
         set_act0_led();
      }
      if (prev_port1_activity != curr_port1_activity)
      {
         set_act1_led();
      }

      Task_sleep(100 * OS_TICKS_IN_MILLI_SEC);

      reset_act0_led();
      reset_act1_led();

      prev_port0_activity = curr_port0_activity;
      prev_port1_activity = curr_port1_activity;

#if ESC_EEPROM_EMULATION
      if (bsp_get_eeprom_update_status())
      {
         bsp_set_eeprom_update_status(0);
         bsp_eeprom_emulation_flush();
      }
#endif

   }

so, task2 is sleeping sometimes very long, I want to know if the scheduler do not call a task if it is sleeping? And why does he know that?

Or is there maybee something other like semaphore (I dont know if)?

hope you understand what I want to know.

Thanks for your help.

  • Michael,

    yes, the task2  is just driving the activity LEDs as it's main functions. As the blinks should be visible it is relatively slow.

    A sleeping task is not called. The OS scheduler has a tick timer to maintain the sleep time. You might refer to Sys/Bios 6 docs for more details.

    However the whole think is just an example of how to use the EtherCAT firmware with a stack (in this case Beckhoff SSC) and an application. There are many ways to implement certain features and with a different stack there will be different solutions anyway. You may also port the drivers for a different RTOS if needed...

    Regards.

  • Thank you. That a sleeping task is not called was exactly what I wanted to know.