Asset Tracker Thread working

In asset_tracker sample program, the general thread program has following structure:

static bool xyz_event_handler(const struct app_event_header *eh)

{

// subscribed events handling here 

}

static void module_thread_fn(void)
-- define variables
 self.thread_id = k_current_get();

  err = module_start(&self);
  if (err)
  {
    LOG_ERR("Failed starting module, error: %d", err);
    SEND_ERROR(xyz, XYZ_DATA_ERROR, err);
  }
   while(1)
   {
     module_get_next_msg(&self,msg);
       switch(state)
       {
        case(a):{break;}
        case(b):{break;}
        case(c):{break;}
       }
   }
}
K_THREAD_DEFINE(xyz_module_thread, CONFIG_XYZ_THREAD_STACK_SIZE,  module_thread_fn, NULL, NULL, NULL,   K_LOWEST_APPLICATION_THREAD_PRIO, 0, 0);
//*******************************************************************
APP_EVENT_LISTENER(MODULE, xyz_event_handler);
APP_EVENT_SUBSCRIBE(MODULE, app_module_event);
APP_EVENT_SUBSCRIBE(MODULE, abc_module_event);
APP_EVENT_SUBSCRIBE(MODULE, data_module_event);
//*************
whenever any of the events subscribed events is detected, the thread executes the xyz_event_handler().
In this structure, my query is related to infinite while loop:
As the thread is allotted some execution time by the scheduler of kernel, is the code inside while(1) and switch() always executed in allotted time slot to thread by the kernel or is it also related to some events internally by scheduler ?
if yes, then, as system flows from state a -> b -> c, then, the code inside case c also, will be executed evertime in each thread slot as long state is c.  
Parents Reply Children
No Data
Related