存储缓冲区的一个更好的约化定理
A Better Reduction Theorem for Store Buffers
摘要:
当验证一个并发程序时,通常假设内存是顺序一致的。然而,大多数现代多处理器依赖于存储缓冲来提高效率,并且仅以相当大的性能损失来提供本机顺序一致性。为了重新获得顺序一致性,程序员必须遵循适当的编程原则。然而,简单的规程,比如用锁保护所有共享访问,对于构建高性能的多处理器软件来说不够灵活。我们提出了一个新的纪律下TSO(总存储顺序,存储缓冲区转发)的并发编程。它不依赖于并发原语,比如锁。相反,线程使用ghost操作来获取和释放内存地址的所有权。一个线程只有在没有其他线程拥有一个地址的情况下才能写入该地址,并且只有在它拥有一个地址或者该地址是共享的并且该线程自从上次写入一个不属于它的地址后已经刷新了它的存储缓冲区的情况下才能从该地址读取。该规程涵盖了粗粒度并发(数据受锁保护)和细粒度并发(原子操作争用内存)。我们正式这个纪律在Isabelle/HOL,并证明,如果每一个程序的执行在一个系统中没有存储缓冲区遵循的纪律,那么每一个程序的执行与存储缓冲区是顺序一致的。因此,我们可以通过对程序的普通断言推理来证明TSO下的顺序一致性,而根本不必考虑存储缓冲区。
英文摘要:
When verifying a concurrent program, it is usual to assume that memory is sequentially consistent. However, most modern multiprocessors depend on store buffering for efficiency, and provide native sequential consistency only at a substantial performance penalty. To regain sequential consistency, a programmer has to follow an appropriate programming discipline. However, naïve disciplines, such as protecting all shared accesses with locks, are not flexible enough for building high-performance multiprocessor software. We present a new discipline for concurrent programming under TSO (total store order, with store buffer forwarding). It does not depend on concurrency primitives, such as locks. Instead, threads use ghost operations to acquire and release ownership of memory addresses. A thread can write to an address only if no other thread owns it, and can read from an address only if it owns it or it is shared and the thread has flushed its store buffer since it last wrote to an address it did not own. This discipline covers both coarse-grained concurrency (where data is protected by locks) as well as fine-grained concurrency (where atomic operations race to memory). We formalize this discipline in Isabelle/HOL, and prove that if every execution of a program in a system without store buffers follows the discipline, then every execution of the program with store buffers is sequentially consistent. Thus, we can show sequential consistency under TSO by ordinary assertional reasoning about the program, without having to consider store buffers at all.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。