SlideShare ist ein Scribd-Unternehmen logo
1 von 45
Downloaden Sie, um offline zu lesen
Your Logo Here

Viller Hsiao <villerhsiao@gmail.com>

F9 Microkernel ktimer
Rights to Copy

LOGO

copyright © 2014 Viller Hsiao

Attribution – ShareAlike 3.0
You are free
●

to copy, distribute, display, and perform the work

●

to make derivative works

●

Corrections, suggestions,
contributions and
translations are welcome!

to make commercial use of the work

Under the following conditions
Attribution. You must give the original author credit.
– Share Alike. If you alter, transform, or build upon this work, you may
distribute the resulting work only under a license identical to this one.
For any reuse or distribution, you must make clear to others the
license terms of this work.
–

●

Any of these conditions can be waived if you get permission from the copyright holder.

Your fair use and other rights are in no way affected by the above.
License text: http://creativecommons.org/licenses/by-sa/3.0/legalcode

Place, 04/02/14

villerhsiao
F9 Microkernel [1]
●

New open source implementation built from scratch, which deploys
modern kernel techniques, derived from L4 microkernel designs, to
deep embedded devices.
●

●

BSD License

Characteristics of F9 microkernel
●

Efficiency: performance + power consumption
–

Tickless

●

Security: memory protection + isolated execution

●

●

LOGO

Flexible development environment

Repository
●

https://github.com/f9micro

Place, 04/02/14

villerhsiao
Agenda

●

●

LOGO

Concept about operating system kernel
time subsystem
F9 Microkernel ktimer introduction

Place, 04/02/14

villerhsiao
LOGO

Concept about Operating System Kernel
Time Subsystem

Place, 04/02/14

villerhsiao
OS Kernel Time Subsystem

●

Current Time
●

System time, UTC/GMP time, … etc

●

Alarm, the time event

●

Process timeslice

●

Timeout

●

Time delay

Place, 04/02/14

villerhsiao

LOGO
System Time and Tick

●

LOGO

From Wikipedia [2],
“System time represents a computer system's notion of
the passing of time.“
“System time is measured by a system clock, which is
typically implemented as a simple count of the number
of ticks that have transpired since some arbitrary
starting date, called the epoch.”

Place, 04/02/14

villerhsiao
How Is Tick Implemented?
●

LOGO

Hardware timer device
●

Assert interrupt after a programmable inteval
–

Handling tick stuff in Timeout Interrupt Service
Routine (ISR)

HW
Timer

CPU
Adjust system time
Handle timeout event
….

Timeout interrupt

Control
Read Counts
Setup timeout value

Place, 04/02/14

villerhsiao
How Is Tick Implemented? (Cont.)
●

Type 1: Incremental timer
●

Example: Cortex-A9 MP Global Timer

Place, 04/02/14

villerhsiao

LOGO
How Is Tick Implemented? (Cont.)
●

LOGO

Incremental timer functionality

1

Current Value

+

0x12abc
=

Incremental value
0x36000

Compare Value

+

0x36000

Y

Place, 04/02/14

Y

Auto
Increament?
villerhsiao

Interrupt
How Is Tick Implemented? (Cont.)
●

Type 2: Counting down timer
●

Example: Cortex-M4 SysTick

Place, 04/02/14

villerhsiao

LOGO
How Is Tick Implemented? (Cont.)
●

LOGO

Counting down timer functionality
0

=

1

-

Reload value

=

0x36000

Current Value
0x12abc

Y

Place, 04/02/14

Y

Auto
Load?
villerhsiao

Interrupt
How Is Tick Implemented? (Cont.)
●

Prescaler
●

Tweak HW tick period
Timer Module

clk

Place, 04/02/14

Prescaler
val

clk/val

villerhsiao

Counting Part

LOGO
How Is Tick Implemented? (cont.)

●

Timeout ISR
●

Increase system ticks

●

Execute handler of timeout event

●

Re-schedule if required

Place, 04/02/14

villerhsiao

LOGO
Simple Graph of CPU Operating States

LOGO

INT

Processes
Threads
Tasks

ISR
Softirq
CTX
INT

CTX
CTX
Idle thread

CTX
INT

INT

T
sleep
T
Deep sleep

Place, 04/02/14

villerhsiao

INT : interrupt
CTX: context switch
T : after a while
Time Diagram of Legacy Ticks

event1

event2
event3

LOGO

event4

HW
Timer
interrupt

CPU
activities

Place, 04/02/14

villerhsiao
Where Is the Problem?
●

LOGO

Context switch overhead
INT

Processes
Threads
Tasks

ISR
Softirq
CTX
INT

CTX
CTX

Idle thread
T
sleep
T
Deep sleep

Place, 04/02/14

villerhsiao

CTX
INT

INT
Where Is the Problem?
●

LOGO

Unecessary power consumed
INT

Processes
Threads
Tasks

ISR
Softirq
CTX
INT

CTX
CTX

Idle thread
T
sleep
T
Deep sleep

Place, 04/02/14

villerhsiao

CTX
INT

INT
Where Is the Problem?

●

Tick resolution
●

Performance, power v.s. timer precision

Place, 04/02/14

villerhsiao

LOGO
Time Diagram of Legacy Ticks

event1

event2
event3

LOGO

event4

HW
Timer
interrupt

CPU
activities

CPU waken up for timekeeping only
Place, 04/02/14

villerhsiao
Solution: Tickless

event1

event2
event3

LOGO

event4

Timer
interrupt
New
CPU
activities

Previous
CPU
activities
Place, 04/02/14

villerhsiao
Drawback of Tickless

●

LOGO

Tickless is not free [3],
“It increases the number of instructions executed on
the path to and from the idle loop.”
“On many architectures, dyntick-idle mode also
increases the number of expensive clockreprogramming operations”

●

Systems with aggressive real-time response
constraints often run periodic tick

Place, 04/02/14

villerhsiao
Example: Linux Time Subsystem

●

Device level
●

clocksource
–

●

●

jiffies

clockevent

High resolution kernel timer
●

hrtimers

Place, 04/02/14

villerhsiao

LOGO
Example: Linux Time Subsystem (Cont.)

●

LOGO

Tickless
●

(Nearly) Full tickless operation after 3.10

●

dyntick-idle
–

●

adaptive-tick
–

●

CONFIG_NO_HZ_IDLE

CONFIG_NO_HZ_FULL

periodic
–

CONFIG_HZ_PERIODIC

–

Consumes battery power 2-3 times as fast as dyntick-idle one. [3]

Place, 04/02/14

villerhsiao
LOGO

F9 Microkernel ktimer Introduction

Place, 04/02/14

villerhsiao
Example Hardware Device

●

STM32F4Discovery board
●

Cortex-M4 EVB
–

Use Cortex-M4 SysTick as the tick HW
●
●
●

Place, 04/02/14

24-bit system timer
Counting down
Please refer to [4] for more detail

villerhsiao

LOGO
ktimer Features

●

System time

●

Time event

●

Tickless

Place, 04/02/14

villerhsiao

LOGO
ktimer Configurations

●

CONFIG_KTIMER_HEARTBEAT
●

●

CONFIG_KTIMER_MINTICKS
●

●

HW cycles per ktimer tick

Minimum ktimer ticks unit for time event

CONFIG_KTIMER_TICKLESS
●

Enable tickless

Place, 04/02/14

villerhsiao

LOGO
ktimer Event Utility

●

LOGO

ktimer_event_create()
●

Arguments
–
–

Timeout handler

–

●

Timeout ticks
Pointer to arguments for timeout handler

Return Non-zero to reschedule event again
–

Freed automatically if not be re-scheduled

Place, 04/02/14

villerhsiao
ktimer Anotomy

●

System time
●

●

ktime_now

ktimer event list
●

event_queue

●

Managed by ktable

Place, 04/02/14

villerhsiao

LOGO
ktimer Anotomy (Cont.)
●

LOGO

ktable
●

Basic kernel library in F9 Microkernel

●

Fast objects pool management
–

To allocate/free objects of pre-defined size and
numbers easiler
ktable
ktable_free()
ktable_init()

Used
Unused
Place, 04/02/14

ktable_alloc()
villerhsiao
ktimer Anotomy (Cont.)

●

Life cycle of time event
●

One-shot

●

●

LOGO

Continuous

How to control life cycle in ktimer?
●

The return value of handler is treated as next
timeout delta

Place, 04/02/14

villerhsiao
ktimer Anotomy (Cont.)

●

HW Timer ISR
●

__ktimer_handler()
–

Increase tick

–

Arrange Softirq for handling timer events

Place, 04/02/14

villerhsiao

LOGO
ktimer Anotomy (Cont.)

●

LOGO

Two-stage interrupt handling
●

ISR
–

●

IRQ context

Softirq
–

Thread context
●
●

–

Real time preemptive characteristic.
Can be scheduled like any other threads in the system
[5].

Handled in kernel thread

Place, 04/02/14

villerhsiao
ktimer Anotomy (Cont.)

●

HW Timer ISR
●

__ktimer_handler()
–

Increase tick

–

Arrange Softirq for handling timer events

Place, 04/02/14

villerhsiao

LOGO
ktimer Anotomy (Cont.)

●

HW timer softirq handler
●

ktimer_event_handler()
–

Find timeout event and executing its handler

–

Re-insert event if required

Place, 04/02/14

villerhsiao

LOGO
ktimer Anotomy (Cont.)

●

LOGO

Tickless
●

●

Enter tickless right before going to CPU idle
state
Set interval of next timer interrupt as delta of
next event
–

●

Or KTIMER_MAXTICKS

Adjust system time after waked up

Place, 04/02/14

villerhsiao
ktimer Anotomy (Cont.)
●

LOGO

Tickless Compensation
●

SysTick frequency distortion when enter/exit standby
mode
tickless

active

idle

handle
other
interrupt

Timer
interrupt
idle

active

CPU
Activity
systick

Place, 04/02/14

villerhsiao
ktimer Anotomy (Cont.)
●

LOGO

Tickless Compensation

tickless

active

idle

handle
other
interrupt

Timer
interrupt
idle

active

CPU
Activity
systick

Place, 04/02/14

villerhsiao
ktimer Anotomy (Cont.)

●

LOGO

Tickless Compensation
●

Pre-defined value
–

CONFIG_KTIMER_TICKLESS_COMPENSATION
●

–

CONFIG_KTIMER_TICKLESS_INT_COMPENSATION
●

●

Compensation value before entering idle
Compensation value when CPU is waked up by non-timer
interrupt.

But how much to set these value to?

Place, 04/02/14

villerhsiao
ktimer Anotomy (Cont.)

●

LOGO

Tickless Compensation
●

But how much to set these value to?
–

Get average compensation from general pupose
timer
●

(total diff / count of entering tickless)

SYSTICK
HW timer
TIM2

Place, 04/02/14

villerhsiao
ktimer Anotomy (Cont.)

●

LOGO

Tickless Compensation
●

How to calibrate the compensation value?
–

CONFIG_KTIMER_TICKLESS_VERIFY

–

CONFIG_KDB

Set
compensation
To 0

Place, 04/02/14

Get
average
Compensation
from KDB

villerhsiao

Re-define
Compensation
value
ktimer Anotomy (Cont.)
●

LOGO

KDB
●

Kernel debugger

## KDB ##
commands:
K: print kernel tables
e: dump ktimer events
n: show timer (now)
s: show softirqs
t: dump threads
m: dump memory pools
a: dump address spaces
p: show sampling
v: show tickless scheduling stat
----------------

Place, 04/02/14

## KDB ##
-------NOW-----Now is 70993
Ktimer T=1297 D=0
--------------------

villerhsiao
Reference:

LOGO

[1]

Jim Huang (Dec 9, 2013),
“F9: A Secure and Efficient Microkernel Built for Deep Embedded Systems”

[2]

Wikipedia, “System time”

[3]

P. E. McKenney (May 14, 2013), “NO_HZ: Reducing Scheduling-Clock Ticks”

[4]

ST Mcroelectronics,
STM32F3xxx and STM32F4xxx Cortex-M4 programming manual

[5]

J. Altenberg, “Using the Realtime Preemption Patch on ARM CPUs”

Place, 04/02/14

villerhsiao
LOGO

THE END

Place, 04/02/14

villerhsiao

Weitere ähnliche Inhalte

Was ist angesagt?

Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDBLinaro
 
Efficient Buffer Management
Efficient Buffer ManagementEfficient Buffer Management
Efficient Buffer Managementbasisspace
 
Introduction to segmentation fault handling
Introduction to segmentation fault handling Introduction to segmentation fault handling
Introduction to segmentation fault handling Larion
 
Avoiding Catastrophic Performance Loss
Avoiding Catastrophic Performance LossAvoiding Catastrophic Performance Loss
Avoiding Catastrophic Performance Lossbasisspace
 
Debugging With GNU Debugger GDB
Debugging With GNU Debugger GDBDebugging With GNU Debugger GDB
Debugging With GNU Debugger GDBkyaw thiha
 
淺入淺出 GDB
淺入淺出 GDB淺入淺出 GDB
淺入淺出 GDBJim Chang
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDBDavid Khosid
 
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...Anne Nicolas
 
GDB: A Lot More Than You Knew
GDB: A Lot More Than You KnewGDB: A Lot More Than You Knew
GDB: A Lot More Than You KnewUndo
 
Porting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons LearnedPorting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons Learnedbasisspace
 
Give me 15 minutes and i'll change your view of gdb
Give me 15 minutes and i'll change your view of gdbGive me 15 minutes and i'll change your view of gdb
Give me 15 minutes and i'll change your view of gdbgregthelaw
 
Openwrt startup
Openwrt startupOpenwrt startup
Openwrt startup晓东 杜
 
AGDK tutorial step by step
AGDK tutorial step by stepAGDK tutorial step by step
AGDK tutorial step by stepJungsoo Nam
 
Code review and automated testing for Puppet code
Code review and automated testing for Puppet codeCode review and automated testing for Puppet code
Code review and automated testing for Puppet codewzzrd
 
Starting up Containers Super Fast With Lazy Pulling of Images
Starting up Containers Super Fast With Lazy Pulling of ImagesStarting up Containers Super Fast With Lazy Pulling of Images
Starting up Containers Super Fast With Lazy Pulling of ImagesKohei Tokunaga
 
GCC Compiler as a Performance Testing tool for C programs
GCC Compiler as a Performance Testing tool for C programsGCC Compiler as a Performance Testing tool for C programs
GCC Compiler as a Performance Testing tool for C programsDaniel Ilunga
 
Deep dive - Concourse CI/CD and Pipelines
Deep dive  - Concourse CI/CD and PipelinesDeep dive  - Concourse CI/CD and Pipelines
Deep dive - Concourse CI/CD and PipelinesSyed Imam
 

Was ist angesagt? (20)

Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDB
 
Efficient Buffer Management
Efficient Buffer ManagementEfficient Buffer Management
Efficient Buffer Management
 
Introduction to segmentation fault handling
Introduction to segmentation fault handling Introduction to segmentation fault handling
Introduction to segmentation fault handling
 
Avoiding Catastrophic Performance Loss
Avoiding Catastrophic Performance LossAvoiding Catastrophic Performance Loss
Avoiding Catastrophic Performance Loss
 
Debugging With GNU Debugger GDB
Debugging With GNU Debugger GDBDebugging With GNU Debugger GDB
Debugging With GNU Debugger GDB
 
淺入淺出 GDB
淺入淺出 GDB淺入淺出 GDB
淺入淺出 GDB
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDB
 
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
 
Gnu debugger
Gnu debuggerGnu debugger
Gnu debugger
 
GDB: A Lot More Than You Knew
GDB: A Lot More Than You KnewGDB: A Lot More Than You Knew
GDB: A Lot More Than You Knew
 
Porting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons LearnedPorting the Source Engine to Linux: Valve's Lessons Learned
Porting the Source Engine to Linux: Valve's Lessons Learned
 
GDB Rocks!
GDB Rocks!GDB Rocks!
GDB Rocks!
 
Give me 15 minutes and i'll change your view of gdb
Give me 15 minutes and i'll change your view of gdbGive me 15 minutes and i'll change your view of gdb
Give me 15 minutes and i'll change your view of gdb
 
Openwrt startup
Openwrt startupOpenwrt startup
Openwrt startup
 
Usage of GDB
Usage of GDBUsage of GDB
Usage of GDB
 
AGDK tutorial step by step
AGDK tutorial step by stepAGDK tutorial step by step
AGDK tutorial step by step
 
Code review and automated testing for Puppet code
Code review and automated testing for Puppet codeCode review and automated testing for Puppet code
Code review and automated testing for Puppet code
 
Starting up Containers Super Fast With Lazy Pulling of Images
Starting up Containers Super Fast With Lazy Pulling of ImagesStarting up Containers Super Fast With Lazy Pulling of Images
Starting up Containers Super Fast With Lazy Pulling of Images
 
GCC Compiler as a Performance Testing tool for C programs
GCC Compiler as a Performance Testing tool for C programsGCC Compiler as a Performance Testing tool for C programs
GCC Compiler as a Performance Testing tool for C programs
 
Deep dive - Concourse CI/CD and Pipelines
Deep dive  - Concourse CI/CD and PipelinesDeep dive  - Concourse CI/CD and Pipelines
Deep dive - Concourse CI/CD and Pipelines
 

Ähnlich wie f9-microkernel-ktimer

Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17Muga Nishizawa
 
Reducing boot time in embedded Linux
Reducing boot time in embedded LinuxReducing boot time in embedded Linux
Reducing boot time in embedded LinuxChris Simmonds
 
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueShapeBlue
 
LCE13: Introduction to Jira - Linaro's Project Management Application
LCE13: Introduction to Jira - Linaro's Project Management ApplicationLCE13: Introduction to Jira - Linaro's Project Management Application
LCE13: Introduction to Jira - Linaro's Project Management ApplicationLinaro
 
What's Coming in CloudStack 4.19
What's Coming in CloudStack 4.19What's Coming in CloudStack 4.19
What's Coming in CloudStack 4.19ShapeBlue
 
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018Taro L. Saito
 
NTTドコモ様 導入事例 OpenStack Summit 2015 Tokyo 講演「After One year of OpenStack Cloud...
NTTドコモ様 導入事例 OpenStack Summit 2015 Tokyo 講演「After One year of OpenStack Cloud...NTTドコモ様 導入事例 OpenStack Summit 2015 Tokyo 講演「After One year of OpenStack Cloud...
NTTドコモ様 導入事例 OpenStack Summit 2015 Tokyo 講演「After One year of OpenStack Cloud...VirtualTech Japan Inc.
 
smalltalk numbercrunching
smalltalk numbercrunchingsmalltalk numbercrunching
smalltalk numbercrunchingDaniel Poon
 
BUD17-405: Building a reference IoT product with Zephyr
BUD17-405: Building a reference IoT product with Zephyr BUD17-405: Building a reference IoT product with Zephyr
BUD17-405: Building a reference IoT product with Zephyr Linaro
 
Reducing the boot time of Linux devices
Reducing the boot time of Linux devicesReducing the boot time of Linux devices
Reducing the boot time of Linux devicesChris Simmonds
 
Cinder On-boarding Room - Berlin (11-13-2018)
Cinder On-boarding Room - Berlin (11-13-2018)Cinder On-boarding Room - Berlin (11-13-2018)
Cinder On-boarding Room - Berlin (11-13-2018)Jay Bryant
 
Quick and Easy Device Drivers for Embedded Linux Using UIO
Quick and Easy Device Drivers for Embedded Linux Using UIOQuick and Easy Device Drivers for Embedded Linux Using UIO
Quick and Easy Device Drivers for Embedded Linux Using UIOChris Simmonds
 
TI TechDays 2010: swiftBoot
TI TechDays 2010: swiftBootTI TechDays 2010: swiftBoot
TI TechDays 2010: swiftBootandrewmurraympc
 
Integrating Puppet and Gitolite for sysadmins cooperations
Integrating Puppet and Gitolite for sysadmins cooperationsIntegrating Puppet and Gitolite for sysadmins cooperations
Integrating Puppet and Gitolite for sysadmins cooperationsLuca Mazzaferro
 
Cloud firewall logging
Cloud firewall loggingCloud firewall logging
Cloud firewall loggingJoyent
 
OpenStack Cinder On-Boarding Room - Vancouver Summit 2018
OpenStack Cinder On-Boarding Room - Vancouver Summit 2018OpenStack Cinder On-Boarding Room - Vancouver Summit 2018
OpenStack Cinder On-Boarding Room - Vancouver Summit 2018Jay Bryant
 
from Docker to Moby and back. what changed ?
from Docker to Moby and back. what changed ?from Docker to Moby and back. what changed ?
from Docker to Moby and back. what changed ?strikr .
 

Ähnlich wie f9-microkernel-ktimer (20)

Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
 
Reducing boot time in embedded Linux
Reducing boot time in embedded LinuxReducing boot time in embedded Linux
Reducing boot time in embedded Linux
 
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
 
LCE13: Introduction to Jira - Linaro's Project Management Application
LCE13: Introduction to Jira - Linaro's Project Management ApplicationLCE13: Introduction to Jira - Linaro's Project Management Application
LCE13: Introduction to Jira - Linaro's Project Management Application
 
What's Coming in CloudStack 4.19
What's Coming in CloudStack 4.19What's Coming in CloudStack 4.19
What's Coming in CloudStack 4.19
 
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
Airframe: Lightweight Building Blocks for Scala - Scale By The Bay 2018
 
NTTドコモ様 導入事例 OpenStack Summit 2015 Tokyo 講演「After One year of OpenStack Cloud...
NTTドコモ様 導入事例 OpenStack Summit 2015 Tokyo 講演「After One year of OpenStack Cloud...NTTドコモ様 導入事例 OpenStack Summit 2015 Tokyo 講演「After One year of OpenStack Cloud...
NTTドコモ様 導入事例 OpenStack Summit 2015 Tokyo 講演「After One year of OpenStack Cloud...
 
smalltalk numbercrunching
smalltalk numbercrunchingsmalltalk numbercrunching
smalltalk numbercrunching
 
BUD17-405: Building a reference IoT product with Zephyr
BUD17-405: Building a reference IoT product with Zephyr BUD17-405: Building a reference IoT product with Zephyr
BUD17-405: Building a reference IoT product with Zephyr
 
Feature toggling
Feature togglingFeature toggling
Feature toggling
 
Reducing the boot time of Linux devices
Reducing the boot time of Linux devicesReducing the boot time of Linux devices
Reducing the boot time of Linux devices
 
Cinder On-boarding Room - Berlin (11-13-2018)
Cinder On-boarding Room - Berlin (11-13-2018)Cinder On-boarding Room - Berlin (11-13-2018)
Cinder On-boarding Room - Berlin (11-13-2018)
 
Quick and Easy Device Drivers for Embedded Linux Using UIO
Quick and Easy Device Drivers for Embedded Linux Using UIOQuick and Easy Device Drivers for Embedded Linux Using UIO
Quick and Easy Device Drivers for Embedded Linux Using UIO
 
TI TechDays 2010: swiftBoot
TI TechDays 2010: swiftBootTI TechDays 2010: swiftBoot
TI TechDays 2010: swiftBoot
 
HPC on OpenStack
HPC on OpenStackHPC on OpenStack
HPC on OpenStack
 
Hexagonal architecture
Hexagonal architectureHexagonal architecture
Hexagonal architecture
 
Integrating Puppet and Gitolite for sysadmins cooperations
Integrating Puppet and Gitolite for sysadmins cooperationsIntegrating Puppet and Gitolite for sysadmins cooperations
Integrating Puppet and Gitolite for sysadmins cooperations
 
Cloud firewall logging
Cloud firewall loggingCloud firewall logging
Cloud firewall logging
 
OpenStack Cinder On-Boarding Room - Vancouver Summit 2018
OpenStack Cinder On-Boarding Room - Vancouver Summit 2018OpenStack Cinder On-Boarding Room - Vancouver Summit 2018
OpenStack Cinder On-Boarding Room - Vancouver Summit 2018
 
from Docker to Moby and back. what changed ?
from Docker to Moby and back. what changed ?from Docker to Moby and back. what changed ?
from Docker to Moby and back. what changed ?
 

Mehr von Viller Hsiao

Bpf performance tools chapter 4 bcc
Bpf performance tools chapter 4   bccBpf performance tools chapter 4   bcc
Bpf performance tools chapter 4 bccViller Hsiao
 
Prerequisite knowledge for shared memory concurrency
Prerequisite knowledge for shared memory concurrencyPrerequisite knowledge for shared memory concurrency
Prerequisite knowledge for shared memory concurrencyViller Hsiao
 
twlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsotwlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsoViller Hsiao
 
Linux kernel tracing
Linux kernel tracingLinux kernel tracing
Linux kernel tracingViller Hsiao
 
Meet cute-between-ebpf-and-tracing
Meet cute-between-ebpf-and-tracingMeet cute-between-ebpf-and-tracing
Meet cute-between-ebpf-and-tracingViller Hsiao
 
mbed-os 3.0 modules dependency graph
mbed-os 3.0 modules dependency graphmbed-os 3.0 modules dependency graph
mbed-os 3.0 modules dependency graphViller Hsiao
 
Introduction to ARM mbed-OS 3.0 uvisor
Introduction to ARM mbed-OS 3.0 uvisorIntroduction to ARM mbed-OS 3.0 uvisor
Introduction to ARM mbed-OS 3.0 uvisorViller Hsiao
 
My first-crawler-in-python
My first-crawler-in-pythonMy first-crawler-in-python
My first-crawler-in-pythonViller Hsiao
 
Yet another introduction to Linux RCU
Yet another introduction to Linux RCUYet another introduction to Linux RCU
Yet another introduction to Linux RCUViller Hsiao
 

Mehr von Viller Hsiao (9)

Bpf performance tools chapter 4 bcc
Bpf performance tools chapter 4   bccBpf performance tools chapter 4   bcc
Bpf performance tools chapter 4 bcc
 
Prerequisite knowledge for shared memory concurrency
Prerequisite knowledge for shared memory concurrencyPrerequisite knowledge for shared memory concurrency
Prerequisite knowledge for shared memory concurrency
 
twlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsotwlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdso
 
Linux kernel tracing
Linux kernel tracingLinux kernel tracing
Linux kernel tracing
 
Meet cute-between-ebpf-and-tracing
Meet cute-between-ebpf-and-tracingMeet cute-between-ebpf-and-tracing
Meet cute-between-ebpf-and-tracing
 
mbed-os 3.0 modules dependency graph
mbed-os 3.0 modules dependency graphmbed-os 3.0 modules dependency graph
mbed-os 3.0 modules dependency graph
 
Introduction to ARM mbed-OS 3.0 uvisor
Introduction to ARM mbed-OS 3.0 uvisorIntroduction to ARM mbed-OS 3.0 uvisor
Introduction to ARM mbed-OS 3.0 uvisor
 
My first-crawler-in-python
My first-crawler-in-pythonMy first-crawler-in-python
My first-crawler-in-python
 
Yet another introduction to Linux RCU
Yet another introduction to Linux RCUYet another introduction to Linux RCU
Yet another introduction to Linux RCU
 

Kürzlich hochgeladen

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Kürzlich hochgeladen (20)

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

f9-microkernel-ktimer

  • 1. Your Logo Here Viller Hsiao <villerhsiao@gmail.com> F9 Microkernel ktimer
  • 2. Rights to Copy LOGO copyright © 2014 Viller Hsiao Attribution – ShareAlike 3.0 You are free ● to copy, distribute, display, and perform the work ● to make derivative works ● Corrections, suggestions, contributions and translations are welcome! to make commercial use of the work Under the following conditions Attribution. You must give the original author credit. – Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. For any reuse or distribution, you must make clear to others the license terms of this work. – ● Any of these conditions can be waived if you get permission from the copyright holder. Your fair use and other rights are in no way affected by the above. License text: http://creativecommons.org/licenses/by-sa/3.0/legalcode Place, 04/02/14 villerhsiao
  • 3. F9 Microkernel [1] ● New open source implementation built from scratch, which deploys modern kernel techniques, derived from L4 microkernel designs, to deep embedded devices. ● ● BSD License Characteristics of F9 microkernel ● Efficiency: performance + power consumption – Tickless ● Security: memory protection + isolated execution ● ● LOGO Flexible development environment Repository ● https://github.com/f9micro Place, 04/02/14 villerhsiao
  • 4. Agenda ● ● LOGO Concept about operating system kernel time subsystem F9 Microkernel ktimer introduction Place, 04/02/14 villerhsiao
  • 5. LOGO Concept about Operating System Kernel Time Subsystem Place, 04/02/14 villerhsiao
  • 6. OS Kernel Time Subsystem ● Current Time ● System time, UTC/GMP time, … etc ● Alarm, the time event ● Process timeslice ● Timeout ● Time delay Place, 04/02/14 villerhsiao LOGO
  • 7. System Time and Tick ● LOGO From Wikipedia [2], “System time represents a computer system's notion of the passing of time.“ “System time is measured by a system clock, which is typically implemented as a simple count of the number of ticks that have transpired since some arbitrary starting date, called the epoch.” Place, 04/02/14 villerhsiao
  • 8. How Is Tick Implemented? ● LOGO Hardware timer device ● Assert interrupt after a programmable inteval – Handling tick stuff in Timeout Interrupt Service Routine (ISR) HW Timer CPU Adjust system time Handle timeout event …. Timeout interrupt Control Read Counts Setup timeout value Place, 04/02/14 villerhsiao
  • 9. How Is Tick Implemented? (Cont.) ● Type 1: Incremental timer ● Example: Cortex-A9 MP Global Timer Place, 04/02/14 villerhsiao LOGO
  • 10. How Is Tick Implemented? (Cont.) ● LOGO Incremental timer functionality 1 Current Value + 0x12abc = Incremental value 0x36000 Compare Value + 0x36000 Y Place, 04/02/14 Y Auto Increament? villerhsiao Interrupt
  • 11. How Is Tick Implemented? (Cont.) ● Type 2: Counting down timer ● Example: Cortex-M4 SysTick Place, 04/02/14 villerhsiao LOGO
  • 12. How Is Tick Implemented? (Cont.) ● LOGO Counting down timer functionality 0 = 1 - Reload value = 0x36000 Current Value 0x12abc Y Place, 04/02/14 Y Auto Load? villerhsiao Interrupt
  • 13. How Is Tick Implemented? (Cont.) ● Prescaler ● Tweak HW tick period Timer Module clk Place, 04/02/14 Prescaler val clk/val villerhsiao Counting Part LOGO
  • 14. How Is Tick Implemented? (cont.) ● Timeout ISR ● Increase system ticks ● Execute handler of timeout event ● Re-schedule if required Place, 04/02/14 villerhsiao LOGO
  • 15. Simple Graph of CPU Operating States LOGO INT Processes Threads Tasks ISR Softirq CTX INT CTX CTX Idle thread CTX INT INT T sleep T Deep sleep Place, 04/02/14 villerhsiao INT : interrupt CTX: context switch T : after a while
  • 16. Time Diagram of Legacy Ticks event1 event2 event3 LOGO event4 HW Timer interrupt CPU activities Place, 04/02/14 villerhsiao
  • 17. Where Is the Problem? ● LOGO Context switch overhead INT Processes Threads Tasks ISR Softirq CTX INT CTX CTX Idle thread T sleep T Deep sleep Place, 04/02/14 villerhsiao CTX INT INT
  • 18. Where Is the Problem? ● LOGO Unecessary power consumed INT Processes Threads Tasks ISR Softirq CTX INT CTX CTX Idle thread T sleep T Deep sleep Place, 04/02/14 villerhsiao CTX INT INT
  • 19. Where Is the Problem? ● Tick resolution ● Performance, power v.s. timer precision Place, 04/02/14 villerhsiao LOGO
  • 20. Time Diagram of Legacy Ticks event1 event2 event3 LOGO event4 HW Timer interrupt CPU activities CPU waken up for timekeeping only Place, 04/02/14 villerhsiao
  • 22. Drawback of Tickless ● LOGO Tickless is not free [3], “It increases the number of instructions executed on the path to and from the idle loop.” “On many architectures, dyntick-idle mode also increases the number of expensive clockreprogramming operations” ● Systems with aggressive real-time response constraints often run periodic tick Place, 04/02/14 villerhsiao
  • 23. Example: Linux Time Subsystem ● Device level ● clocksource – ● ● jiffies clockevent High resolution kernel timer ● hrtimers Place, 04/02/14 villerhsiao LOGO
  • 24. Example: Linux Time Subsystem (Cont.) ● LOGO Tickless ● (Nearly) Full tickless operation after 3.10 ● dyntick-idle – ● adaptive-tick – ● CONFIG_NO_HZ_IDLE CONFIG_NO_HZ_FULL periodic – CONFIG_HZ_PERIODIC – Consumes battery power 2-3 times as fast as dyntick-idle one. [3] Place, 04/02/14 villerhsiao
  • 25. LOGO F9 Microkernel ktimer Introduction Place, 04/02/14 villerhsiao
  • 26. Example Hardware Device ● STM32F4Discovery board ● Cortex-M4 EVB – Use Cortex-M4 SysTick as the tick HW ● ● ● Place, 04/02/14 24-bit system timer Counting down Please refer to [4] for more detail villerhsiao LOGO
  • 27. ktimer Features ● System time ● Time event ● Tickless Place, 04/02/14 villerhsiao LOGO
  • 28. ktimer Configurations ● CONFIG_KTIMER_HEARTBEAT ● ● CONFIG_KTIMER_MINTICKS ● ● HW cycles per ktimer tick Minimum ktimer ticks unit for time event CONFIG_KTIMER_TICKLESS ● Enable tickless Place, 04/02/14 villerhsiao LOGO
  • 29. ktimer Event Utility ● LOGO ktimer_event_create() ● Arguments – – Timeout handler – ● Timeout ticks Pointer to arguments for timeout handler Return Non-zero to reschedule event again – Freed automatically if not be re-scheduled Place, 04/02/14 villerhsiao
  • 30. ktimer Anotomy ● System time ● ● ktime_now ktimer event list ● event_queue ● Managed by ktable Place, 04/02/14 villerhsiao LOGO
  • 31. ktimer Anotomy (Cont.) ● LOGO ktable ● Basic kernel library in F9 Microkernel ● Fast objects pool management – To allocate/free objects of pre-defined size and numbers easiler ktable ktable_free() ktable_init() Used Unused Place, 04/02/14 ktable_alloc() villerhsiao
  • 32. ktimer Anotomy (Cont.) ● Life cycle of time event ● One-shot ● ● LOGO Continuous How to control life cycle in ktimer? ● The return value of handler is treated as next timeout delta Place, 04/02/14 villerhsiao
  • 33. ktimer Anotomy (Cont.) ● HW Timer ISR ● __ktimer_handler() – Increase tick – Arrange Softirq for handling timer events Place, 04/02/14 villerhsiao LOGO
  • 34. ktimer Anotomy (Cont.) ● LOGO Two-stage interrupt handling ● ISR – ● IRQ context Softirq – Thread context ● ● – Real time preemptive characteristic. Can be scheduled like any other threads in the system [5]. Handled in kernel thread Place, 04/02/14 villerhsiao
  • 35. ktimer Anotomy (Cont.) ● HW Timer ISR ● __ktimer_handler() – Increase tick – Arrange Softirq for handling timer events Place, 04/02/14 villerhsiao LOGO
  • 36. ktimer Anotomy (Cont.) ● HW timer softirq handler ● ktimer_event_handler() – Find timeout event and executing its handler – Re-insert event if required Place, 04/02/14 villerhsiao LOGO
  • 37. ktimer Anotomy (Cont.) ● LOGO Tickless ● ● Enter tickless right before going to CPU idle state Set interval of next timer interrupt as delta of next event – ● Or KTIMER_MAXTICKS Adjust system time after waked up Place, 04/02/14 villerhsiao
  • 38. ktimer Anotomy (Cont.) ● LOGO Tickless Compensation ● SysTick frequency distortion when enter/exit standby mode tickless active idle handle other interrupt Timer interrupt idle active CPU Activity systick Place, 04/02/14 villerhsiao
  • 39. ktimer Anotomy (Cont.) ● LOGO Tickless Compensation tickless active idle handle other interrupt Timer interrupt idle active CPU Activity systick Place, 04/02/14 villerhsiao
  • 40. ktimer Anotomy (Cont.) ● LOGO Tickless Compensation ● Pre-defined value – CONFIG_KTIMER_TICKLESS_COMPENSATION ● – CONFIG_KTIMER_TICKLESS_INT_COMPENSATION ● ● Compensation value before entering idle Compensation value when CPU is waked up by non-timer interrupt. But how much to set these value to? Place, 04/02/14 villerhsiao
  • 41. ktimer Anotomy (Cont.) ● LOGO Tickless Compensation ● But how much to set these value to? – Get average compensation from general pupose timer ● (total diff / count of entering tickless) SYSTICK HW timer TIM2 Place, 04/02/14 villerhsiao
  • 42. ktimer Anotomy (Cont.) ● LOGO Tickless Compensation ● How to calibrate the compensation value? – CONFIG_KTIMER_TICKLESS_VERIFY – CONFIG_KDB Set compensation To 0 Place, 04/02/14 Get average Compensation from KDB villerhsiao Re-define Compensation value
  • 43. ktimer Anotomy (Cont.) ● LOGO KDB ● Kernel debugger ## KDB ## commands: K: print kernel tables e: dump ktimer events n: show timer (now) s: show softirqs t: dump threads m: dump memory pools a: dump address spaces p: show sampling v: show tickless scheduling stat ---------------- Place, 04/02/14 ## KDB ## -------NOW-----Now is 70993 Ktimer T=1297 D=0 -------------------- villerhsiao
  • 44. Reference: LOGO [1] Jim Huang (Dec 9, 2013), “F9: A Secure and Efficient Microkernel Built for Deep Embedded Systems” [2] Wikipedia, “System time” [3] P. E. McKenney (May 14, 2013), “NO_HZ: Reducing Scheduling-Clock Ticks” [4] ST Mcroelectronics, STM32F3xxx and STM32F4xxx Cortex-M4 programming manual [5] J. Altenberg, “Using the Realtime Preemption Patch on ARM CPUs” Place, 04/02/14 villerhsiao