+ All Categories
Home > Documents > ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. ·...

ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. ·...

Date post: 30-Jul-2021
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
35
ARA: Automatic Instance-Level Analysis in Real-Time Systems Gerion Entrup, Benedikt Steinmeier, Christian Dietrich Leibniz Universität Hannover July 9, 2019 supported by
Transcript
Page 1: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

ARA: Automatic Instance-Level Analysisin Real-Time Systems

Gerion Entrup, Benedikt Steinmeier, Christian Dietrich

Leibniz Universität Hannover

July 9, 2019 supported by

Page 2: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

A Hard Beginning

Getting a FreeRTOS project from Github:% git clone https://github.com/grafalex82/GPSLoggerCloning into 'GPSLogger'...remote: Enumerating objects: 1245, done.remote: Counting objects: 100% (1245/1245), done.remote: Compressing objects: 100% (666/666), done.remote: Total 9544 (delta 683), reused 992 (delta 567), pack-reused 8299Receiving objects: 100% (9544/9544), 52.33 MiB | 9.47 MiB/s, done.Resolving deltas: 100% (6615/6615), done.

Repository size: 65 MiB134 000 lines of code

What is the systems architecture?

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Motivation 2 – 21

Page 3: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

A Hard Beginning

Getting a FreeRTOS project from Github:% git clone https://github.com/grafalex82/GPSLoggerCloning into 'GPSLogger'...remote: Enumerating objects: 1245, done.remote: Counting objects: 100% (1245/1245), done.remote: Compressing objects: 100% (666/666), done.remote: Total 9544 (delta 683), reused 992 (delta 567), pack-reused 8299Receiving objects: 100% (9544/9544), 52.33 MiB | 9.47 MiB/s, done.Resolving deltas: 100% (6615/6615), done.

Repository size: 65 MiB134 000 lines of code

What is the systems architecture?

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Motivation 2 – 21

Page 4: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

The Instance GraphOSPERT’18:Levels of Specialization in Real-Time Operating Systems

Serial DMAISR

GPSThread

LoggingQueue

SD WriterThread

LEDThread

LockSemaphore

DisplayThread

SPI DMAISR

ButtonThread

EventsQueue

I2C DMAISR

sleep

sleep

wait

wakeup wait

wake

up

waitwakeup

lock

lock

put

get

put get

Get instances of OS abstractions.Get interactions between them.

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Motivation 3 – 21

Page 5: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

The Instance GraphOSPERT’18:Levels of Specialization in Real-Time Operating Systems

Serial DMAISR

GPSThread

LoggingQueue

SD WriterThread

LEDThread

LockSemaphore

DisplayThread

SPI DMAISR

ButtonThread

EventsQueue

I2C DMAISR

sleep

sleep

wait

wakeup wait

wake

up

waitwakeup

lock

lock

put

get

put get

We have extracted the graph manually!Not possible for larger code bases. We need automation!

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Motivation 3 – 21

Page 6: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

Automatic Real-Time Systems Analyzer (ARA)

Automatic instance graph extractionStatic source code analysis

Application as inputSupports multiple RTOS interfaces.(currently FreeRTOS and OSEK/AUTOSAR)Fields of use:

System overviewKnowledge extraction for specializationOS-API usage validation

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Motivation 4 – 21

Page 7: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

Agenda

MotivationTechniqueExperimentsConclusion

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Motivation 5 – 21

Page 8: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

ARA in a Nutshell

Source

ARA

TaskHandle_t h = NULL;i n t main () {

xTaskCreate ( vTask1 , ”Task1” , NULL) ;xTaskCreate ( vTask2 , ”Task2” , &h ) ;

vTaskStartScheduler ( ) ;// should never reach t h i swh i l e ( 1 ) ;r e tu rn 0 ;

}

vo id vTask1 ( vo id ∗ param) {whi l e (1) {

do_stuf f ( ) ;vTaskDelay (100) ;

}}

vo id vTask2 ( vo id ∗ param) {do_long_operation ( ) ;xTaskDelete (h)

}

RTOS-API

Control flow analysisControl flow analysis

RTOS mappingRTOS mapping

Value analysisValue analysis

Serial DMAISR

GPSThread

LoggingQueue

SD WriterThread

LEDThread

LockSemaphore

DisplayThread

SPI DMAISR

ButtonThread

EventsQueue

I2C DMAISR

sleep

sleep

wait

wakeup wait

wake

up

waitwakeup

lock

lock

put

get

put get

Instance graphInstance graph

programmed against

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 6 – 21

Page 9: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

ARA in a Nutshell

Source

ARA

TaskHandle_t h = NULL;i n t main () {

xTaskCreate ( vTask1 , ”Task1” , NULL) ;xTaskCreate ( vTask2 , ”Task2” , &h ) ;

vTaskStartScheduler ( ) ;// should never reach t h i swh i l e ( 1 ) ;r e tu rn 0 ;

}

vo id vTask1 ( vo id ∗ param) {whi l e (1) {

do_stuf f ( ) ;vTaskDelay (100) ;

}}

vo id vTask2 ( vo id ∗ param) {do_long_operation ( ) ;xTaskDelete (h)

}

RTOS-API

Control flow analysisControl flow analysis

RTOS mappingRTOS mapping

Value analysisValue analysis

Serial DMAISR

GPSThread

LoggingQueue

SD WriterThread

LEDThread

LockSemaphore

DisplayThread

SPI DMAISR

ButtonThread

EventsQueue

I2C DMAISR

sleep

sleep

wait

wakeup wait

wake

up

waitwakeup

lock

lock

put

get

put get

Instance graphInstance graph

programmed against

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 6 – 21

Page 10: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

OSEK/AUTOSAR vs. FreeRTOS

TASK t1 {PRIORITY = 1;SCHEDULE = FULL;AUTOSTART = TRUE;

}

TASK t2 {PRIORITY = 2;SCHEDULE = FULL;

}

.oil

OSEK/AUTOSAR

TASK(t1) {ActivateTask(t2);

}

TASK(t2) {TerminateTask();

}

.cpp

TaskHandle_t t1, t2;

int main() {t1 = xTaskCreate(task_1 , 2);t2 = xTaskCreate(task_2 , 1);vTaskStartScheduler();

}

task_1 { // priority: 2vTaskNotifyGive(t1);

}

task_2 { // priority: 1while (true) {

ulTaskNotifyTake();vTaskDelete(NULL);

}}

.cppFreeRTOS

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 7 – 21

Page 11: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

RTOS Mapping

Detect all system callsCreate unified model# OSEK"ActivateTask": (os_type.activate , ...)"TerminateTask": (os_type.destroy , ...)"GetResource": (os_type.take, ...)"ReleaseResource": (os_type.commit , ...)# FreeRTOS"xTaskCreate": (os_type.create , ...)"vTaskNotifyGive": (os_type.commit , ...)"ulTaskNotifyTake" : (os_type.take, ...)"xQueueTakeMutexRecursive": (os_type.take, ...)"xQueueGiveMutexRecursive": (os_type.commit , ...)

Create parser for extra data (like OIL file).

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 8 – 21

Page 12: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

ARA in a Nutshell

Source

ARA

TaskHandle_t h = NULL;i n t main () {

xTaskCreate ( vTask1 , ”Task1” , NULL) ;xTaskCreate ( vTask2 , ”Task2” , &h ) ;

vTaskStartScheduler ( ) ;// should never reach t h i swh i l e ( 1 ) ;r e tu rn 0 ;

}

vo id vTask1 ( vo id ∗ param) {whi l e (1) {

do_stuf f ( ) ;vTaskDelay (100) ;

}}

vo id vTask2 ( vo id ∗ param) {do_long_operation ( ) ;xTaskDelete (h)

}

RTOS-API

Control flow analysisControl flow analysis

RTOS mappingRTOS mapping

Value analysisValue analysis

Serial DMAISR

GPSThread

LoggingQueue

SD WriterThread

LEDThread

LockSemaphore

DisplayThread

SPI DMAISR

ButtonThread

EventsQueue

I2C DMAISR

sleep

sleep

wait

wakeup wait

wake

up

waitwakeup

lock

lock

put

get

put get

Instance graphInstance graph

programmed against

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 9 – 21

Page 13: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

ARA in a Nutshell

Source

ARA

TaskHandle_t h = NULL;i n t main () {

xTaskCreate ( vTask1 , ”Task1” , NULL) ;xTaskCreate ( vTask2 , ”Task2” , &h ) ;

vTaskStartScheduler ( ) ;// should never reach t h i swh i l e ( 1 ) ;r e tu rn 0 ;

}

vo id vTask1 ( vo id ∗ param) {whi l e (1) {

do_stuf f ( ) ;vTaskDelay (100) ;

}}

vo id vTask2 ( vo id ∗ param) {do_long_operation ( ) ;xTaskDelete (h)

}

RTOS-API

Control flow analysisControl flow analysis

RTOS mappingRTOS mapping

Value analysisValue analysis

Serial DMAISR

GPSThread

LoggingQueue

SD WriterThread

LEDThread

LockSemaphore

DisplayThread

SPI DMAISR

ButtonThread

EventsQueue

I2C DMAISR

sleep

sleep

wait

wakeup wait

wake

up

waitwakeup

lock

lock

put

get

put get

Instance graphInstance graph

programmed against

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 9 – 21

Page 14: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

System-Call Aware ICFG

1. Extract interproceduralcontrol flow graph (with LLVM).

2. Split calls in separate blocks.3. Label block types.

system call, call, computation4. Merge appropriate computation blocks.

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

void recv();void send();

void create(int p2) {int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;foo += 4;xTaskCreate(send, p2);return;

}

int main() {create(5);return;

}

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 10 – 21

Page 15: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

System-Call Aware ICFG

1. Extract interproceduralcontrol flow graph (with LLVM).

2. Split calls in separate blocks.

3. Label block types.system call, call, computation

4. Merge appropriate computation blocks.

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

void recv();void send();

void create(int p2) {int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;foo += 4;xTaskCreate(send, p2);return;

}

int main() {create(5);return;

}

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 10 – 21

Page 16: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

System-Call Aware ICFG

1. Extract interproceduralcontrol flow graph (with LLVM).

2. Split calls in separate blocks.3. Label block types.

system call, call, computation

4. Merge appropriate computation blocks.

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

void recv();void send();

void create(int p2) {int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;foo += 4;xTaskCreate(send, p2);return;

}

int main() {create(5);return;

}

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 10 – 21

Page 17: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

System-Call Aware ICFG

1. Extract interproceduralcontrol flow graph (with LLVM).

2. Split calls in separate blocks.3. Label block types.

system call, call, computation4. Merge appropriate computation blocks.

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

create(int)main()

int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;

foo += 4;xTaskCreate(send, p2);return;

create(5);return;

int foo = 0;

xTaskCreate(recv, 3);

if (foo == 0)

foo++;

foo += 4;

if (foo == 0)foo++;

foo += 4;

xTaskCreate(send, p2);

return;

create(5);

return;

void recv();void send();

void create(int p2) {int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;foo += 4;xTaskCreate(send, p2);return;

}

int main() {create(5);return;

}

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 10 – 21

Page 18: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

ARA in a Nutshell

Source

ARA

TaskHandle_t h = NULL;i n t main () {

xTaskCreate ( vTask1 , ”Task1” , NULL) ;xTaskCreate ( vTask2 , ”Task2” , &h ) ;

vTaskStartScheduler ( ) ;// should never reach t h i swh i l e ( 1 ) ;r e tu rn 0 ;

}

vo id vTask1 ( vo id ∗ param) {whi l e (1) {

do_stuf f ( ) ;vTaskDelay (100) ;

}}

vo id vTask2 ( vo id ∗ param) {do_long_operation ( ) ;xTaskDelete (h)

}

RTOS-API

Control flow analysisControl flow analysis

RTOS mappingRTOS mapping

Value analysisValue analysis

Serial DMAISR

GPSThread

LoggingQueue

SD WriterThread

LEDThread

LockSemaphore

DisplayThread

SPI DMAISR

ButtonThread

EventsQueue

I2C DMAISR

sleep

sleep

wait

wakeup wait

wake

up

waitwakeup

lock

lock

put

get

put get

Instance graphInstance graph

programmed against

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 11 – 21

Page 19: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

ARA in a Nutshell

Source

ARA

TaskHandle_t h = NULL;i n t main () {

xTaskCreate ( vTask1 , ”Task1” , NULL) ;xTaskCreate ( vTask2 , ”Task2” , &h ) ;

vTaskStartScheduler ( ) ;// should never reach t h i swh i l e ( 1 ) ;r e tu rn 0 ;

}

vo id vTask1 ( vo id ∗ param) {whi l e (1) {

do_stuf f ( ) ;vTaskDelay (100) ;

}}

vo id vTask2 ( vo id ∗ param) {do_long_operation ( ) ;xTaskDelete (h)

}

RTOS-API

Control flow analysisControl flow analysis

RTOS mappingRTOS mapping

Value analysisValue analysis

Serial DMAISR

GPSThread

LoggingQueue

SD WriterThread

LEDThread

LockSemaphore

DisplayThread

SPI DMAISR

ButtonThread

EventsQueue

I2C DMAISR

sleep

sleep

wait

wakeup wait

wake

up

waitwakeup

lock

lock

put

get

put get

Instance graphInstance graph

programmed against

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 11 – 21

Page 20: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

Value Analysis

Get arguments for system calls.Backward search from the call site.Follow def-use chain.Follow callee-caller relationship.Take unambiguous values.

void recv();void send();

void create(int p2) {int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;foo += 4;xTaskCreate(send, p2);return;

}

int main() {create(5);return;

}

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 12 – 21

Page 21: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

Value Analysis

Get arguments for system calls.Backward search from the call site.Follow def-use chain.Follow callee-caller relationship.Take unambiguous values.

void recv();void send();

void create(int p2) {int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;foo += 4;xTaskCreate(send, p2);return;

}

int main() {create(5);return;

}

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 12 – 21

Page 22: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

Value Analysis

Get arguments for system calls.Backward search from the call site.Follow def-use chain.Follow callee-caller relationship.Take unambiguous values.

void recv();void send();

void create(int p2) {int foo = 0;xTaskCreate(recv, 3);if (foo == 0)

foo++;foo += 4;xTaskCreate(send, p2);return;

}

int main() {create(5);return;

}

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 12 – 21

Page 23: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

ARA in a Nutshell

Source

ARA

TaskHandle_t h = NULL;i n t main () {

xTaskCreate ( vTask1 , ”Task1” , NULL) ;xTaskCreate ( vTask2 , ”Task2” , &h ) ;

vTaskStartScheduler ( ) ;// should never reach t h i swh i l e ( 1 ) ;r e tu rn 0 ;

}

vo id vTask1 ( vo id ∗ param) {whi l e (1) {

do_stuf f ( ) ;vTaskDelay (100) ;

}}

vo id vTask2 ( vo id ∗ param) {do_long_operation ( ) ;xTaskDelete (h)

}

RTOS-API

Control flow analysisControl flow analysis

RTOS mappingRTOS mapping

Value analysisValue analysis

Serial DMAISR

GPSThread

LoggingQueue

SD WriterThread

LEDThread

LockSemaphore

DisplayThread

SPI DMAISR

ButtonThread

EventsQueue

I2C DMAISR

sleep

sleep

wait

wakeup wait

wake

up

waitwakeup

lock

lock

put

get

put get

Instance graphInstance graph

programmed against

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 13 – 21

Page 24: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

ARA in a Nutshell

Source

ARA

TaskHandle_t h = NULL;i n t main () {

xTaskCreate ( vTask1 , ”Task1” , NULL) ;xTaskCreate ( vTask2 , ”Task2” , &h ) ;

vTaskStartScheduler ( ) ;// should never reach t h i swh i l e ( 1 ) ;r e tu rn 0 ;

}

vo id vTask1 ( vo id ∗ param) {whi l e (1) {

do_stuf f ( ) ;vTaskDelay (100) ;

}}

vo id vTask2 ( vo id ∗ param) {do_long_operation ( ) ;xTaskDelete (h)

}

RTOS-API

Control flow analysisControl flow analysis

RTOS mappingRTOS mapping

Value analysisValue analysis

Serial DMAISR

GPSThread

LoggingQueue

SD WriterThread

LEDThread

LockSemaphore

DisplayThread

SPI DMAISR

ButtonThread

EventsQueue

I2C DMAISR

sleep

sleep

wait

wakeup wait

wake

up

waitwakeup

lock

lock

put

get

put get

Instance graph

programmed against

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 13 – 21

Page 25: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

Instance Graph Creation

Instance creation in branch or loop?ARA marks them with “?”.

Instance creation before or after scheduler start?Before: Only runs once.After: Unknown number of runs.ARA sets “late” attribute.

main T1late: False

T2late: True

xTaskCreate xTaskCreate?

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Technique 14 – 21

Page 26: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

Agenda

MotivationTechniqueExperimentsConclusion

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Experiments 15 – 21

Page 27: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

Experiments

Show viability of approach.Tested with 4 real-world systems:

GPSLogger (FreeRTOS)SmartPlug1 (FreeRTOS)I4Copter with events (OSEK)I4Copter without events (OSEK)

Implemented three validation tests:FreeRTOS: Only ISR-capable system calls used in ISRs?OSEK: Does OIL-file match the source code?FreeRTOS/OSEK: Enter and exit of critical region always pairwise?

1https://github.com/KKoovalsky/SmartplugLUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Experiments 16 – 21

Page 28: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

SmartPlug

RTOS

MQTT

late: False

vTaskDelay

HTTPDaemon

late: False

configConnect

late: False

ulTaskNotifyTake

xTaskGetCurrentTaskHandle

xTaskCreate?

vTaskDelete

vTaskDelayvTaskDelete

PowerGet

late: True

xTaskCreate?

xConfiguratorQueue

late: False

vQueueDelete

vTaskDelayUntil

vTaskDelay

xMqttQueue

late: False

xQueueGenericSend

xQueueReceive

StartUp

late: False

vTaskDelayvTaskDelete

GatewayAddr

late: False

vTaskDelayvTaskDelete

Blink

late: False

vTaskDelay

PLCInit

late: False

vTaskDelayvTaskDelete

PLCRcv

late: False

ulTaskNotifyTakeRegis

late: TruexTaskCreate?

xQueueGenericSend

xPLCSendSemaphore

late: False

xQueueGenericSend

vTaskDelete

xQueueGenericSend

PLCSend

late: False

xQueueSemaphoreTake

ulTaskNotifyTake

xQueueGenericSendhostIntPinHandler

late: False

vTaskNotifyGiveFromISR

main

vTaskStartScheduler

xTaskCreate?

xTaskCreate?

xTaskCreate?

xQueueGenericCreate?

xTaskCreate?

xTaskCreate?

xTaskCreate

xTaskCreate

xTaskCreate

xQueueGenericCreate?

xQueueCreateMutex

xTaskCreate

xQueueReceive

RTOS

MQTT

late: False

vTaskDelay

HTTPDaemon

late: False

configConnect

late: False

ulTaskNotifyTake

xTaskGetCurrentTaskHandle

xTaskCreate?

vTaskDelete

vTaskDelayvTaskDelete

PowerGet

late: True

xTaskCreate?

xConfiguratorQueue

late: False

vQueueDelete

vTaskDelayUntil

vTaskDelay

xMqttQueue

late: False

xQueueGenericSend

xQueueReceive

StartUp

late: False

vTaskDelayvTaskDelete

GatewayAddr

late: False

vTaskDelayvTaskDelete

Blink

late: False

vTaskDelay

PLCInit

late: False

vTaskDelayvTaskDelete

PLCRcv

late: False

ulTaskNotifyTakeRegis

late: TruexTaskCreate?

xQueueGenericSend

xPLCSendSemaphore

late: False

xQueueGenericSend

vTaskDelete

xQueueGenericSend

PLCSend

late: False

xQueueSemaphoreTake

ulTaskNotifyTake

xQueueGenericSendhostIntPinHandler

late: False

vTaskNotifyGiveFromISR

main

vTaskStartScheduler

xTaskCreate?

xTaskCreate?

xTaskCreate?

xQueueGenericCreate?

xTaskCreate?

xTaskCreate?

xTaskCreate

xTaskCreate

xTaskCreate

xQueueGenericCreate?

xQueueCreateMutex

xTaskCreate

xQueueReceive

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Experiments 17 – 21

Page 29: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

SmartPlug

RTOS

MQTT

late: False

vTaskDelay

HTTPDaemon

late: False

configConnect

late: False

ulTaskNotifyTake

xTaskGetCurrentTaskHandle

xTaskCreate?

vTaskDelete

vTaskDelayvTaskDelete

PowerGet

late: True

xTaskCreate?

xConfiguratorQueue

late: False

vQueueDelete

vTaskDelayUntil

vTaskDelay

xMqttQueue

late: False

xQueueGenericSend

xQueueReceive

StartUp

late: False

vTaskDelayvTaskDelete

GatewayAddr

late: False

vTaskDelayvTaskDelete

Blink

late: False

vTaskDelay

PLCInit

late: False

vTaskDelayvTaskDelete

PLCRcv

late: False

ulTaskNotifyTakeRegis

late: TruexTaskCreate?

xQueueGenericSend

xPLCSendSemaphore

late: False

xQueueGenericSend

vTaskDelete

xQueueGenericSend

PLCSend

late: False

xQueueSemaphoreTake

ulTaskNotifyTake

xQueueGenericSendhostIntPinHandler

late: False

vTaskNotifyGiveFromISR

main

vTaskStartScheduler

xTaskCreate?

xTaskCreate?

xTaskCreate?

xQueueGenericCreate?

xTaskCreate?

xTaskCreate?

xTaskCreate

xTaskCreate

xTaskCreate

xQueueGenericCreate?

xQueueCreateMutex

xTaskCreate

xQueueReceive

RTOS

MQTT

late: False

vTaskDelay

HTTPDaemon

late: False

configConnect

late: False

ulTaskNotifyTake

xTaskGetCurrentTaskHandle

xTaskCreate?

vTaskDelete

vTaskDelayvTaskDelete

PowerGet

late: True

xTaskCreate?

xConfiguratorQueue

late: False

vQueueDelete

vTaskDelayUntil

vTaskDelay

xMqttQueue

late: False

xQueueGenericSend

xQueueReceive

StartUp

late: False

vTaskDelayvTaskDelete

GatewayAddr

late: False

vTaskDelayvTaskDelete

Blink

late: False

vTaskDelay

PLCInit

late: False

vTaskDelayvTaskDelete

PLCRcv

late: False

ulTaskNotifyTakeRegis

late: TruexTaskCreate?

xQueueGenericSend

xPLCSendSemaphore

late: False

xQueueGenericSend

vTaskDelete

xQueueGenericSend

PLCSend

late: False

xQueueSemaphoreTake

ulTaskNotifyTake

xQueueGenericSendhostIntPinHandler

late: False

vTaskNotifyGiveFromISR

main

vTaskStartScheduler

xTaskCreate?

xTaskCreate?

xTaskCreate?

xQueueGenericCreate?

xTaskCreate?

xTaskCreate?

xTaskCreate

xTaskCreate

xTaskCreate

xQueueGenericCreate?

xQueueCreateMutex

xTaskCreate

xQueueReceive

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Experiments 17 – 21

Page 30: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

GPSLogger

RTOS

SDThread

late: False

vTaskDelay

sdQueue

late: True

xQueueGenericCreate

xQueueReceive

LEDThread

late: False

vTaskDelay

DisplayTask

late: False

xGPSDataMutex

late: True

xQueueCreateMutex?

xQueueGenericSend

xQueueSemaphoreTake

GPSTask

late: FalsexQueueSemaphoreTake

ButtonsThread

late: False

vTaskDelaybuttonsQueue

late: FalsexQueueGenericSend

xQueueReceive

ulTaskNotifyTake

xTaskGetCurrentTaskHandle

xQueueGenericSend

xQueueCreateMutex?

xQueueGenericSendvTaskDelay

_ZN14SdFatSPIDriver22dmaTransferCompletedCBEv

late: False xQueueGiveFromISR

HAL_I2C_MemTxCpltCallback

late: False vTaskNotifyGiveFromISR

USART1_IRQHandler

late: False vTaskNotifyGiveFromISR

main

vTaskStartScheduler

xTaskCreate

xTaskCreate

xTaskCreate

xTaskCreate

xQueueGenericCreate

xTaskCreate

RTOS

SDThread

late: False

vTaskDelay

sdQueue

late: True

xQueueGenericCreate

xQueueReceive

LEDThread

late: False

vTaskDelay

DisplayTask

late: False

xGPSDataMutex

late: True

xQueueCreateMutex?

xQueueGenericSend

xQueueSemaphoreTake

GPSTask

late: FalsexQueueSemaphoreTake

ButtonsThread

late: False

vTaskDelaybuttonsQueue

late: FalsexQueueGenericSend

xQueueReceive

ulTaskNotifyTake

xTaskGetCurrentTaskHandle

xQueueGenericSend

xQueueCreateMutex?

xQueueGenericSendvTaskDelay

_ZN14SdFatSPIDriver22dmaTransferCompletedCBEv

late: False xQueueGiveFromISR

HAL_I2C_MemTxCpltCallback

late: False vTaskNotifyGiveFromISR

USART1_IRQHandler

late: False vTaskNotifyGiveFromISR

main

vTaskStartScheduler

xTaskCreate

xTaskCreate

xTaskCreate

xTaskCreate

xQueueGenericCreate

xTaskCreate

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Experiments 18 – 21

Page 31: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

GPSLogger

RTOS

SDThread

late: False

vTaskDelay

sdQueue

late: True

xQueueGenericCreate

xQueueReceive

LEDThread

late: False

vTaskDelay

DisplayTask

late: False

xGPSDataMutex

late: True

xQueueCreateMutex?

xQueueGenericSend

xQueueSemaphoreTake

GPSTask

late: FalsexQueueSemaphoreTake

ButtonsThread

late: False

vTaskDelaybuttonsQueue

late: FalsexQueueGenericSend

xQueueReceive

ulTaskNotifyTake

xTaskGetCurrentTaskHandle

xQueueGenericSend

xQueueCreateMutex?

xQueueGenericSendvTaskDelay

_ZN14SdFatSPIDriver22dmaTransferCompletedCBEv

late: False xQueueGiveFromISR

HAL_I2C_MemTxCpltCallback

late: False vTaskNotifyGiveFromISR

USART1_IRQHandler

late: False vTaskNotifyGiveFromISR

main

vTaskStartScheduler

xTaskCreate

xTaskCreate

xTaskCreate

xTaskCreate

xQueueGenericCreate

xTaskCreate

RTOS

SDThread

late: False

vTaskDelay

sdQueue

late: True

xQueueGenericCreate

xQueueReceive

LEDThread

late: False

vTaskDelay

DisplayTask

late: False

xGPSDataMutex

late: True

xQueueCreateMutex?

xQueueGenericSend

xQueueSemaphoreTake

GPSTask

late: FalsexQueueSemaphoreTake

ButtonsThread

late: False

vTaskDelaybuttonsQueue

late: FalsexQueueGenericSend

xQueueReceive

ulTaskNotifyTake

xTaskGetCurrentTaskHandle

xQueueGenericSend

xQueueCreateMutex?

xQueueGenericSendvTaskDelay

_ZN14SdFatSPIDriver22dmaTransferCompletedCBEv

late: False xQueueGiveFromISR

HAL_I2C_MemTxCpltCallback

late: False vTaskNotifyGiveFromISR

USART1_IRQHandler

late: False vTaskNotifyGiveFromISR

main

vTaskStartScheduler

xTaskCreate

xTaskCreate

xTaskCreate

xTaskCreate

xQueueGenericCreate

xTaskCreate

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Experiments 18 – 21

Page 32: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

Future Work

Build a global control flow graph (GCFG) [DHL17].Include scheduler decisions.

Improve value analysis.Alias analysis.Model ambiguous values.

Interactive graph browsing.Link source code and instance graph.

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Conclusion 19 – 21

Page 33: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

Conclusion

ARA2

Automatic extraction of an instance graph.Supports multiple RTOS interfaces.Show viability with 4 real-world applications.

Fields of use:Application architecture overview.Knowledge extraction for specialization.OS-API usage validation.

Thank you! Questions?

2https://github.com/luhsra/araLUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Conclusion 20 – 21

Page 34: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

Conclusion

ARA2

Automatic extraction of an instance graph.Supports multiple RTOS interfaces.Show viability with 4 real-world applications.

Fields of use:Application architecture overview.Knowledge extraction for specialization.OS-API usage validation.

Thank you! Questions?

2https://github.com/luhsra/araLUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Conclusion 20 – 21

Page 35: ARA: Automatic Instance-Level Analysis in Real-Time Systems · 2019. 7. 19. · ARA:AutomaticInstance-LevelAnalysis inReal-TimeSystems GerionEntrup,BenediktSteinmeier,ChristianDietrich

References I

Christian Dietrich, Martin Hoffmann, and Daniel Lohmann. “GlobalOptimization of Fixed-Priority Real-Time Systems by RTOS-AwareControl-Flow Analysis”. In: ACM Transactions on Embedded ComputingSystems 16.2 (2017), 35:1–35:25. doi: 10.1145/2950053.

LUH ARA: Automatic Instance-Level Analysis in Real-Time Systems – Conclusion 21 – 21


Recommended