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的后果,并探讨了相应的应对措施或替代设计方案。我们希望本次对语义和模式的分析能帮助厂商开发符合规范的模拟器或验证工具,并助力工程师设计更优质的状态机模型。