论文标题
McMini:多线程程序的基于DPOR的可编程模型检查器
McMini: A Programmable DPOR-Based Model Checker for Multithreaded Programs
论文作者
论文摘要
上下文:模型检查已成为获得对多线程程序正确性的信心的关键工具。由于种族条件未发现这些测试,因此单位测试和功能测试不足。模型检查工具解决了此问题。简单的模型检查器对于在生产前检测种族条件很有用。 查询:当前的模型Checker Hardwire是通用线程操作的行为,并且不使用更简单的原始操作识别与应用程序相关的线程范式或功能。这引入了其他操作,导致当前的模型检查器过慢。此外,没有任何机制来对基础线程库或操作系统中实现的实际线程唤醒策略的语义进行建模。消除这些约束可以使模型检查器更快。 方法:McMini是基于DPOR(动态局部订单还原)的可扩展**模型检查器。发明了一种机制,可以向McMini新的原始线程操作声明,通常以100〜行或更少的C〜代码。扩展了该机制,还允许McMini的用户声明替代线程唤醒策略,包括条件变量的虚假唤醒。 知识:在McMini中,用户定义了新的线程操作。用户通过声明DPOR算法信息来优化这些操作,从而减少要搜索的线程时间表的数量。一个声明:(i)在启用操作的条件下; (ii)哪些线程操作彼此独立; (iii)当两个操作被视为共同启用时。通过定义何时启用等待操作(在信号量,条件变量等上)来实现可选的唤醒策略。描述了一个新的启用线程操作,允许用户声明替代性唤醒策略。 接地:首先确认McMini可以正确,有效地作为传统但可扩展的模型检查器,用于静音,信号量,条件变量和读取器锁定锁。然后对McMini的可扩展性进行了对新的原始操作的测试,代表了多线程操作的其他有用的范式。读者和两个作者是一个例子。与条件变量以外的传统实现相比,发现模型检查的速度速度越多,速度越多。然后,使用对式操作测试了替代性唤醒策略(例如FIFO,LIFO,任意等)。最后,在一个虚假唤醒的情况下,通过一个仅暴露出错误**的程序对虚假的唤醒进行了测试。 重要性:许多应用程序对多线程范式采用功能,这些功能超出了传统的静音,信号量和条件变量。它们是在基本操作之上定义的。直接定义这些范式的新原语的能力使模型检查器通过搜索较少的线程计划来更快。建模特定线程唤醒策略的能力,包括条件变量的虚假唤醒,也很重要。请注意,POSIX留下了“ pthread_mutex_lock”,“ sem_wait”和`pthread_cond_wait”的唤醒策略。然后,POSIX线程实现选择了特定的策略(例如FIFO,任意),可以由McMini直接建模。
Context: Model checking has become a key tool for gaining confidence in correctness of multi-threaded programs. Unit tests and functional tests do not suffice because of race conditions that are not discovered by those tests. This problem is addressed by model checking tools. A simple model checker is useful for detecting race conditions prior to production. Inquiry: Current model checkers hardwire the behavior of common thread operations, and do not recognize application-dependent thread paradigms or functions using simpler primitive operations. This introduces additional operations, causing current model checkers to be excessively slow. In addition, there is no mechanism to model the semantics of the actual thread wakeup policies implemented in the underlying thread library or operating system. Eliminating these constraints can make model checkers faster. Approach: McMini is an **extensible** model checker based on DPOR (Dynamic Partial Order Reduction). A mechanism was invented to declare to McMini new, primitive thread operations, typically in 100~lines or less of C~code. The mechanism was extended to also allow a user of McMini to declare alternative thread wakeup policies, including spurious wakeups from condition variables. Knowledge: In McMini, the user defines new thread operations. The user optimizes these operations by declaring to the DPOR algorithm information that reduces the number of thread schedules to be searched. One declares: (i) under what conditions an operation is enabled; (ii) which thread operations are independent of each other; and (iii) when two operations can be considered as co-enabled. An optional wakeup policy is implemented by defining when a wait operation (on a semaphore, condition variable, etc.) is enabled. A new enqueue thread operation is described, allowing a user to declare alternative wakeup policies. Grounding: McMini was first confirmed to operate correctly and efficiently as a traditional, but extensible model checker for mutex, semaphore, condition variable, and reader-writer lock. McMini's extensibility was then tested on novel primitive operations, representing other useful paradigms for multithreaded operations. An example is readers-and-two-writers. The speed of model checking was found to be five times faster and more, as compared to traditional implementations on top of condition variables. Alternative wakeup policies (e.g., FIFO, LIFO, arbitrary, etc.) were then tested using an enqueue operation. Finally, spurious wakeups were tested with a program that exposes a bug **only** in the presence of a spurious wakeup. Importance: Many applications employ functions for multithreaded paradigms that go beyond the traditional mutex, semaphore, and condition variables. They are defined on top of basic operations. The ability to directly define new primitives for these paradigms makes model checkers run faster by searching fewer thread schedules. The ability to model particular thread wakeup policies, including spurious wakeup for condition variables, is also important. Note that POSIX leaves undefined the wakeup policies of `pthread_mutex_lock`, `sem_wait`, and `pthread_cond_wait`. The POSIX thread implementation then chooses a particular policy (e.g., FIFO, arbitrary), which can be directly modeled by McMini.