part2 :%code%readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 ·...
TRANSCRIPT
![Page 1: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/1.jpg)
Part 2 : Code Reading of
F9 Microkernel
ben6 2013-‐11-‐18
Scheduling
![Page 2: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/2.jpg)
Agenda
• Brief of F9 Microkernel Scheduling
• All about Algorithms
• Scheduling Code reading
F9
![Page 3: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/3.jpg)
Agenda
• Brief of F9 Microkernel Scheduling
• All about Algorithms
• Scheduling Code reading
F9
![Page 4: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/4.jpg)
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)
![Page 5: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/5.jpg)
CharacterisMcs
• Energy efficient scheduling • Tickless Mmer
![Page 6: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/6.jpg)
Mckless scheduler • F9 implements a Mckless scheduler which implies the dynamic Mmer.
• You can track the development here: hWps://github.com/southernbear/RIOT/wiki/Development
• F9 follows some concepts about TiROS for Mckless:
hWp://Mros.sourceforge.net/
![Page 7: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/7.jpg)
Agenda
• Brief of F9 Microkernel Scheduling
• All about Algorithms
• Scheduling Code reading
F9
![Page 8: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/8.jpg)
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.
![Page 9: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/9.jpg)
Agenda
• Brief of F9 Microkernel Scheduling
• All about Algorithms
• Scheduling Code reading
F9
![Page 10: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/10.jpg)
Scheduling related code
• ipc.c • kMmer.c • sched.c (most important) • so]irq.c • syscall.c • systhread.c • thread.c
![Page 11: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/11.jpg)
KMmer_handler
Timer handler in ISR vector table
![Page 12: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/12.jpg)
kMmer_handler Hardware interrupt
trigger ktmer_handler
![Page 13: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/13.jpg)
Plaborm/irq.h: schedule_in_irq
Trigger point of scheduling which while
IRQ event occurs
include/plaborm/irq.h
![Page 14: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/14.jpg)
IRQ_HANDLER
include/plaborm/irq.h
![Page 15: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/15.jpg)
context_switch
include/plaborm/irq.h
![Page 16: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/16.jpg)
Scheduler slots • sched.h
ss_scheduled ss_handler
sched_slot_t
26 typedef struct sched_slot { 27 tcb_t *ss_scheduled; 28 sched_handler_t ss_handler; 29 } sched_slot_t;
sched.h
Priority in order
![Page 17: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/17.jpg)
Schedule handler
typedef tcb_t *(*sched_handler_t)(struct sched_slot *slot);
![Page 18: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/18.jpg)
Select target thread
ss_handler is used while currnt slot thread is empty or
not runnable
![Page 19: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/19.jpg)
thread_state_t
Only scheduling for T_RUNNABLE State
![Page 20: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/20.jpg)
Thread control block
TCB using by schedule slots
![Page 21: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/21.jpg)
__NAKED
• __aWribute__((naked)) 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.
Using While IRQ funcMon
![Page 22: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/22.jpg)
kMmer event scheduling
![Page 23: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/23.jpg)
schedule_slot_set_handler
![Page 24: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/24.jpg)
thread.c
![Page 25: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/25.jpg)
Conclusion
• F9 Microkernel uses following concepts – Tickless Scheduling – Dynamic Timer To archive energy efficiency scheduling
![Page 26: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/26.jpg)
Discussions
?
F9
![Page 27: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/27.jpg)
Kernel line of code for reading
Kernel C code line: 2183 Git head: 4d87f204252d57525f9cd93f163ca5225cc34bb7
![Page 28: Part2 :%Code%Readingcaxapa.ru/thumbs/865208/docslide.__f9-microkernel-code... · 2020-02-17 · __NAKED! • __aribute__((naked))! Use!this!aribute!on!the!ARM,!AVR,!MCORE,!MSP430,!NDS32,!RL78,!RXand!SPU!](https://reader034.vdocuments.mx/reader034/viewer/2022042218/5ec34221bfd5783ac71c3a97/html5/thumbnails/28.jpg)
References • F9 Microkernel source code and introducMon
• hWps://github.com/southernbear/RIOT/wiki/Development
• TiROS for Mckless hWp://Mros.sourceforge.net/
• GCC Naked AWribute