Home Learning Paths ECU Lab Assessments Interview Preparation Arena Pricing Log In Sign Up

Automotive Task Timing Model

AUTOSAR Task Activation and Response Time
  Periodic task (T=10ms):
  ─────────────────────────────────────────────────────
  t=0ms:   Alarm fires → task READY
  t=0.1ms: OS schedules task (context switch delay)
  t=0.1ms–7.8ms: Task RUNNING (includes blocking from higher-priority preemption)
  t=7.8ms: TerminateTask → SUSPENDED

  Timing parameters (AUTOSAR TIMEX / SymTA/S model):
  ┌────────────────────────────────────────────────────┐
  │ BCET (Best-Case Execution Time):  2.1 ms           │
  │ WCET (Worst-Case Execution Time): 8.3 ms           │
  │ Period:                           10.0 ms          │
  │ Response-time budget:             10.0 ms          │
  │ CPU load contribution:            WCET/Period=83%  │
  └────────────────────────────────────────────────────┘
  WCET > Period → guaranteed timing violation → safety violation for ASIL tasks

TRACE32 Timing Charts

CMMtiming_chart.cmm
// Generate task timing chart from ETM trace

// Prerequisites: ETM trace captured (see hardware-trace-etm-mcds)

// Task timing chart: shows task activation, run, preemption, completion
Trace.Chart.TASK            // timeline: each task = a row; colour = state

// Zoom to a specific time window showing a 10ms task overrun
Trace.Chart.TASK /ZOOM 49.5ms 52.5ms    // 3ms window around suspected overrun

// Measure a specific task's execution time between trace markers
// Use TRACE32 'Trace.Find' to locate task entry/exit points

// Export timing data for AUTOSAR timing analysis tools (SymTA/S, Timing Designer)
// TRACE32 can export in AUTOSAR TIMEX format for tool import
Trace.SAVE.TASK timing_export.timex

// Oscilloscope-style view: trigger waveforms
// Show ISR arrivals + task activations on a time axis
Trace.Chart.Signal /VCD timing_signals.vcd   // export VCD for GTKWave

// Statistical timing analysis across 1000 task activations:
LOCAL &i &max_us
&max_us=0.
// Iterate Trace.Find results counting execution durations
Trace.Statistics.TASK "OsTask_10ms"   // min/avg/max execution time

Worst-Case Execution Time Analysis

MethodToolNotes
Measurement-based WCETTRACE32 + STM + ETMMeasures observed max; may miss rare worst-case paths; fast
Static WCET (IPET)AbsInt aiT, Rapita RapiTimeFormal proof of WCET; considers all paths + cache behaviour; required for ASIL D
Hybrid: measure + annotationRapita RVSETM coverage proves path taken; static analysis fills unmeasured branches
WCET test vectorsManual or generatedExercise all branches including error paths, cold cache, boundary conditions

⚠️ Cache Invalidation on WCET Measurement

WCET measurements must account for cache cold-start: the first execution after a task context switch may experience cache misses that normal runs avoid. ASIL C/D WCET measurement protocols require cache flushing before each timing measurement run to ensure consistent worst-case conditions. Measuring with a warm cache gives optimistic results that do not reflect the true WCET. aiT and similar tools model the cache state explicitly to produce a correct static WCET.

Runtime Timing Violation Detection

Ctiming_monitor.c
/* Runtime timing violation monitoring using AUTOSAR OS ProtectionHook */
#include "Os.h"
#include "Dem.h"
#include 

/* Timing budget per task in STM ticks (300 ticks = 1µs) */
#define TASK_10MS_BUDGET_TICKS  (9500u * 300u)  /* 9.5ms budget; 0.5ms margin */

static uint32_t g_task10ms_start;

void Os_PreTaskHook(void) {
    if (GetTaskID() == OsTask_10ms_id) {
        g_task10ms_start = (uint32_t)MODULE_STM0.TIM0.U;
    }
}

void Os_PostTaskHook(void) {
    if (GetTaskID() == OsTask_10ms_id) {
        uint32_t elapsed = (uint32_t)MODULE_STM0.TIM0.U - g_task10ms_start;
        if (elapsed > TASK_10MS_BUDGET_TICKS) {
            /* Report timing violation as DEM event */
            Dem_ReportErrorStatus(DEM_EVENT_TASK_10MS_TIMING_VIOLATION,
                                  DEM_EVENT_STATUS_FAILED);
            /* Log worst-case for post-investigation */
            if (elapsed > g_task10ms_wcet_observed) {
                g_task10ms_wcet_observed = elapsed;
            }
        }
    }
}

Summary

The AUTOSAR timing model formalises BCET/WCET/period parameters; WCET > period is a guaranteed violation. TRACE32 timing charts derived from ETM trace provide sub-microsecond resolution task-level timelines — sufficient to identify preemption patterns, ISR storms, and individual overruns visually. For ASIL C/D certification, measurement-based WCET must be supplemented with static analysis (aiT/RapiTime) that covers all execution paths and cache states. Runtime monitoring via OS hooks with STM timestamps provides continuous production monitoring at near-zero overhead.

🔬 Deep Dive — Core Concepts Expanded

This section builds on the foundational concepts covered above with additional technical depth, edge cases, and configuration nuances that separate competent engineers from experts. When working on production ECU projects, the details covered here are the ones most commonly responsible for integration delays and late-phase defects.

Key principles to reinforce:

  • Configuration over coding: In AUTOSAR and automotive middleware environments, correctness is largely determined by ARXML configuration, not application code. A correctly implemented algorithm can produce wrong results due to a single misconfigured parameter.
  • Traceability as a first-class concern: Every configuration decision should be traceable to a requirement, safety goal, or architecture decision. Undocumented configuration choices are a common source of regression defects when ECUs are updated.
  • Cross-module dependencies: In tightly integrated automotive software stacks, changing one module's configuration often requires corresponding updates in dependent modules. Always perform a dependency impact analysis before submitting configuration changes.

🏭 How This Topic Appears in Production Projects

  • Project integration phase: The concepts covered in this lesson are most commonly encountered during ECU integration testing — when multiple software components from different teams are combined for the first time. Issues that were invisible in unit tests frequently surface at this stage.
  • Supplier/OEM interface: This is a topic that frequently appears in technical discussions between Tier-1 ECU suppliers and OEM system integrators. Engineers who can speak fluently about these details earn credibility and are often brought into critical design review meetings.
  • Automotive tool ecosystem: Vector CANoe/CANalyzer, dSPACE tools, and ETAS INCA are the standard tools used to validate and measure the correct behaviour of the systems described in this lesson. Familiarity with these tools alongside the conceptual knowledge dramatically accelerates debugging in real projects.

⚠️ Common Mistakes and How to Avoid Them

  1. Assuming default configuration is correct: Automotive software tools ship with default configurations that are designed to compile and link, not to meet project-specific requirements. Every configuration parameter needs to be consciously set. 'It compiled' is not the same as 'it is correctly configured'.
  2. Skipping documentation of configuration rationale: In a 3-year ECU project with team turnover, undocumented configuration choices become tribal knowledge that disappears when engineers leave. Document why a parameter is set to a specific value, not just what it is set to.
  3. Testing only the happy path: Automotive ECUs must behave correctly under fault conditions, voltage variations, and communication errors. Always test the error handling paths as rigorously as the nominal operation. Many production escapes originate in untested error branches.
  4. Version mismatches between teams: In a multi-team project, the BSW team, SWC team, and system integration team may use different versions of the same ARXML file. Version management of all ARXML files in a shared repository is mandatory, not optional.

📊 Industry Note

Engineers who master both the theoretical concepts and the practical toolchain skills covered in this course are among the most sought-after professionals in the automotive software industry. The combination of AUTOSAR standards knowledge, safety engineering understanding, and hands-on configuration experience commands premium salaries at OEMs and Tier-1 suppliers globally.

← PreviousRuntime Measurement & ProfilingNext →Cache & Pipeline Analysis