f9 microkernel code reading part 2 scheduling
DESCRIPTION
Discuss scheduling which one of core function within F9 MicrokernelTRANSCRIPT
Part 2 : Code Reading of
F9 Microkernel
ben6 2013-‐11-‐18
Scheduling
Agenda
• Brief of F9 Microkernel Scheduling
• All about Algorithms
• Scheduling Code reading
F9
Agenda
• Brief of F9 Microkernel Scheduling
• All about Algorithms
• Scheduling Code reading
F9
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)
CharacterisMcs
• Energy efficient scheduling • Tickless Mmer
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/
Agenda
• Brief of F9 Microkernel Scheduling
• All about Algorithms
• Scheduling Code reading
F9
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.
Agenda
• Brief of F9 Microkernel Scheduling
• All about Algorithms
• Scheduling Code reading
F9
Scheduling related code
• ipc.c • kMmer.c • sched.c (most important) • so]irq.c • syscall.c • systhread.c • thread.c
KMmer_handler
Timer handler in ISR vector table
kMmer_handler Hardware interrupt
trigger ktmer_handler
Plaborm/irq.h: schedule_in_irq
Trigger point of scheduling which while
IRQ event occurs
include/plaborm/irq.h
IRQ_HANDLER
include/plaborm/irq.h
context_switch
include/plaborm/irq.h
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
Schedule handler
typedef tcb_t *(*sched_handler_t)(struct sched_slot *slot);
Select target thread
ss_handler is used while currnt slot thread is empty or
not runnable
thread_state_t
Only scheduling for T_RUNNABLE State
Thread control block
TCB using by schedule slots
__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
kMmer event scheduling
schedule_slot_set_handler
thread.c
Conclusion
• F9 Microkernel uses following concepts – Tickless Scheduling – Dynamic Timer To archive energy efficiency scheduling
Discussions
?
F9
Kernel line of code for reading
Kernel C code line: 2183 Git head: 4d87f204252d57525f9cd93f163ca5225cc34bb7
References • F9 Microkernel source code and introducMon
• hWps://github.com/southernbear/RIOT/wiki/Development
• TiROS for Mckless hWp://Mros.sourceforge.net/
• GCC Naked AWribute