F9 Microkernel code reading part 2 scheduling
-
Upload
benux-wei -
Category
Technology
-
view
1.968 -
download
16
description
Transcript of F9 Microkernel code reading part 2 scheduling
![Page 1: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/1.jpg)
Part 2 : Code Reading of
F9 Microkernel
ben6 2013-‐11-‐18
Scheduling
![Page 2: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/2.jpg)
Agenda
• Brief of F9 Microkernel Scheduling
• All about Algorithms
• Scheduling Code reading
F9
![Page 3: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/3.jpg)
Agenda
• Brief of F9 Microkernel Scheduling
• All about Algorithms
• Scheduling Code reading
F9
![Page 4: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/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: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/5.jpg)
CharacterisMcs
• Energy efficient scheduling • Tickless Mmer
![Page 6: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/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: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/7.jpg)
Agenda
• Brief of F9 Microkernel Scheduling
• All about Algorithms
• Scheduling Code reading
F9
![Page 8: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/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: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/9.jpg)
Agenda
• Brief of F9 Microkernel Scheduling
• All about Algorithms
• Scheduling Code reading
F9
![Page 10: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/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: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/11.jpg)
KMmer_handler
Timer handler in ISR vector table
![Page 12: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/12.jpg)
kMmer_handler Hardware interrupt
trigger ktmer_handler
![Page 13: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/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: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/14.jpg)
IRQ_HANDLER
include/plaborm/irq.h
![Page 15: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/15.jpg)
context_switch
include/plaborm/irq.h
![Page 16: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/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: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/17.jpg)
Schedule handler
typedef tcb_t *(*sched_handler_t)(struct sched_slot *slot);
![Page 18: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/18.jpg)
Select target thread
ss_handler is used while currnt slot thread is empty or
not runnable
![Page 19: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/19.jpg)
thread_state_t
Only scheduling for T_RUNNABLE State
![Page 20: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/20.jpg)
Thread control block
TCB using by schedule slots
![Page 21: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/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: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/22.jpg)
kMmer event scheduling
![Page 23: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/23.jpg)
schedule_slot_set_handler
![Page 24: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/24.jpg)
thread.c
![Page 25: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/25.jpg)
Conclusion
• F9 Microkernel uses following concepts – Tickless Scheduling – Dynamic Timer To archive energy efficiency scheduling
![Page 26: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/26.jpg)
Discussions
?
F9
![Page 27: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/html5/thumbnails/27.jpg)
Kernel line of code for reading
Kernel C code line: 2183 Git head: 4d87f204252d57525f9cd93f163ca5225cc34bb7
![Page 28: F9 Microkernel code reading part 2 scheduling](https://reader035.fdocuments.in/reader035/viewer/2022081720/5577b511d8b42a1c068b4668/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