execution management module
Feature - Process Lifecycle Management
EM包括一个客户的daemon进程和若干客户端libraries 每个进程启动时,关联到若干个功能组状态(“或关系”)和若干依赖("与"关系),可配置参数和环境变量 状态切换,未关联到指定状态的进程会终止,关联的进程根据依赖启动 EM的进程进程状态: Idle->Starting->Running->Terminating->Terminated 每个进行执行状态: Initializng->Running->Terminating 上下电时序:
进程上电时序:
OS启动EM daemon, 后者将MachineFG切换到Startup状态 根据execution manifest配置的依赖关系,依次启动关联到对应状态的所有进程,将其进程状态修改为Starting, 并启动超时监控 进程启动成功后,使用ExecutionClient API报告其执行状态Running给EM。超时未报,EM强行终止进程。 进程下电时序:
EM daemon发送SIGTERM给进程,将进程状态修改为Terminating,并启动超时监控。 进程执行终止,通过ExecutionClient API将terminating状态返回给EM。进程超时未终止,EM强行终止该进程。
Feature - State Management
SM为自定义进程,通过StateClient API控制功能组状态 状态切换失败,会进入未定义功能组状态 MachineFG包括如下强制状态: Startup,Shutdown, Restart, SafeState 每个进程是一个StateClient SetState是一个慢服务(异步服务),返回值为ara::core::Future类型,可通过ara::core::Future::GetResult()获取结果,或者通过is_ready()轮询,或者通过then()定义异步callback GetState询问EM的一个功能组状态,返回值为异步的ara::core::Future
EM
SM
APP1
APP2
setState(machineFG, stateXZY)
SIGTERM
ExecutionClient::ReportExecutionState(kTerminating)
waitForTermination(APP)
CreateProcess(SM)
ExecutionClient::ReportExecutionState(kRunning)
kSuccess
EM
SM
APP1
APP2
Feature - State Management
EM daemon通过API通知PHM进程状态和功能组状态变更 PHM检测到错误后通过进程监控API请求重启进程或者SafeState 详见PHM
Feature - Resource Limitation
资源配置
RAM(code,data,heap,thread stacks) CPU time(deadline) 绑定核 调度策略(进程的首个线程, 运行时可更改线程调度策略): SCHED_FIFO/RR/OTHER 资源监控
OS PHM,定义恢复行为(PHM报告异常给SM,并启动恢复行为)
Feature - No-Reporting & Companion Process
非上报进程(开源/第三方)上电后自动设置为Running 通过伙伴进程监控和报告非上报进程的状态,确保非上报进程的可用性
EM
companion-process
no-reporting-process
spawn
spawn
check availability
report running
EM
companion-process
no-reporting-process
interaction
API
SetState(SM->EM) ReportExecutionState(AA->EM) Initialize, Deinitialize(AA->CORE) Logger(AA->LOG)
---
title: interaction
---
stateDiagram-v2
state "Log and Trace" as a1
state "Logger(interface)" as a2
state "AAs" as a3
state "ExecutionClient(interface)" as e1
state "Execution Management" as e2
state "Core" as c1
state "Initialize(interface)" as c2
state "Deintialize(interface)" as c3
state "state-mgr" as s1
state "StateClient(interface)" as s2
a2 --> a1
c2 --> c1
c3 --> c1
e1 --> e2
s2 --> e2
a3 --> a2
a3 --> e1
a3 --> c2
a3 --> c3
s1 --> a2
s1 --> c2
s1 --> c3
s1 --> s2
s1 --> e1