Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

F9 Microkernel code reading part 2 scheduling


Published on

Discuss scheduling which one of core function within F9 Microkernel

Published in: Technology, Education
  • Be the first to comment

F9 Microkernel code reading part 2 scheduling

  1. 1. Part  2  :  Code  Reading   of   F9  Microkernel   Scheduling   ben6   2013-­‐11-­‐18  
  2. 2. F9   Agenda   •  Brief  of  F9  Microkernel  Scheduling   •  All  about  Algorithms   •  Scheduling  Code  reading  
  3. 3. F9   Agenda   •  Brief  of  F9  Microkernel  Scheduling   •  All  about  Algorithms   •  Scheduling  Code  reading  
  4. 4. F9  Microkernel  Overview   •  an  experimental  microkernel  used  to  construct   flexible  embedded  systems  inspired  by  famous  L4   microkernel.     •  The  moMvaMon  of  F9  microkernel  is  to  deploy   modern  kernel  techniques  to  support     –  running  real-­‐Mme  and  Mme-­‐sharing  applicaMons  (ex:     wireless  communicaMons)  for  ARM  Cortex-­‐M  series   microprocessors  with  efficiency  (performance  +   power  consumpMon)     –  security  (memory  protecMon  +  isolated  execuMon)  
  5. 5. CharacterisMcs   •  Energy  efficient  scheduling   •  Tickless  Mmer  
  6. 6. Mckless  scheduler   •  F9  implements  a  Mckless  scheduler  which  implies   the  dynamic  Mmer.   •  You  can  track  the  development  here:     hWps:// Development   •  F9  follows  some  concepts  about  TiROS  for   Mckless:          hWp://
  7. 7. F9   Agenda   •  Brief  of  F9  Microkernel  Scheduling   •  All  about  Algorithms   •  Scheduling  Code  reading  
  8. 8. Tickless  Scheduling •  Reference  concept  of  TiROS   •  TiROS  avoids  most  context-­‐switching   overhead  costs  by  eliminaMng  periodic  Mcks.   •  Most  embedded  real-­‐Mme  OSes,  a  trade  off   between  high  Mme-­‐resoluMon  (by  increasing   Mck  frequency)  and  overhead.   •  TiROS  does  not  use  Mcks  and  achieves  high-­‐ Mme  resoluMon  with  very  low  overhead.
  9. 9. F9   Agenda   •  Brief  of  F9  Microkernel  Scheduling   •  All  about  Algorithms   •  Scheduling  Code  reading  
  10. 10. Scheduling  related  code   •  •  •  •  •  •  •  ipc.c   kMmer.c   sched.c          (most  important)   so]irq.c   syscall.c   systhread.c   thread.c  
  11. 11. KMmer_handler   Timer  handler  in  ISR   vector  table  
  12. 12. kMmer_handler   Hardware  interrupt   trigger  ktmer_handler  
  13. 13. Plaborm/irq.h:  schedule_in_irq   Trigger  point  of   scheduling  which  while   IRQ  event  occurs   include/plaborm/irq.h  
  14. 14. IRQ_HANDLER   include/plaborm/irq.h  
  15. 15. context_switch   include/plaborm/irq.h  
  16. 16. Scheduler  slots •  sched.h sched.h    26  typedef  struct  sched_slot  {    27          tcb_t  *ss_scheduled;    28          sched_handler_t  ss_handler;    29  }  sched_slot_t;   sched_slot_t   ss_scheduled   ss_handler Priority  in  order  
  17. 17. Schedule  handler   typedef  tcb_t  *(*sched_handler_t)(struct  sched_slot  *slot);  
  18. 18. Select  target  thread   ss_handler  is  used   while  currnt  slot   thread  is  empty  or   not  runnable  
  19. 19. thread_state_t   Only  scheduling  for  T_RUNNABLE  State  
  20. 20. Thread  control  block   TCB  using  by  schedule  slots  
  21. 21. __NAKED   •  __aWribute__((naked))   Using  While  IRQ  funcMon   Use  this  aWribute  on  the  ARM,  AVR,  MCORE,  MSP430,  NDS32,  RL78,  RX  and  SPU   ports  to  indicate  that  the  specified  funcMon  does  not  need  prologue/epilogue   sequences  generated  by  the  compiler.       It  is  up  to  the  programmer  to  provide  these  sequences.       The  only  statements  that  can  be  safely  included  in  naked  funcMons  are  asm   statements  that  do  not  have  operands.       All  other  statements,  including  declaraMons  of  local  variables,  if  statements,  and  so   forth,  should  be  avoided.  Naked  funcMons  should  be  used  to  implement  the  body  of   an  assembly  funcMon,  while  allowing  the  compiler  to  construct  the  requisite   funcMon  declaraMon  for  the  assembler.    
  22. 22. kMmer  event  scheduling  
  23. 23. schedule_slot_set_handler  
  24. 24. thread.c  
  25. 25. Conclusion   •  F9  Microkernel  uses  following  concepts   –  Tickless  Scheduling   –  Dynamic  Timer   To  archive  energy  efficiency  scheduling  
  26. 26. Discussions   F9   ?  
  27. 27. Kernel  line  of  code  for  reading   Kernel  C  code  line:  2183   Git  head:  4d87f204252d57525f9cd93f163ca5225cc34bb7  
  28. 28. References   •  F9  Microkernel  source  code  and  introducMon   •  hWps://   •  TiROS  for  Mckless  hWp://   •  GCC  Naked  AWribute