State machines are used ubiquitously in engineering software-intensive systems. UML State Machines extend simple finite state machines with powerful constructs. Among the many extensions, there is one seemingly simple and innocent language construct that fundamentally changes state machines' reactive model of computation: doActivity behaviors. DoActivity behaviors describe behavior that is executed independently from the state machine once entered in a given state, typically modeling complex computation or communication as background tasks. However, the UML specification or textbooks are vague about how the doActivity behavior construct should be appropriately used. This lack of guidance is a severe issue as, when improperly used, doActivities can cause concurrent, non-deterministic bugs that are especially challenging to find and could ruin a seemingly correct software design. The Precise Semantics of UML State Machines (PSSM) specification introduced detailed operational semantics for state machines. To the best of our knowledge, there is no rigorous review yet of doActivity's semantics as specified in PSSM. We analyzed the semantics by collecting evidence from cross-checking the text of the specification, its semantic model and executable test cases, and the simulators supporting PSSM. We synthesized insights about subtle details and emergent behaviors relevant to tool developers and advanced modelers. We reported inconsistencies and missing clarifications in more than 20 issues to the standardization committee. Based on these insights, we studied 11 patterns for doActivities detailing the consequences of using a doActivity in a given situation and discussing countermeasures or alternative design choices. We hope that our analysis of the semantics and the patterns help vendors develop conformant simulators or verification tools and engineers design better state machine models.
翻译:状态机广泛应用于工程化软件密集型系统中。UML状态机以强大的构造扩展了简单的有限状态机。在众多扩展中,有一个看似简单且无害的语言构造却从根本上改变了状态机的反应式计算模型:doActivity行为。一旦进入给定状态,doActivity行为就会独立于状态机执行,通常将复杂计算或通信建模为后台任务。然而,UML规范或教科书对于如何适当使用doActivity行为构造语焉不详。这种指导缺失是一个严重问题,因为若使用不当,doActivity可能导致并发、非确定性错误,这类错误极难发现,并可能破坏看似正确的软件设计。UML状态机精确语义(PSSM)规范引入了详细的状态机操作语义。据我们所知,目前尚无人严格审查PSSM规范中doActivity的语义。我们通过交叉核对规范文本、其语义模型与可执行测试案例以及支持PSSM的模拟器收集证据,从而分析了该语义。我们综合得出了与工具开发者和高级建模者相关的微妙细节和涌现行为的见解。我们向标准化委员会报告了20余项问题中的不一致与未澄清之处。基于这些见解,我们研究了11种doActivity模式,详细说明了在特定情况下使用doActivity的后果,并讨论了应对措施或替代设计方案。我们希望,我们对语义和模式的分析能帮助厂商开发合规的模拟器或验证工具,并帮助工程师设计更优的状态机模型。