1 / 28

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

Access Point Event Simulator (APES) for Legacy Software Systems (LESS). Stefan Resmerita Joint work with Patricia Derler and Edward Lee February 17, 2009. Contents. Goals and motivation Approach Ptolemy II components Further work Demos. Contents. Main Goals. Short-term:

keisha
Download Presentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Access Point Event Simulator (APES) for Legacy Software Systems (LESS) Stefan Resmerita Joint work with Patricia Derler and Edward Lee February 17, 2009

  2. Contents • Goals and motivation • Approach • Ptolemy II components • Further work • Demos Contents 2

  3. Main Goals • Short-term: • Simulate (on a host computer) execution of embedded software written in C for OSEK-compliant OS and given platform model • Achieve fast Software-in-the-Loop testing • Medium to long term: • Enable modeling of legacy applications • Apply MBD principles to legacy software Goals and Motivation 3

  4. Software in the Loop Testing Plant Model User Input Actuator models Sensor Models Simulation of original application code + Error – Simulation of modified application code Goals and Motivation 4

  5. Simulation write(angle) read(angle) S-function dC mC time Execution on the ECU preemption read(angle) write(angle) dC mC time Classical Problem MotorController.c void mC_step() { … read(angle); … } Memory … 0023456 12 0023457 0 0023459 6 0023460 23 0023461 0 0023463 0 … DynamicsController.c void dC_step() { … write(angle); … } Goals and Motivation 5

  6. 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 Approach 6

  7. Request Response Model Structure • Functionality actors • OSEK actors • Actor execution • Actor interaction • Java-C bridge Ptolemy II components 7

  8. void dC_step() { … angle = t1*s1; … } void mC_step() { … tmp_a = angle; … } void dC_step() { … SendMessage(m_a, angle); … } void mC_step() { … ReceiveMessage(m_a,angle); … } void appDispatcher(){ while (appRunning){ WaitEvent(appDispatcherEvent); ClearEvent(appDispatcherEvent); if(simStep%5 == 0){ ActivateTask(dC_Task); } SetEvent(mC_Task, mC_Event); simStep++; } TerminateTask(); } 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 Approach 8

  9. T2 T1 t1 t2 t2 + 2 t1 + 1 + 2 activate(T1) activate(T2)AGET2AGET1 APET1(1)APET2(2)terminate(T2)APET(1’) Execution Control at Access Points • Insert a callback to the simulation engine at every access point • Determine the execution time since the previous APE • Send the timestamped APE to the task scheduler • Pause the execution of the task • The task scheduler generates an Access Granted Event (AGE) • The execution of the task is resumed upon receiving the AGE Approach 9

  10. CCodeLibrary MotorController.c void mC_step() { … aPCallback(12); tmp_angle = angle; … … aPCallback(42); WaitEvent(evMask); … } 2. start 6. resume 3. callback (stop) 1. Trigger 5. AGE 4. APE a. system call b. change task state, reschedule Example CTask.java Thread cCodeThread; void fire() { notify(); } void aPCallback(time) { requestExecTime(time); sleep(); } Approach 10

  11. Functionality Actor: CTask • Executes a C function mapped to an OSEK task in a dedicated thread • Implements two callback methods: • accessPointCallback(executionTime, minimumDelay); • before every access point where no monitoring is needed • accessPointCallback(executionTime, minimumDelay, varName, value); • Inserted in the C code after the line where varName is updated • Parameters: • The name of a C function mapped to an OSEK task • The priority of the task • Ports: • Multicast output port, used to send APEs • Multicast input port, used to receive AGEs • Regular I/O ports for global variables Ptolemy II components 11

  12. APE1 t1 + 1 CT1 callback(t1) Generate APE1 withtimestamp t1 + 1 1 Process ev3 Process ev1 Trigger task 1 Wake up threadof C task 1 (CT1) Process ev2 Multithreaded DE Simulation: Problem ev1 ev2 ev3 t2 t3 model time t1 CT2 CT1 real time Ptolemy II components 12

  13. APE1 ev´1 t1 + 1 t1 + 1 CT1 callback(1, 2) Resume DE thread Suspend C thread 1, 1 ProcessAPE1 Process ev1 Trigger task 1 Wake up threadof C task 1 (CT1) Ask to be re-fired at t1 + 1 Process ev2 Process ev´1 Suspend execution of DE thread Multithreaded DE Simulation: Solution ev1 ev2 ev3 t2 t3 model time t1 CT2 CT1 real time Generate APE1 Finish ev´1 processing Ptolemy II components 13

  14. ready event/resource received trigger waiting suspended AGE preemption termiate task wait for event resource blocked running OSEK Actor: TaskScheduler • Fixed priority preemptive scheduling • Receives APEs from CTask actors • Maintains task status information • Implements task system services • ActivateTask, TerminateTask • Receives task status notifications from other OSEK actors • Sends AGEs to functionality actors Ptolemy II components 14

  15. OSEK Actor: EventManager • Implements event OSEK services • SendEvent • GetEvent • ClearEvent • Notifies the TaskScheduler to change task status • If a task needs to wait for an event • If a waiting task receives an event Ptolemy II components 15

  16. Source (sensor) Actor: FormattedLineReader • Reads data from an input file • At each iteration, data from one line is send to the output ports • Assumes input text in tabular format • A column is a sampled signal • A line contains the values of all signals at a sample time • Maps port names and types to named columns • Buffered reading • All the file is processed at initialization, when all tokens are created and stored in memory Ptolemy II components 16

  17. Infrastructure Element: MultiCastIOPort • Provides line-free connectivity between actors • Output port: • Destination actors are specified at runtime in each send action • Static filter for eligible destinations given as a parameter • Input: • Static filter for source actors specified as a parameter • Can help in modeling service oriented applications Ptolemy II components 17

  18. Monitoring • Task execution: Visualization of task states in time • Global variables Ptolemy II components 18

  19. Java-C bridge • Java classes • OSEKEntryPoint: Receives all system calls from C tasks and routes them to the appropriate OSEK actors • AccessPointCallbackDispatcher: Routes the callbacks from C to the appropriate functionality actors • C wrapping code • APES layer • OS layer • Application layer Ptolemy II components 19

  20. Next Steps: 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 Further work 20

  21. 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 Further work 21

  22. Modeling of Legacy Applications • Task Model • Functional Model • Timing Model • Modal Model Further work 22

  23. Demos: Active Rear Steering Control • Simulink model: Demos 23

  24. Demo 1: Building a Basic APES model • 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 Demos 24

  25. The ARS Model for Demo 1 25

  26. Demo 2: APES model with plant actor in C • 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 plant is wrapped in an EmbeddedCActor • Connections are needed between controllers and their environment Demos 26

  27. The ARS Model for Demo 2 Demos 27

  28. Thank you for your attention!

More Related