30
Access Point Event Simulator (APES) for Legacy Software Systems (LESS) Patricia Derler and Stefan Resmerita University of Salzburg, Austria

Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Access Point Event Simulator (APES) for Legacy Software Systems (LESS)

Patricia Derler and Stefan Resmerita University of Salzburg, Austria

Page 2: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 2 November 4, 2009

Contents

  Goals and Motivation

  Approach

  Examples of APES Models

  Future Work

  Conclusions

Page 3: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 3 November 4, 2009

APES-LESS: Goals and Motivation

Page 4: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 4 November 4, 2009

Main Goals

  Short-term:   Simulate (on a host computer) execution of embedded

software written in C for a given operating system and a given hardware platform model

  Achieve fast Software-in-the-Loop testing

Plant Model

Actuator models Sensor Models

Application code

User Input e.g. model of an engine

e.g. engine control software

Page 5: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 5 November 4, 2009

Main Goals

  Medium to long term:   Enable modeling of legacy applications   Apply Model Based Design principles to legacy software

Plant Model

Actuator models Sensor Models

Simulation of original application code

Simulation of modified application code

+

User Input

Error

Page 6: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 6 November 4, 2009

The Need to Simulate the Effects of Execution Times and Preemption

write(angle)

dC mC

time

Simulation in Simulink read(angle)

dC_step mC_step

time

Execution on the ECU

preemption

MotorController.c void mC_step() { … read(angle); …

} //high priority

DynamicsController.c void dC_step() { … write(angle); …

} //low priority

0023456 12

0023457 0

0023459 6

0023460 23

0023461 0

0023463 0

Memory

read(angle) write(angle)

Page 7: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 7 November 4, 2009

APES-LESS: Approach

Page 8: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 8 November 4, 2009

Ptolemy II

  Simulation environment for heterogeneous systems   Developed at UC Berkeley   Actor-oriented design   Explicit support for models of computation, e.g.

discrete event, continuous time, synchronous dataflow, process network, …

local director

port

external port

actor

Page 9: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 9 November 4, 2009

Simulation Engine Based on Ptolemy II

  Fast prototyping   Discrete event simulation   Java threads

  Component-based design   Visual modeling   Portability   Enables execution of legacy code under different

models of computation

Page 10: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 10 November 4, 2009

APES Model Structure for OSEK OS

Request

Response

  1 Thread for simulation engine

  Each application functionality actor runs in a separate thread

  Java threads are used for simulating task context switches

execution control of legacy code

implementation of operating system services

Input/Output actors

Executes actors by processing events on a common timeline

event-based communication

protocol

DE Director

Page 11: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 11 November 4, 2009

Event-Based Approach

Access Point Event (APE) • An access point is a line of source code with an I/O

access or a system call • In a run of the software, an access point event occurs

whenever the code of an access point starts executing

void dC_step() { … angle = t1*s1; …

}

void appDispatcher(){ while (appRunning){ WaitEvent(aDispEvent); ... } }

Page 12: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 12 November 4, 2009

Execution Control at Access Points

void dC_step() { … aPCallback(t1); angle = t1*s1; … aPCallback(t2); v = speed; …

}

t2

  Send the timestamped APE to the task scheduler and pause the execution   The task scheduler generates an Access Granted Event (AGE)   The execution of the task is resumed upon receiving the AGE

t1

  Insert a callback to the simulation engine at every access point   Determine the execution time since

the previous APE

Page 13: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 13 November 4, 2009

Example: Simulating Preemption

activate(T1) activate(T2) AGET2 AGET

1

APET1(Δ1) APET

2(Δ2) terminate(T2) APET(Δ1’)

T2

τ1 τ2 τ 2+Δ2 τ1+Δ1+Δ2

  Two tasks: T1 and T2   T2 has higher priority   T1 is triggered at time τ1   T2 is triggered at time τ2   Δ2 is the execution time

of T2   Δ1 is the execution time of T1 from the beginning until

its first access point is reached   Assume τ2 < τ1 + Δ1

T1

Page 14: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 14 November 4, 2009

Example: Execution Control in APES

MotorController.c

void mC_step() { … aPCallback(12); tmp_angle = angle; … … aPCallback(42); WaitEvent(evMask); …

}

Thread cCodeThread;

void fire() { notify();

}

void aPCallback(time) { requestExecTime(time); sleep();

}

CTask.java

2. start

6. resume

b. change task state, reschedule

•CCodeLibrary

Page 15: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 15 November 4, 2009

Example: Execution Control in APES

  Sends APEs and receives AGEs   Implements callback methods

  Fixed priority preemptive scheduling

  Maintains task status information   Implements task system services   Communicates with CTask actors   Receives task status notifications

from other OSEK actors

ready

running

waiting suspended AG

E

preemption

Task states

Page 16: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 16 November 4, 2009

APES Monitoring

  Task execution: Visualization of task states in time

  Global variables

Page 17: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 17 November 4, 2009

APES-LESS: Examples of APES Models

Page 18: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 18 November 4, 2009

Active Rear Steering Control (ARS): A Simulink Model

Page 19: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 19 November 4, 2009

Example 1: A Basic APES Model for ARS

  C code is generated from the Simulink model for each of the three subsystems

  Both controllers and the plant model are compiled in the same native library

  Input is read in the C part from a file   CTask actors are used only for execution control   No connections necessary at the Ptolemy level

Page 20: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 20 November 4, 2009

The Basic APES Model for the ARS Code

Page 21: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 21 November 4, 2009

Example 2: Another APES Model for the ARS Legacy Code

  The two controllers are compiled in the same native library

  Speed input is provided by a Ptolemy DE actor, and front angle input from a file at the Ptolemy level

  The code of the plant model is wrapped in an EmbeddedCActor

  Connections are needed between controllers and their environment

Page 22: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 22 November 4, 2009

The Second APES Model for the ARS Code

Page 23: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 23 November 4, 2009

APES-LESS: Future Work

Page 24: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 24 November 4, 2009

Work in Progress: The Simulator

  Methods   Refine source line granularity   Adapt and use existing methods for estimation of

execution time   Automatization tools

  Code instrumentation   Generation of the APES model

  Visualization tools   Performance evaluation

Page 25: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 25 November 4, 2009

Next Steps I: Application Performance Evaluation

  Simulation of closed-loop control applications   Bridging different simulation environments   Tool support

  Testing with code coverage

  Stability analysis/validation with regard to execution times

Page 26: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 26 November 4, 2009

Next Steps II: High Level Models of Legacy Applications

  Task Model

  Functional Model

  Timing Model

  Modal Model

Page 27: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 27 November 4, 2009

Further Applications

  Comparing methods for execution time estimation

  Experimenting with   Control systems with timing compensation schemes   Dynamic scheduling

Page 28: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 28 November 4, 2009

APES-LESS: Conclusions

Page 29: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 29 November 4, 2009

Summary I

  In APES, legacy code is executed in a manner closer to an actual implementation on a given platform

  APES provides an experimental platform for a variety of development activities for legacy code, such as:   Software-in-the-Loop testing of control systems   Time-related application performance evaluation

  APES can be used as testing tool in the design of:   Execution-aware controllers   Control-aware scheduling

Page 30: Access Point Event Simulator (APES) for Legacy Software ... · 6. resume b. change task state, reschedule •CCodeLibrary . November 4, 2009 Derler 15 Example: Execution Control in

Derler 30 November 4, 2009

Summary II

  APES offers a bottom-up approach for modeling legacy code applications

  The basic elements of APES for OSEK have been developed

  There is still significant work to do, especially related to leveraging existing methods for estimation of execution times