1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management...

25
u www.iti.tugraz.at u [email protected] Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach Graz University of Technology Institute for Technical Informatics Echtzeit 2015 - Betriebssysteme und Echtzeit Boppard, November 12-13, 2015

Transcript of 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management...

Page 1: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

u www.iti.tugraz.at u [email protected]

Collaborative Resource

Management for Multi-Core

AUTOSAR OS

1

Renata Martins Gomes

Fabian Mauroner

Marcel Baunach

Graz University of Technology

Institute for Technical Informatics

Echtzeit 2015 - Betriebssysteme und Echtzeit

Boppard, November 12-13, 2015

Page 2: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Agenda

• General Concepts

• AUTOSAR

• DynamicHinting

• Proposed Improvements

• Summary and Outlook

Collaborative Resource Management for Multi-Core AUTOSAR OS

2

Renata M. Gomes ([email protected])

Page 3: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

General ConceptsPriority Inversion

Collaborative Resource Management for Multi-Core AUTOSAR OS

3

Renata M. Gomes ([email protected])

Bounded

Page 4: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Collaborative Resource Management for Multi-Core AUTOSAR OS

4

Renata M. Gomes ([email protected])

General ConceptsPriority Inversion

Bounded Unbounded

Page 5: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

AUTOSAR OS

• Based on OSEK (Offene Systeme und deren

Schnittstellen für die Elektronik im Kraftfahrzeug)

• Designed with single-core in mind

• Extended for multi-core support

• For strictly static systems

Collaborative Resource Management for Multi-Core AUTOSAR OS

6

Renata M. Gomes ([email protected])

Page 6: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Collaborative Resource Management for Multi-Core AUTOSAR OS

7

Renata M. Gomes ([email protected])

AUTOSAR OSMulti-Core Support

AUTOSAR has been extended to support multi-core

processors. One example is in the resource sharing

mechanisms:

In AUTOSAR OS, there was no reformulation of the

concepts behind the resource management.

Instead, a second sharing mechanism was created to

deal only with the resource sharing across cores.

Two incompatible concepts for sharing resources

Page 7: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Collaborative Resource Management for Multi-Core AUTOSAR OS

8

Renata M. Gomes ([email protected])

AUTOSAR OSResources

Sharing resources among tasks within one core

• Defined by OSEK

• OSEK-PCP (highest-locker protocol)

• Each resource has a ceiling priority

• Task priority is immediately raised to ceiling upon allocation

• Avoids unbounded priority inversion and deadlocks

Sub-ceiling priority tasks won’t run, even if they do not need (yet)

the resource

• Restricted system calls while holding a resource

• Tasks cannot suspend themselves (wait for event, sleep, etc)

• Deadlock free

Page 8: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Collaborative Resource Management for Multi-Core AUTOSAR OS

9

Renata M. Gomes ([email protected])

AUTOSAR OSSpinlocks

Sharing resources among tasks only across cores

• Not allowed in same core

• Tasks priorities are meaningless across cores

• No priority-related resource manager defined

• Spinlock allocation order is hw/sw dependent

• Busy waiting for already allocated spinlocks

• Advice: disable interrupts while waiting/holding a spinlock

• Nesting only in globally well-defined order

Deadlocks are avoided, but unbounded priority inversion

may occur across cores

Page 9: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Collaborative Resource Management for Multi-Core AUTOSAR OS

10

Renata M. Gomes ([email protected])

• Resource management approach

• Tasks collaborate with each other when sharing exclusive

resources

• Hints sent to blocking tasks to indicate their spurious influence

• Tasks are free to ignore or follow a hint (release the resource)

• Contracts can be specified, e.g. for enforcing behavior and

real-time constraints

• Hint receiving and handling:

• Explicit query

• Early wakeup

• Hint handlers

DynamicHintingCollaborative Resource Management

Page 10: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Collaborative Resource Management for Multi-Core AUTOSAR OS

11

Renata M. Gomes ([email protected])

DynamicHintingCollaborative Resource Management

• Reduces priority inversion

• Requires collaboration between tasks

Page 11: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Collaborative Resource Management for Multi-Core AUTOSAR OS

12

Renata M. Gomes ([email protected])

Priority Inheritance Protocol (PIP)

DynamicHintingCollaborative Resource Management

• Reduces priority inversion

• Requires collaboration between tasks

Page 12: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Collaborative Resource Management for Multi-Core AUTOSAR OS

13

Renata M. Gomes ([email protected])

DynamicHintingCollaborative Resource Management

PIP with DynamicHinting

• Reduces priority inversion

• Requires collaboration between tasks

Page 13: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Proposed Improvementsin AUTOSAR

• Introduce DynamicHinting

• Establish cross-core priority awareness

• Define priority-based allocation order for spinlocks

• Remove unbounded priority inversion for spinlocks

• Reduce bounded priority inversion

Collaborative Resource Management for Multi-Core AUTOSAR OS

14

Renata M. Gomes ([email protected])

Page 14: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Proposed ImprovementsTestbed

Tests conducted with widely-used hardware and

software in the automotive domain:

• Triple-core Infineon AURIXTM TC297B microcontroller

• Open-source OSEK and AUTOSAR compliant ERIKA

Enterprise OS V2.5.0

External oscilloscope measures digital-output lines

driven by tasks

Collaborative Resource Management for Multi-Core AUTOSAR OS

15

Renata M. Gomes ([email protected])

Page 15: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Proposed ImprovementsAllocation Order for Spinlocks

In case two or more tasks wait for a spinlock, which one receives it first?

• Tasks waiting for a spinlock should receive it in order of task priority

• AUTOSAR does not define this order, leaving it dependent on the

implementation

• E.g. Test system:

• Software (OS): FIFO queue

• Hardware: core-specific priority queue

Changes on the busy-waiting mechanism:

• Only the highest-priority task waiting actually polls lock variable

• Others wait until they have highest priority in waiting queue

Collaborative Resource Management for Multi-Core AUTOSAR OS

16

Renata M. Gomes ([email protected])

Page 16: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Proposed ImprovementsAllocation Order for Spinlocks

Collaborative Resource Management for Multi-Core AUTOSAR OS

17

Renata M. Gomes ([email protected])

Unmodified ERIKA

Page 17: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Proposed ImprovementsAllocation Order for Spinlocks

Collaborative Resource Management for Multi-Core AUTOSAR OS

18

Renata M. Gomes ([email protected])

Modified ERIKAUnmodified ERIKA

Page 18: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Proposed ImprovementsHandling Unbounded Priority Inversion

No unbounded priority inversion should ever occur in a real-time system,

but so far in AUTOSAR:

• No resource management protocol implemented across cores

• No priorities known across cores

• Unbounded priority inversion might occur

Communicate priority inversion to other cores:

• Set an OSEK event when cross-core priority inversion occurs

• Current owner (core) receives event, and raises the priority of the

blocking task for the time while it holds the spinlock

Ideally implemented in kernel, proof of concept implemented at

application level

Collaborative Resource Management for Multi-Core AUTOSAR OS

19

Renata M. Gomes ([email protected])

Page 19: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Collaborative Resource Management for Multi-Core AUTOSAR OS

20

Renata M. Gomes ([email protected])

Unmodified ERIKA

Proposed ImprovementsHandling Unbounded Priority Inversion

Page 20: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Collaborative Resource Management for Multi-Core AUTOSAR OS

21

Renata M. Gomes ([email protected])

Modified ERIKAUnmodified ERIKA

Proposed ImprovementsHandling Unbounded Priority Inversion

Page 21: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

• Hints for spinlocks

• Hints received through explicit query

• In tests, tasks periodically ask the resource

manager about their current hints

• In tests, tasks are always resource-collaborative

Collaborative Resource Management for Multi-Core AUTOSAR OS

22

Renata M. Gomes ([email protected])

Proposed ImprovementsDynamicHinting

Page 22: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Collaborative Resource Management for Multi-Core AUTOSAR OS

23

Renata M. Gomes ([email protected])

Proposed ImprovementsDynamicHinting

Ex.: Allocation Order Ex.: Unbounded Priority Inversion

Page 23: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Summary

AUTOSAR does not provide satisfactory resource

management, specially for multi-core platforms.

Proposed improvements

• Removed unbounded priority inversion for spinlocks

• Defined priority-based allocation order for spinlocks

• Introduced DynamicHinting in AUTOSAR

• Reduced bounded priority inversion

• System kept deadlock free

• API unchanged

Collaborative Resource Management for Multi-Core AUTOSAR OS

24

Renata M. Gomes ([email protected])

Page 24: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Outlook

• Modify kernel to support more flexible hint notification

• Unify AUTOSAR resources and spinlocks

• Schedulability analysis

• Dependability guarantees on real-time behavior

• Introduce DynamicHinting in other multi-core Oss

• Test in real application

Collaborative Resource Management for Multi-Core AUTOSAR OS

25

Renata M. Gomes ([email protected])

Page 25: 1 Collaborative Resource Management for Multi-Core AUTOSAR … · Collaborative Resource Management for Multi-Core AUTOSAR OS 1 Renata Martins Gomes Fabian Mauroner Marcel Baunach

Thank you!

Collaborative Resource Management for Multi-Core AUTOSAR OS

26

Renata M. Gomes ([email protected])

Renata Martins [email protected]

Graz University of Technology

Institute for Technical Informatics

Embedded Automotive Systems Group (EAS)