State machines are used in engineering many types of 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的后果,并讨论了应对措施或替代设计选择。我们希望我们对语义的分析以及这些模式能帮助供应商开发符合规范的模拟器或验证工具,并协助工程师设计更优的状态机模型。