53
Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte Systeme und Betriebssysteme Friedrich-Alexander-Universität Erlangen-Nürnberg SS 15 – 2015-05-04 http://www4.informatik.uni-erlangen.de/Lehre/SS15/V _ KSS

Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Konfigurierbare Systemsoftware

(KSS)

VL 4 – Aspect-Aware Development:

The CiAO Approach

Daniel Lohmann

Lehrstuhl für Informatik 4Verteilte Systeme und Betriebssysteme

Friedrich-Alexander-UniversitätErlangen-Nürnberg

SS 15 – 2015-05-04

http://www4.informatik.uni-erlangen.de/Lehre/SS15/V_KSS

Page 2: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

About this Lecture

Problem Space Solution Space

Specif ic Problem Specif ic Solution

Domain Expert ��

��

����

������

Features and Dependencies

Architect / Developer

�����

�����

�����Class

�����Aspect...

Architecture and Implementation

System User

����...

�Conf igurationA

B

D

C

System User

inst

ance

leve

lm

odel

leve

l

Variant

intendedproperties

actual implementation

intentional side extensional side

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach 4–2

Page 3: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Implementation Techniques: Classification →֒ 3–3

Decompositional Approaches

Configuration

Components Variant

Text-based filtering (untyped)

Preprocessors

Compositional Approaches

Configuration

Components Variant

Language-based composition

mechanisms (typed)

OOP, AOP, Templates

Generative Approaches

Configuration

Generator VariantTemplates

Metamodel-based generation

of components (typed)

MDD, C++ TMP, generators

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach 4–3

Page 4: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Implementation Techniques: Goals →֒ 2–35

GeneralHow to achieve

these with AOP?➊ Separation of concerns (SoC)

➋ Resource thriftiness

Operational

➌ Granularity Components should be fine-grained. Each artifact should ei-

ther be mandatory or dedicated to a single feature only.

➍ Economy The use of memory/run-time expensive language features

should be avoided as far as possible. Decide and bind as much

as possible at generation time.

➎ Pluggability Changing the set of optional features should not require mod-

ifications in any other part of the implementation. Feature

implements should be able to “integrate themselves”.

➏ Extensibility The same should hold for new optional features, which may be

available in a future version of the product line.

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach 4–4

Page 5: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Agenda

4.1 AOP Mechanisms Under the Hood

4.2 Study: i4Weathermon AOP

4.3 CiAO

4.4 CiAO Results

4.5 Summary

4.6 References

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach 4–5

Page 6: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Agenda

4.1 AOP Mechanisms Under the HoodDiagram Notation

Obliviousness & Quantification

AOP Mechanisms: Summary

4.2 Study: i4Weathermon AOP

4.3 CiAO

4.4 CiAO Results

4.5 Summary

4.6 References

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.1 AOP Mechanisms Under the Hood 4–6

Page 7: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Notation

BaseClass

method()

explicitJP() • method is explicit join point

SomeClass

#protected()

static()

unadvisable() ◦

method is unadvisable

AnAspect

exec("explicitJP")

intro("SomeClass")

«slice»

ASlice

state_variable_

anotherMethod()

"explicitJP"

advice [of "join point"]

ASlice

introduction [of Slice]

static

call [of method]

elements belong to same concern

kn

ow

s implied relationship

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.1 AOP Mechanisms Under the Hood 4–7

Page 8: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

AOP Mechanisms Demystified: “Obliviousness”

Szenario:

Optional featurecomponent F1 shall beintegrated into SPLcomponent PL

F1

feature()

PL

main()

fea

ture

kn

ow

s

«aspect»

F1

exec("main")

PL

main()

kn

ow

s

"ma

in"

With OOP:

PL has to call F1 ; PL has to know F1

control flows can only be established in the direction of knowledge

With AOP:

F1 can give advice to PL ; F1 has to may know PLcontrol flow is established opposite to the direction of knowledgebinding is inherently loose ; silently missed, if PL does not exist

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.1 AOP Mechanisms Under the Hood 4–8

Page 9: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

AOP Mechanisms Demystified: “Quantification”

Szenario:

(Nonfunctional)feature component F1

shall be integrated into(optional) SPLcomponents PLC1...n

«aspect»

F1

exec("%")

PLC1

foo()

PLC2

bar()

PLCn

zoo()

. . .

. . .

With AOP:

binding is inherently loose ; may quantify over n join pointspossible by delarative pointcut concept(here: wildcard in match expression)

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.1 AOP Mechanisms Under the Hood 4–9

Page 10: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

AOP Mechanisms Demystified: Summary

Advice inverses the direction in which control-flow relationships

are established: C calls A =⇒ A advises C

Aspects integrate themselves into the surrounding program; “I make you call me”

Surrounding program can be kept oblivious of the aspects; advice-based binding as a means to integrate (optional) features

Pointcuts provide for an implicit quantifiction of this integration

Applies to 0 . . . M . . . n join points, depending on the pointcut expression; Aspects can be kept oblivious of the surrounding program

Thereby, advice-based binding is inherently loose; advice-based binding as a means to integrate interacting features

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.1 AOP Mechanisms Under the Hood 4–10

Page 11: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Agenda

4.1 AOP Mechanisms Under the Hood

4.2 Study: i4Weathermon AOPFlashback: i4Weathermon

I4WeatherMon with AOP

I4WeatherMon with AOP: Results

4.3 CiAO

4.4 CiAO Results

4.5 Summary

4.6 References

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.2 Study: i4Weathermon AOP 4–11

Page 12: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

I4WeatherMon: Feature Model →֒ 2–30

WeatherMon

Actuators

... Alarm Display PC Connection

RS232Line USBLine Protocol

SNGProto

rationale: SNGProto provides

backwards compatibility to

existing client software XMLProto

Sensors

Temperature Air Pressure Wind Speed ...

How to achieve Granularity, Economy, Pluggability, Extensibility ?

Configuration-dependent sensor and actuator sets

initialization, integration, interaction of optional feature code

Generic and nongeneric actuators

interacting optional feature code

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.2 Study: i4Weathermon AOP 4–12

Page 13: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

I4WeatherMon: OOP Solution Space →֒ 2–40

«interface»

Sensor

measure()name()unit()str_val()init()

«interface»

Actuator

before_process()after_process()process()init()

ChainBase

_next

Wind

id()measure()name()unit()str_val()init()

Pressure

id()measure()name()unit()str_val()init()

Display

#print()before_process()process()init()

SNGConnection

before_process()after_process()process()init()

«alias»

PCConnection

#send()

Weather

registerSensor()measure()init()

Sink

registerActuator()process()init()

_sensors _actuatorsinit,

measure

init,

pro

cess

registerSensor registerActuator

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.2 Study: i4Weathermon AOP 4–13

Page 14: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

I4WeatherMon: AOP Solution Space

Weather

measure() •

Wind

measure()name()unit()str_val()

Pressure

measure()name()unit()str_val()

PressureHandling

exec("Weather::measure")exec("Sink::process")intro("Weather")intro("Sink")

WindHandling

exec("Weather::measure")exec("Sink::process")intro("Weather")intro("Sink")

Display

#print()

exec("Sink::process")exec("Sink::process_data(%)")

SNGConnection

exec("Sink::process")exec("Sink::process_data(Wind)")exec("Sink::process_data(Pressure)")exec("Sink::process_data(Temperature)")

Sink

process() •

process_data(Pressure) •

process_data(Wind) •

«alias»

PCConnection

#send()

_wind

_pressure

measure

measure

"measure"

"measure"

"process"

pro

cess_data

(Win

d)

"process"

pro

cess_data

(Pre

ssure

)

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.2 Study: i4Weathermon AOP 4–14

Page 15: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

I4WeatherMon: AOP Solution Space

Weather

measure() •

Wind

measure()name()unit()str_val()

Pressure

measure()name()unit()str_val()

PressureHandling

exec("Weather::measure")exec("Sink::process")intro("Weather")intro("Sink")

WindHandling

exec("Weather::measure")exec("Sink::process")intro("Weather")intro("Sink")

Display

#print()

exec("Sink::process")exec("Sink::process_data(%)")

SNGConnection

exec("Sink::process")exec("Sink::process_data(Wind)")exec("Sink::process_data(Pressure)")exec("Sink::process_data(Temperature)")

Sink

process() •

process_data(Pressure) •

process_data(Wind) •

«alias»

PCConnection

#send()

_wind

_pressure

measure

measure

"measure"

"measure"

"process"

pro

cess_data

(Win

d)

"process"

pro

cess_data

(Pre

ssure

)

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.2 Study: i4Weathermon AOP 4–14

Basic structure

Weather and Sink are (almost) empty classes.

Provide a lexical scope for sensor / actuator introductions

Provide explicit join points (empty methods measure() / process()) that are

invoked by the main loop, when measuring / processing should take place

; All further functionality is provided by the aspects!

Page 16: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

I4WeatherMon: AOP Solution Space

Weather

measure() •

Wind

measure()name()unit()str_val()

Pressure

measure()name()unit()str_val()

PressureHandling

exec("Weather::measure")exec("Sink::process")intro("Weather")intro("Sink")

WindHandling

exec("Weather::measure")exec("Sink::process")intro("Weather")intro("Sink")

Display

#print()

exec("Sink::process")exec("Sink::process_data(%)")

SNGConnection

exec("Sink::process")exec("Sink::process_data(Wind)")exec("Sink::process_data(Pressure)")exec("Sink::process_data(Temperature)")

Sink

process() •

process_data(Pressure) •

process_data(Wind) •

«alias»

PCConnection

#send()

_wind

_pressure

measure

measure

"measure"

"measure"

"process"

pro

cess_data

(Win

d)

"process"

pro

cess_data

(Pre

ssure

)

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.2 Study: i4Weathermon AOP 4–14

Sensor integration

A Sensor is implemented as a class with an accompanying Handling aspect

Slices the sensor singleton instance into Weather

Gives advice to Weather::measure() to invoke Sensor::measure()

Slices an explicit join point process_data(Sensor) into Sink

Gives advice to Sink::process() to invoke process_data(Sensor)

Page 17: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

I4WeaterMon: AOP Sensor Integration

class Weather {public:void measure() {} // empty implementation

};

class Sink {public:void process() {} // empty implementation

};

aspect PressureHandling {// Weather integrationadvice "Weather" : slice struct{Pressure _pressure; // introduce sensor instance (singleton)

};advice execution( "void Weather::measure()" ) : before() {theWeather._pressure.measure(); // invoke sensor’s measure()

}// Sink integrationadvice "Sink" : slice struct {// introduce sensor-specific explicit join point for actuator aspectsvoid process_data( const Pressure & ) {}

};advice execution( "void Sink::process()" ) : after() {theSink.process_data( theWeather._pressure ); // trigger it

}};

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.2 Study: i4Weathermon AOP 4–15

Page 18: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

I4WeatherMon: AOP Solution Space

Weather

measure() •

Wind

measure()name()unit()str_val()

Pressure

measure()name()unit()str_val()

PressureHandling

exec("Weather::measure")exec("Sink::process")intro("Weather")intro("Sink")

WindHandling

exec("Weather::measure")exec("Sink::process")intro("Weather")intro("Sink")

Display

#print()

exec("Sink::process")exec("Sink::process_data(%)")

SNGConnection

exec("Sink::process")exec("Sink::process_data(Wind)")exec("Sink::process_data(Pressure)")exec("Sink::process_data(Temperature)")

Sink

process() •

process_data(Pressure) •

process_data(Wind) •

«alias»

PCConnection

#send()

_wind

_pressure

measure

measure

"measure"

"measure"

"process"

pro

cess_data

(Win

d)

"process"

pro

cess_data

(Pre

ssure

)

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.2 Study: i4Weathermon AOP 4–16

Generic actuator integration

A generic actuator (processes all sensors) is implemented by an aspect

Gives advice to Sink::process() to execute processing pre-/post actions

Gives generic advice to all overloads of Sink:process_data() to invoke

each sensor (typed) in order to process its data via the generic str_val()

; Generic actuator does not know the available / possible sensor types

Page 19: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

I4WeaterMon: AOP Generic Actuator Integration

aspect Display {...

// display each element of the weather dataadvice execution("void Sink::process_data(%)") : before () {typedef JoinPoint::template Arg<0>::ReferredType Data;char val[5];tjp->arg<0>()->str_val( val );print( Data::name(), val, Data::unit() );

}};

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.2 Study: i4Weathermon AOP 4–17

Page 20: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

I4WeatherMon: AOP Solution Space

Weather

measure() •

Wind

measure()name()unit()str_val()

Pressure

measure()name()unit()str_val()

PressureHandling

exec("Weather::measure")exec("Sink::process")intro("Weather")intro("Sink")

WindHandling

exec("Weather::measure")exec("Sink::process")intro("Weather")intro("Sink")

Display

#print()

exec("Sink::process")exec("Sink::process_data(%)")

SNGConnection

exec("Sink::process")exec("Sink::process_data(Wind)")exec("Sink::process_data(Pressure)")exec("Sink::process_data(Temperature)")

Sink

process() •

process_data(Pressure) •

process_data(Wind) •

«alias»

PCConnection

#send()

_wind

_pressure

measure

measure

"measure"

"measure"

"process"

pro

cess_data

(Win

d)

"process"

pro

cess_data

(Pre

ssure

)

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.2 Study: i4Weathermon AOP 4–18

Nongeneric actuator integration

A nongeneric actuator (processes some sensors) is implemented by an aspect

Gives advice to Sink::process() to execute processing pre-/post actions

Gives advice to selected overloads of Sink:process_data() to invoke them

in order to process each sensors data via a sensor-specific interface

; Nongeneric actuator has to know specific sensor types

Page 21: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

I4WeaterMon: AOP Generic Actuator Integration

aspect SNGConnection : protected PCConnection {UInt8 _p, _w, _t1, _t2; // weather record...

// let this aspect take a higher precedence than <Sensor>Handlingadvice process () : order ("SNGConnection", "%Handling");advice execution("void Sink::process(const Weather&)")

: before () { ... /* init record */ }advice execution("void Sink::process(const Weather&)")

: after () { ... /* transmit record */ }

// collect wind, pressure, temperature data by giving specific adviceadvice execution("void Sink::process_data(...)") && args (wind)

: before (const Wind &wind) {_w = wind._w;

}advice execution("void Sink::process_data(...)") && args (pressure)

: before (const Pressure &pressure) {_p = pressure._p - 850;

}advice execution("void Sink::process_data(...)") && args (temp)

: before (const Temperature &temp) {_t1 = (UInt8)temp._t1;_t2 = temp._t2;

}};

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.2 Study: i4Weathermon AOP 4–19

Page 22: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

I4WeaterMon: CPP vs. AOP – Footprint →֒ 2–42

64

Air PressureDisplay

Air PressureDisplayRS232LineXMLProto

Air PressureWind SpeedDisplay

TemperatureDisplay

TemperatureAir PressureWind SpeedRS232LineXMLProto

TemperatureAir PressureWind SpeedRS232LineXMLProtoDisplayC Version AO Version OO Version

512

1024

1536

2048

2560

3072

3584

4096

4608

5120

5632

RA

M(B

yte

)

96

128

160

192

224

256

288

320

352

384

Fla

sh

(Byte

)

AOP is as efficient as

CPP-based configurability!

Page 23: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

I4WeaterMon (AOP): Evaluation

General

➊ Separation of concerns (SoC) ✔

➋ Resource thriftiness ✔

Operational➌ Granularity ✔

Every component implements functionality of a single feature only.

➍ Economy ✔

All control-flow bindings are established at compile time.

➎ Pluggability ✔

Sensors and actuators integrate themselves by aspects.

➏ Extensibility ✔

“Plug & Play” of sensor and actuator implementations.

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.2 Study: i4Weathermon AOP 4–21

Page 24: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Agenda

4.1 AOP Mechanisms Under the Hood

4.2 Study: i4Weathermon AOP

4.3 CiAOMotivation and Goals

Design Approach

Examples: Aspects in Action

Explicit Join Points

Further Examples

4.4 CiAO Results

4.5 Summary

4.6 References

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–22

Page 25: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

CiAO: Motivation and Goals

“Throughout the entire operating-system design cycle, we

must be careful to separate policy decisions from implemen-

tation details (mechanisms). This separation allows maximum

flexibility if policy decisions are to be changed later.

”Silberschatz, Gagne, and Galvin 2005: Operating System Concepts [8, p. 72]

Primary goal: architectural configurability

configurability of even fundamental policies7→ synchronization, protection, interaction

Secondary goal: < the standards >

efficiency, configurability in general, portability

Approach: aspect-aware operating system design

strict decoupling of policies and mechanisms in the implementation7→ using aspects as the primary composition technique

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–23

Page 26: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

CiAO 7→ CiAO is Aspect-Oriented [3–5]

A product line of aspect-oriented operating systems

Implements OSEK VDX / AUTOSAR OS [1, 7]Fine-grained configurability of all system policies and abstractionsDeveloped from scratch with AOP

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–24

Page 27: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

CiAO: General Structure

Layered Architecture

Interface layer (as/ciao)System layer (os)Hardware layer (hw)

Layers 7→ C++ namespaces

Potential join points forcross-layer transitionsFurther refined by sublayers(os::krn, hw::irq)Layers as a means ofaspect-aware development; “visible transitions”

// yields all hardware invocations from the system layerpointcut OStoHW() = call("% hw::...::%(...)")

&& within("% os::...::%(...)");

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–25

Page 28: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Methodology: Principles of Aspect-Aware Development

Design Principles 7→ Development Idioms

1. loose coupling

2. visible transitions

3. minimal extensions

by

by

by

advice-based binding

explicit join points

extension slices

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–26

Page 29: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Methodology: Principles of Aspect-Aware Development

The principle of loose coupling. Make sure that aspects can hook into allfacets of the static and dynamic integration of system components.The binding of components, but also their instantiation (e.g, placementin a certain memory region) and the time and order of their initialization

should all be established (or at least be influenceable) by aspects.

The principle of visible transitions. Make sure that aspects can hook intoall control flows that run through the system. All control-flowtransitions into, out of, and within the system should be influenceableby aspects. For this they have to be represented on the join-point levelas statically evaluable, unambiguous join points.

The principle of minimal extensions. Make sure that aspects can extendall features provided by the system on a fine granularity. Systemcomponents and system abstractions should be fine-grained, sparse, andextensible by aspects.

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–27

Page 30: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Methodology: Roles of Aspects and Classes

What to model as a class and what as an aspect?

< Thing > is a class if – and only if – itis a distinguishable, instantiable concept of CiAO:

A system component, instantiated internally on behalf of CiAO

The Scheduler, the Alarm Manager, the OS control facility, ...

Hold and manage kernel state, singletons by definition

A system abstraction, instantiated as objects on behalf of the user

Task, Event, Resource, ...

In AUTOSAR OS: instantiated at compile time

Both are sparse ; provide a minimal implementation only

Otherwise < thing > is an aspect!

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–28

Page 31: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Methodology: Roles of Aspects and Classes (Cont’d)

Three idiomatic aspect roles

Extension aspects: extend some system component or systemabstraction by additional functionality.

Policy aspects: “glue” otherwise unrelated system abstractions orcomponents together to implement some CiAO kernel policy.

Upcall aspects: bind behavior defined by higher layers to eventsproduced in lower layers of the system.

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–29

Page 32: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Example: Mechanism Integration

Serial0

init()sendBlock()

Sched

init()ready()

«extension aspect»

Serial0Ext

exec("init")

«binding aspect»

Serial0_Init

exec("init")

«binding aspect»

Sched_Init

exec("init")

«slice»

Serial0Ext_Task

Task _task

init

init

Serial0Ext_Task

init

uses

ready

init() •

"init"

visible transitions

by explicit join points

binding aspectsimplement upcalls by

advice-based bindings

extension aspectsadd to mechanisms by

extension slices

This might lead to

additional functional

dependencies

os::krn

hw::hal

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–30

Page 33: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Example: Mechanism Integration

Serial0

init()sendBlock()

Sched

init()ready()

«extension aspect»

Serial0Ext

exec("init")

«binding aspect»

Serial0_Init

exec("init")

«binding aspect»

Sched_Init

exec("init")

«slice»

Serial0Ext_Task

Task _task

init

init

Serial0Ext_Task

init

uses

ready

init() •

"init"

visible transitions

by explicit join points

binding aspectsimplement upcalls by

advice-based bindings

extension aspectsadd to mechanisms by

extension slices

This might lead to

additional functional

dependencies

os::krn

hw::hal

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–30

Page 34: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Example: Mechanism Integration

Serial0

init()sendBlock()

Sched

init()ready()

«extension aspect»

Serial0Ext

exec("init")

«binding aspect»

Serial0_Init

exec("init")

«binding aspect»

Sched_Init

exec("init")

«slice»

Serial0Ext_Task

Task _task

init

init

Serial0Ext_Task

init

uses

ready

init() •

"init"

visible transitions

by explicit join points

binding aspectsimplement upcalls by

advice-based bindings

extension aspectsadd to mechanisms by

extension slices

This might lead to

additional functional

dependencies

os::krn

hw::hal

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–30

Page 35: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Example: Mechanism Integration

Serial0

init()sendBlock()

Sched

init()ready()

«extension aspect»

Serial0Ext

exec("init")

«binding aspect»

Serial0_Init

exec("init")

«binding aspect»

Sched_Init

exec("init")

«slice»

Serial0Ext_Task

Task _task

init

init

Serial0Ext_Task

init

uses

ready

init() •

"init"

visible transitions

by explicit join points

binding aspectsimplement upcalls by

advice-based bindings

extension aspectsadd to mechanisms by

extension slices

This might lead to

additional functional

dependencies

aspect Serial0Ext {...

advice execution( "void hw::hal::init()" ): order( "Sched_Init", "Serial0_Init" );

...

};

os::krn

hw::hal

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–30

Page 36: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Example: Policy Integration

os::krn

os::krn

hw::hal

«policy aspect»

Sched_LeaveBinding

exec("leaveKernel")

Sched

reschedule()setNeedReschedule()

enterKernel() •

leaveKernel() •

Cooperative Scheduling:

resch

ed

ule

"le

ave

Ke

rne

l"

visible transitions

by explicit join points

Sched

reschedule()setNeedReschedule()

enterKernel() •

leaveKernel() •

«policy aspect»

Sched_ASTBinding

exec("ast")exec("setNeedReschedule")

«policy aspect»

Kernel_ASTSync

exec("enterKernel()")exec("leaveKernel()")

AST0

trigger()disable()enable()

ast() •

Preemptive Scheduling:

reschedule

"setNeedReschedule"

"ast"

trigg

er

uses

dis

able

/e

na

ble

"leaveKernel"

"enterKernel"

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–31

Page 37: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Example: Policy Integration

os::krn

os::krn

hw::hal

«policy aspect»

Sched_LeaveBinding

exec("leaveKernel")

Sched

reschedule()setNeedReschedule()

enterKernel() •

leaveKernel() •

Cooperative Scheduling:

resch

ed

ule

"le

ave

Ke

rne

l"

policy aspectsconnect mechanisms

to implement some

CiAO kernel policy

Sched

reschedule()setNeedReschedule()

enterKernel() •

leaveKernel() •

«policy aspect»

Sched_ASTBinding

exec("ast")exec("setNeedReschedule")

«policy aspect»

Kernel_ASTSync

exec("enterKernel()")exec("leaveKernel()")

AST0

trigger()disable()enable()

ast() •

Preemptive Scheduling:

reschedule

"setNeedReschedule"

"ast"

trigg

er

uses

dis

able

/e

na

ble

"leaveKernel"

"enterKernel"

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–31

Page 38: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Example: Policy Integration

os::krn

os::krn

hw::hal

«policy aspect»

Sched_LeaveBinding

exec("leaveKernel")

Sched

reschedule()setNeedReschedule()

enterKernel() •

leaveKernel() •

Cooperative Scheduling:

resch

ed

ule

"le

ave

Ke

rne

l"

Sched

reschedule()setNeedReschedule()

enterKernel() •

leaveKernel() •

«policy aspect»

Sched_ASTBinding

exec("ast")exec("setNeedReschedule")

«policy aspect»

Kernel_ASTSync

exec("enterKernel()")exec("leaveKernel()")

AST0

trigger()disable()enable()

ast() •

Preemptive Scheduling:

reschedule

"setNeedReschedule"

"ast"

trigg

er

uses

dis

able

/e

na

ble

"leaveKernel"

"enterKernel"

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–31

Page 39: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Methodology: Explicit Join Points

Advice-based binding 7→ availability of the “right” join points

for all semantically important transitions in the system

statically evaluable

Fine-grained component structure ; many implicit join points, but

amount and precise semantics often implementation dependent

aspects have to “know” ; no obliviousness

Important transitions not available for technical reasons as JPs

target code may be fragile (e.g., context switch) ; must not be advised

target code may be written in assembly ; transitions not visible as JPs

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–32

Page 40: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Methodology: Explicit Join Points (Cont’d)

Solution: explicit join points

empty inline methods for the sole purpose that aspects can bind to them

explicitly triggered by components or other aspects

; well defined semantics

Upcall join points (U) represent system-internal events that are tobe processed on a higher layer

exceptions, such as signals or interrupts

internal events, such as system intitalization or entering of the idle state

Transition join points (T) represent semantically importantcontrol-flow transitions inside the kernel

level transitions: user → kernel , user → interrupt

context transitions: threadA → threadB

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–33

Page 41: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Exp

licit

Join

Poin

tsin

CiA

O(E

xcer

pt)

[5] type representing function or method description

os::

krn

U interalErrorHook() Explicit join points for the support and binding of

OSEK OS and AUTOSAR OS user-level hook

functions, as specified in [36, p. 39] and [4, p. 46].

Triggered in case of an error, a protection violation,

before (pre) and after (post) at high-level task

switch, and at operating-system startup and

shutdown time.

U internalProtectionHook(StatusType error)

U internalPreTaskHook()

U internalPostTaskHook()

U internalStartupHook()

U internalShutdownHook()

T enterKernel() Triggered when a control flow enters (respectively

leaves) the kernel domain.T leaveKernel()

...

hw

::h

al

U ThreadFunc() Entry point of a new thread (continuation).

T before_CPURelease(Continuation*& to) Triggered immediately before the running

continuation is deactivated or terminated; to is

going to become the next running continuation.T before_LastCPURelease(Continuation*& to)

T after_CPUReceive() Triggered immediately after the (new) running

continuation got reactivated or started.T after_FirstCPUReceive()

U AST<#>::ast() Entry point of the respective AST.

U init() Triggered during system startup after memory

busses and stack have been initialized.

...

hw

::ir

q U <IRQ_NAME>::handler() Entry point of the respective interrupt handler. (In-

terrupts are still disabled.)

...

Page 42: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Example: Optional Feature Interaction [4]

«policy aspect»

MixedPreemption

exec(...)

«slice»

MixedPreemption_Task

preemptable_

Mixe

dP

reem

ptio

n_Task

«policy aspect»

ResourceSupport_PIP

exec("getResource)exec("releaseResource)

Scheduler

activate()reschedule()setNeedReschedule()

Task

priority_

«extension aspect»

ResourceSupport

intro("Sched")intro("Task")...

«slice»

ResourceSupport_Sched

getResource()releaseResource()

«slice»

ResourceSupport_Task

occupied_originalPri_

ResourceSupport_TaskResource-Support_Sched

«policy aspect»

FullPreemption

call(...)

"activate""releaseResource""setEvent"

«policy aspect»

ResourceSupport_PCP

exec("getResource)exec("releaseResource)

"getResource"

"releaseResource"

«policy aspect»

MixedPreemption

exec(...)

«slice»

MixedPreemption_Task

preemptable_

Mixe

dP

reem

ptio

n_Task

«policy aspect»

ResourceSupport_PIP

exec("getResource)exec("releaseResource)

Scheduler

activate()reschedule()setNeedReschedule()

Task

priority_

«extension aspect»

ResourceSupport

intro("Sched")intro("Task")...

«slice»

ResourceSupport_Sched

getResource()releaseResource()

«slice»

ResourceSupport_Task

occupied_originalPri_

ResourceSupport_TaskResource-Support_Sched

«policy aspect»

FullPreemption

call(...)

"activate""releaseResource""setEvent"

«policy aspect»

ResourceSupport_PCP

exec("getResource)exec("releaseResource)

"getResource"

"releaseResource"

«policy aspect»

MixedPreemption

exec(...)

«slice»

MixedPreemption_Task

preemptable_

Mixe

dP

reem

ptio

n_Task

«policy aspect»

ResourceSupport_PIP

exec("getResource)exec("releaseResource)

Scheduler

activate()reschedule()setNeedReschedule()

Task

priority_

«extension aspect»

ResourceSupport

intro("Sched")intro("Task")...

«slice»

ResourceSupport_Sched

getResource()releaseResource()

«slice»

ResourceSupport_Task

occupied_originalPri_

ResourceSupport_TaskResource-Support_Sched

«policy aspect»

FullPreemption

call(...)

"activate""releaseResource""setEvent"

«policy aspect»

ResourceSupport_PCP

exec("getResource)exec("releaseResource)

"getResource"

"releaseResource"

«policy aspect»

MixedPreemption

exec(...)

«slice»

MixedPreemption_Task

preemptable_

Mixe

dP

reem

ptio

n_Task

«policy aspect»

ResourceSupport_PIP

exec("getResource)exec("releaseResource)

Scheduler

activate()reschedule()setNeedReschedule()

Task

priority_

«extension aspect»

ResourceSupport

intro("Sched")intro("Task")...

«slice»

ResourceSupport_Sched

getResource()releaseResource()

«slice»

ResourceSupport_Task

occupied_originalPri_

ResourceSupport_TaskResource-Support_Sched

«policy aspect»

FullPreemption

call(...)

"activate""releaseResource""setEvent"

«policy aspect»

ResourceSupport_PCP

exec("getResource)exec("releaseResource)

"getResource"

"releaseResource"

«policy aspect»

MixedPreemption

exec(...)

«slice»

MixedPreemption_Task

preemptable_

Mixe

dP

reem

ptio

n_Task

«policy aspect»

ResourceSupport_PIP

exec("getResource)exec("releaseResource)

Scheduler

activate()reschedule()setNeedReschedule()

Task

priority_

«extension aspect»

ResourceSupport

intro("Sched")intro("Task")...

«slice»

ResourceSupport_Sched

getResource()releaseResource()

«slice»

ResourceSupport_Task

occupied_originalPri_

ResourceSupport_TaskResource-Support_Sched

«policy aspect»

FullPreemption

call(...)

"activate""releaseResource""setEvent"

«policy aspect»

ResourceSupport_PCP

exec("getResource)exec("releaseResource)

"getResource"

"releaseResource"

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.3 CiAO 4–35

Page 43: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Continuation:

CiA

O’s

Thre

ad

Abst

ract

ion

[5]

os::krn

hw::hal

ContinuationBase

#init()#save() ◦

#load() ◦

#go() ◦

Continuation

init()hasSeenCPU()switchTo() ◦

saveAndSwitchTo() ◦

start() ◦

saveAndStart() ◦

before_CPURelease() •

before_LastCPURelease() •

after_CPUReceive() •

after_FirstCPUReceive() •

TCBUser

#kickoff()init()start()saveAndStart()

ThreadFunc() •afte

r_F

irstC

PU

Re

ce

ive

«extension aspect»

TCBUser_Cleanup

call("after_FirstCPUReceive")intro("TCBUser")exec("before_LastCPURelease")

«slice»

CleanupSupport

cleanup()

"before_LastCPURelease"

CleanupSupport

«extension aspect»

Continuation_Active

intro("Continuation")exec("after_%CPUReceive")

«slice»

ActiveSupport

setActive()getActive()

ActiveSupport

«policy aspect»

Continuation_SyncIRQ

exec("before_%CPURelease")exec("after_%CPUReceive")

CPU

disable()enable()

disable

enable

«binding aspect»

Task_TCBBinding

exec("ThreadFunc")

enterKernel() •

leaveKernel() •

"ThreadFunc"

leaveKernel TaskFunc

Page 44: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Agenda

4.1 AOP Mechanisms Under the Hood

4.2 Study: i4Weathermon AOP

4.3 CiAO

4.4 CiAO Results

4.5 Summary

4.6 References

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.4 CiAO Results 4–37

Page 45: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

AU

TO

SA

R-O

SFea

ture

sIm

ple

men

ted

inC

iAO

as

Asp

ects

(Exc

erpt)

concern exte

nsio

np

olicy

up

call

ad

vic

e

join

po

ints

extension of | advice-based binding to

ISR cat. 1 support 1 m 2+m 2+m API, OS control | m ISR bindings

ISR cat. 2 support 1 n 5+n 5+n API, OS control, scheduler | n ISR bindings

ISR abortion support 1 2 1+m+n scheduler | m+n ISR functions

Resource support 1 1 3 5 scheduler, API, task | PCP policy implementation

Resource tracking 1 3 4 task, ISR | monitoring of Get/ReleaseResource

Event support 1 5 5 scheduler, API, task, alarm | trigger action JP

Alarm support 1 1 1 API

OS application support 1 2 3 scheduler, task, ISR

Full preemption 1 2 6 | 3 points of rescheduling

Mixed preemption 1 3 7 task | 3 points of rescheduling for task / ISR

Multiple activation support 1 3 3 task | binding to scheduler

Stack monitoring 1 2 3 task | CPU-release JPs

Context check 1 1 s | s service calls

Disabled interrupts check 1 1 30 | all services except interrupt services

Enable w/o disable check 1 3 3 | enable services

Missing task end check 1 1 t | t task functions

Out of range check 1 1 4 | alarm set and schedule table start services

Invalid object check 1 1 25 | services with an OS object parameter

Error hook 1 2 30 scheduler | 29 services

Protection hook 1 1 2 2 API | default policy implementation

Startup / shutdown hook 1 2 2 | explicit hooks

Pre-task / post-task hook 1 2 2 | explicit hooks

Table 5. CiAO-AS kernel concern implemented as aspects with number of affected

Plug & Play of optional features and policies!

Page 46: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Kernel Latency Comparison with “OSEK” [4]

test scenario CiAO OSEK

min full min

(a) voluntary task switch 160 178 218

(b) forced task switch 108 127 280

(c) preemptive task switch 192 219 274

(d) system startup 194 194 399

(e) resource acquisition 19 56 54

(f) resource release 14 52 41

(g) resource release with preemption 240 326 294

(h) category 2 ISR latency 47 47 47

(i) event blocking with task switch 141 172 224

(j) event setting with preemption 194 232 201

(k) comprehensive application 748 748 1216

ormance measurement comparison from CiAO andExecution time [clock ticks] on TC1796@50 MHz

(ac++1.0pre3 with tricore-g++3.4.3 -O3 -fno-rtti -funit-at-a-time -ffunction-sections

-Xlinker --gc-sections)

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.4 CiAO Results 4–39

Page 47: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Kernel Latency Comparison with “OSEK” [4]

test scenario CiAO OSEK

min full min

(a) voluntary task switch 160 178 218

(b) forced task switch 108 127 280

(c) preemptive task switch 192 219 274

(d) system startup 194 194 399

(e) resource acquisition 19 56 54

(f) resource release 14 52 41

(g) resource release with preemption 240 326 294

(h) category 2 ISR latency 47 47 47

(i) event blocking with task switch 141 172 224

(j) event setting with preemption 194 232 201

(k) comprehensive application 748 748 1216

ormance measurement comparison from CiAO andExecution time [clock ticks] on TC1796@50 MHz

(ac++1.0pre3 with tricore-g++3.4.3 -O3 -fno-rtti -funit-at-a-time -ffunction-sections

-Xlinker --gc-sections)

CiAO outperforms the marked

leader in 11 out of 12 cases

by up to 260 percent.

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.4 CiAO Results 4–39

Page 48: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Fea

ture

Gra

nula

rity

ofC

iAO

(sta

tic

mem

ory

dem

ands

per

featu

re)

feature with feature or instance text data bss

Base system (OS control and tasks)

per task + func + 20 + 16 + stack

per application mode 0 + 4 0

ISR cat. 1 support 0 0 0

per ISR +func 0 0

per disable–enable + 4 0 0

Resource support + 128 0 0

per resource 0 + 4 0

per task 0 + 8 0

Event support + 280 0 0

per task 0 + 8 0

per alarm 0 + 12 0

Full preemption 0 0 0

per join point + 12 0 0

Mixed preemption 0 0 0

per join point + 44 0 0

per task 0 + 4 0

Wrong context check 0 0 0

per void join point 0 0 0

per StatusType join point + 8 0 0

Interrupts disabled check 0 0 0

per join point + 64 0 0

Invalid parameters check 0 0 0

per join point + 36 0 0

Error hook 0 0 + 4

per join point + 54 0 0

Startup hook or shutdown hook 0 0 0

Pre-task hook or post-task hook 0 0 0

CiAO achieves excellent granularity!

Page 49: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Discussion: Aspect-Aware Development

By AAD CiAO achieves excellent properties [3–5]

configurability and granularity even for fundamental kernel policies

complete separation of concerns in the implementation

The approach has also been applied to other system software

PUMA, the C/C++ transformation framework behind ac++ [9]

CiAOIP, an aspect-oriented IP stack for embedded systems [2]

Issues: comprehensibility & tool support Base code Aspect code

Files LOC Files LOC

CiAO kernel only 423 21,086 333 5,923

CiAO COM 112 8,689 297 5,552

CiAO IP stack 45 5,038 96 3,230

CiAO overall 580 34,813 726 14,705

ution analysis of CiAO base code and aspect code.

CiAO: aspect code/base code = 1/2.4; where the heck xyz is implemented?

calls for additional tool support

ac++ weaver implementation is stable, but not as mature as gcc

missing or confusing error messages

no support for weaving in template code

no C++0x support

This is research,

after all :-)

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.4 CiAO Results 4–41

Page 50: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Agenda

4.1 AOP Mechanisms Under the Hood

4.2 Study: i4Weathermon AOP

4.3 CiAO

4.4 CiAO Results

4.5 Summary

4.6 References

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.5 Summary 4–42

Page 51: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Summary

Aspect-Aware Development exploits AOP mechanisms to achieveseparation of concerns in configurable system software

Advice inverses the direction in which control-flow relationshipsare established: C calls A =⇒ A advises C

; advice-based binding as a means to integrate (optional) features

Pointcuts provide for an implicit quantifiction of this integration

; advice-based binding as a means to integrate interacting features

CiAO applies these concepts from the very beginning

loose coupling by advice-based binding

visible transitions by explicit join points

minimal extensions by extension slices

The results are compelling

configurability of even all fundamental system policies

excellent granularity and footprint

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.5 Summary 4–43

Page 52: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Referenzen

[1] AUTOSAR. Specification of Operating System (Version 2.0.1). Tech. rep.Automotive Open System Architecture GbR, June 2006.

[2] Christoph Borchert, Daniel Lohmann, and Olaf Spinczyk. “CiAO/IP: A HighlyConfigurable Aspect-Oriented IP Stack”. In: Proceedings of the 10th InternationalConference on Mobile Systems, Applications, and Services (MobiSys ’12). (LowWood Bay, Lake District, UK). New York, NY, USA: ACM Press, June 2012,pp. 435–448. ISBN: 978-1-4503-1301-8. DOI: 10.1145/2307636.2307676.

[3] Daniel Lohmann, Wanja Hofer, Wolfgang Schröder-Preikschat, et al.“Aspect-Aware Operating-System Development”. In: Proceedings of the 10thInternational Conference on Aspect-Oriented Software Development (AOSD ’11).(Porto de Galinhas, Brazil). Ed. by Shigeru Chiba. New York, NY, USA: ACMPress, 2011, pp. 69–80. ISBN: 978-1-4503-0605-8. DOI:10.1145/1960275.1960285.

[4] Daniel Lohmann, Wanja Hofer, Wolfgang Schröder-Preikschat, et al. “CiAO: AnAspect-Oriented Operating-System Family for Resource-Constrained EmbeddedSystems”. In: Proceedings of the 2009 USENIX Annual Technical Conference.Berkeley, CA, USA: USENIX Association, June 2009, pp. 215–228. ISBN:978-1-931971-68-3. URL: http://www.usenix.org/event/usenix09/tech/full_papers/lohmann/lohmann.pdf.

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.6 References 4–44

Page 53: Konfigurierbare Systemsoftware (KSS) · Konfigurierbare Systemsoftware (KSS) VL 4 – Aspect-Aware Development: The CiAO Approach Daniel Lohmann Lehrstuhl für Informatik 4 Verteilte

Referenzen (Cont’d)

[5] Daniel Lohmann, Olaf Spinczyk, Wanja Hofer, et al. “The Aspect-Aware Designand Implementation of the CiAO Operating-System Family”. In: Transactions onAOSD IX. Ed. by Gary T. Leavens and Shigeru Chiba. Lecture Notes in ComputerScience 7271. Springer-Verlag, 2012, pp. 168–215. DOI:10.1007/978-3-642-35551-6_5.

[6] Daniel Lohmann, Olaf Spinczyk, and Wolfgang Schröder-Preikschat. “Lean andEfficient System Software Product Lines: Where Aspects Beat Objects”. In:Transactions on AOSD II. Ed. by Awais Rashid and Mehmet Aksit. Lecture Notesin Computer Science 4242. Springer-Verlag, 2006, pp. 227–255. DOI:10.1007/11922827_8.

[7] OSEK/VDX Group. Operating System Specification 2.2.3. Tech. rep.http://portal.osek-vdx.org/files/pdf/specs/os223.pdf, visited 2014-09-29.OSEK/VDX Group, Feb. 2005.

[8] Abraham Silberschatz, Greg Gagne, and Peter Bear Galvin. Operating SystemConcepts. Seventh. John Wiley & Sons, Inc., 2005. ISBN: 0-471-69466-5.

[9] Matthias Urban, Daniel Lohmann, and Olaf Spinczyk. “The aspect-oriented designof the PUMA C/C++ parser framework”. In: Proceedings of the 9th InternationalConference on Aspect-Oriented Software Development (AOSD ’10). (Rennes andSaint-Malo, France). New York, NY, USA: ACM Press, 2010, pp. 217–221. ISBN:978-1-60558-958-9. DOI: 10.1145/1739230.1739256.

c© dl KSS (VL 4 | SS 15) 4 The CiAO Approach | 4.6 References 4–45