Module 12 · Lesson 39 of 114

Execution management and machine states

Explain how Adaptive AUTOSAR Execution Management starts, stops, and recovers processes, and trace the machine transitions that determine which applications run.

  • Beginner to advanced
  • 9 min read
  • 13 min lab
What you will need

Familiarity with Adaptive AUTOSAR applications and deployment manifests. Ubuntu 24.04 in WSL2 or a VM for the written practice. No board or Adaptive runtime required.

Your place in the module
By the end you can 4 objectives
  • Distinguish State Management decisions from Execution Management actions.
  • Trace startup, normal operation, diagnostics, shutdown, and restart in an example machine.
  • Identify the process starts, stops, and startup dependencies for a transition.
  • Explain how numberOfRestartAttempts changes the outcome of a startup failure.
Video coming soonExecution management and machine states
The video for this lesson is being recorded. Read the lesson below in the meantime.
Recall first from The routing manager and comparing three layers
  • In the daemon deployment, routingmanagerd hosts the local routing manager and the provider runs the service implementation.
  • Same-host calls can succeed over local IPC without the method appearing in a network capture.
  • CommonAPI with its SOME/IP binding and the course ara-lite adapter both depend on vsomeip in the deployments discussed here.
01

What Execution Management controls

4 min read

The last lesson closed the communication stack. This lesson answers how the platform starts and stops applications and which machine states drive that.

Linux makes a distinction that matters during automotive startup. A successful execve() replaces a process's program image so the new program can begin executing. The program may still have to load configuration, open a device, and initialize the data other applications need. A consumer that starts too early can encounter an unavailable dependency even though the provider's program image loaded successfully. This is a real distinction between executing a program and completing its initialization. execve(2)

is usually abbreviated EM. Its application-facing interfaces are in the ara::exec namespace. The behavior described here follows the Execution Management specification of AUTOSAR Adaptive Platform R24-11 (the same release names the Startup, Shutdown and Restart states of the machine function group). EM knows which configured processes belong in the states it manages and which conditions constrain their startup. It uses operating-system facilities to realize the configuration. On a Linux-based machine, the operating system creates and schedules processes and delivers termination notifications. EM uses process lifecycle information to determine whether the requested configuration has been reached or whether execution has failed.

State Management supplies the operating decision during normal managed operation. The decision could be to enter a workshop mode or begin an orderly shutdown. Execution Management applies that decision to processes using the deployed configuration. Initial entry into Startup is a special case. EM initiates that startup as the platform comes up, so State Management itself can be brought into operation. Once State Management is available, it can request the configured transitions that follow.

Carrying out a requested transitionState ManagementExecutionManagementOperating systemRequest target stateStart or stopReport process exitReturn transitionresult1. State Management →Execution ManagementRequest target state2. Execution Management →Operating systemStart or stop3. Operating system →Execution ManagementReport process exit4. Execution Management →State ManagementReturn transition result
State Management requests a transition, and Execution Management applies the process changes using the operating system.

Consider an illustrative machine that reads environmental sensors. Its deployed configuration specifies a device initializer, a sensor publisher, and a workshop tool. One rule says that the publisher requires the initializer to complete startup first. Another says that the workshop tool belongs in Diagnostic. Those rules answer different questions. The dependency determines when the publisher may start. State membership determines whether the workshop tool should be running at all in the requested mode.

Deterministic startup means that EM enforces the configured dependency constraints. If the publisher's configured prerequisite is the initialized device process, every successful startup must satisfy that prerequisite before EM starts the publisher. The elapsed time can vary because device initialization and operating-system scheduling can take different amounts of time on different boots. Independent processes may be eligible to start concurrently. A repeatable dependency order therefore gives an engineer a concrete property to check even when the exact order of unrelated events varies between boots.

The same configuration can call for a process to remain active across a transition. If the device initializer is configured to stay active in both Running and Diagnostic, a change from one to the other can leave it active, stop the publisher if it is specific to Running, and start the workshop tool. A state transition has a target set of processes and conditions for reaching it. Existing processes that satisfy the target configuration can help the machine reach that state without starting their executables again.

02

Machine states and their transitions

4 min read

A describes the machine's intended operation. Adaptive AUTOSAR models machine-wide lifecycle states through the Machine State Function Group. Startup, Shutdown, and Restart have defined lifecycle roles in that model. The example below uses Running and Diagnostic as project-configured operating states. It uses Off to show the stopped machine outside active EM operation. The labels and permitted operating transitions for a real machine come from its integration configuration.

Example machine lifecycleOffStartupRunningDiagnosticShutdownRestartTransitionsBootOffStartupEnter normal operationStartupRunningEnter workshop modeRunningDiagnosticResume normal operationDiagnosticRunningRequest shutdownRunningShutdownRequest shutdownDiagnosticShutdownPlatform stopsShutdownOffRequest rebootRunningRestartPlatform rebootsRestartStartupOffStartupRunningDiagnosticShutdownRestartTransitionsBootOffStartupEnter normal operationStartupRunningEnter workshop modeRunningDiagnosticResume normal operationDiagnosticRunningRequest shutdownRunningShutdownRequest shutdownDiagnosticShutdownPlatform stopsShutdownOffRequest rebootRunningRestartPlatform rebootsRestartStartup
An example machine enters Startup on boot, can switch between Running and Diagnostic, and leaves operation through Shutdown or Restart.
State or condition What it means in this example
Startup EM starts the configured initial processes, including the platform software required to proceed with managed operation.
Running The machine provides its normal functions. The sensor publisher is enabled for normal operation.
Diagnostic The machine provides the configured workshop functions. The workshop tool runs, and the normal publisher stops in this example.
Shutdown The machine is preparing to stop. EM performs the configured termination work and the platform proceeds toward shutdown.
Restart The machine is preparing to reboot. EM performs the configured termination work and the platform proceeds toward a new boot and Startup.
Off The machine has stopped executing. EM carries out lifecycle work again after a wake or power-on event starts a boot.

At power-on, the platform brings up the operating system and starts EM. Startup is the first active lifecycle state in this example. During Startup, EM starts the configured initial software and respects its dependencies. Once the required startup conditions are satisfied, State Management can request Running according to the machine's policy. Entering Running can itself require more process starts. Here the initializer is already active and the publisher starts as the machine enters normal operation.

A workshop request can cause policy to select Diagnostic from Running. The transition makes diagnostics available in the way the integrator specified. In this configuration, the initializer stays active because both modes require the hardware it manages. The publisher stops and the workshop tool starts. A permitted return to Running reverses those changes for the two mode-specific processes. A different machine could keep its publisher active during diagnostics. The name Diagnostic alone gives an engineer insufficient information to predict which processes change. The deployed configuration gives the answer.

A shutdown request can also arrive while the workshop tool is active. In the example, policy can select Shutdown directly from Diagnostic. EM then stops the processes required by the shutdown configuration. The platform completes its own shutdown and the diagram reaches Off. That last step describes what happens to the machine after shutdown. Once the local machine has stopped, there is no local EM process executing. A wake controller or other platform logic can initiate the next boot. Which electronics stay powered while the Adaptive machine is stopped depends on the hardware integration.

Restart has a different destination. For example, after a permitted restart request during Running, the platform prepares for reboot and the next boot enters Startup. Initialization happens again under the startup rules. On Linux, reboot and power-off are distinct operations available to privileged software through the operating system. That distinction supports the two different endings in the diagram. The details of requesting a reset or removing power belong to the platform integration. reboot(2)

When reading a transition record, look for the requested target and whether the process changes required for it completed. A request for Diagnostic expresses the intended mode. Confirmation requires evidence that the transition completed, including the configured process changes. Likewise, Startup followed by a request for Running tells you what the platform attempted. If a required process failed to start, the request alone gives you insufficient evidence that normal operation was reached.

03

What happens when execution fails

3 min read

A process can exit unexpectedly while its state still requires it. For example, if the publisher crashes during Running, normal operation still calls for a publisher, and the crash has left that requirement unsatisfied. In the R24-11 specification (requirement SWS_EM_01309), an unexpected termination outside a state transition makes EM log the event if logging is activated, set the Function Group State of the affected group to the Undefined Function Group State, and call the undefinedStateCallback that State Management registered on its ara::exec::StateClient, passing an ExecutionErrorEvent. EM does not choose the recovery in that case. A process intentionally stopped during a transition has a different meaning. If the publisher stops as requested on entry to Diagnostic, its exit is evidence of the requested change.

On Linux, a parent that waits for a child can obtain status indicating whether the child exited normally or was terminated by a signal. This status provides evidence about termination. The lifecycle manager also needs context about what it asked the process to do. An exit status by itself cannot establish that a process was expected to remain active, that the process satisfied a startup condition before it exited, or that launching a fresh instance would be appropriate. wait(2)

Handling a start-up timeoutStart-uptimeoutCheck numberOfRestartAttemptsRelaunchprocessCheckstartupoutcomeExit from step 2: No attempts leftReport to State ManagementStart-uptimeoutCheck numberOfRestartAttemptsExit from step 2: No attemptsleftReport to State ManagementRelaunchprocessCheckstartupoutcome
On a start-up timeout EM relaunches the process up to numberOfRestartAttempts times, then reports the failure to State Management.
Going deeperCrash handling, start-up timeouts and restart attempts

After an unexpected termination the Function Group is in the Undefined Function Group State and State Management has been notified. State Management then decides how to proceed, for example by requesting a defined state for that group. EM does not relaunch a crashed process on its own during Running. This differs from entering the machine state Restart, which leads to a reboot and a new Startup.

Startup failures have their own rule. EM monitors the time each process needs to start. The start-up timeout is configured in the Execution Manifest (StartupConfig.timeout). When it expires, EM attempts to restart the process up to numberOfRestartAttempts times (SWS_EM_02260). The attribute counts extra attempts: absent or 0 means the process is started once, and 1 means it is started a second time if the start fails. Because EM assumes a process that missed its timeout is in an erroneous state, it asks the operating system to terminate it (for example with SIGKILL) instead of sending SIGTERM. A restart attempt does not fulfill any dependency that waits for a termination.

When the attempts are used up, EM requests the operating system to terminate the process, stops the Function Group State transition, sets the current state to Undefined, makes StateClient::SetState report kOperationFailed, and makes the configured execution error available through StateClient::GetExecutionError (SWS_EM_02259 and SWS_EM_02310). The dependent publisher stays unstarted, because its prerequisite was never satisfied. What happens next is State Management's decision. Requesting another state, or Restart or Shutdown of the machine, are possible policy choices. A persistent startup failure can recur after a reboot, so a machine restart has its own consequences. If essential management software fails before the normal decision path is available, the platform integration needs a recovery path that works during early startup as well.

Take the same publisher exit and place it first in Running and then during the transition to Diagnostic. In Running, the intended process set still includes the publisher. During an intentional stop on entry to Diagnostic, the intended set excludes it. That comparison identifies why a useful execution record needs the target state and the lifecycle action alongside the observed exit. It also explains why diagnosis starts with two questions: which processes did the machine need, and what happened when EM tried to establish that configuration?

The next lesson, Function groups and process states, explains how the machine can manage subsets of applications and describe each process's progress through its own lifecycle.

Key takeaways

  • Execution Management starts and stops configured processes to carry out state transitions.
  • Deterministic startup preserves configured dependencies even when launch timing varies.
  • Startup, Shutdown, and Restart have defined machine lifecycle roles. Running and Diagnostic are example operating modes, and Off depicts the stopped machine.
  • A start-up timeout leads to bounded restart attempts, an unexpected termination is reported to State Management as an undefined state, and a machine Restart initiates a new startup sequence.
Reflect
  1. Explain to a colleague, in two sentences: distinguish State Management decisions from Execution Management actions.
  2. Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
  3. What surprised you when you ran the commands yourself?
On a real board

Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.

References and further reading

Find your next step

↑ ↓ to move · Enter to open · Esc to close