Locks are a standard mechanism for synchronizing concurrent threads. The standard lock set construction assumes that critical sections are confined to a single thread, and therefore only accounts for locks acquired within that thread. The commonly used notion of a critical section implicitly assumes that protected events belong to the same thread. We show that this assumption is not valid for general C/Pthread executions. Using a trace model that captures the essence of C/Pthread programs, we give a trace-based characterization of critical sections that does not impose a per-thread restriction. As a result, critical sections may span multiple threads. Such \emph{multi-thread} critical sections arise naturally in real programs and close a semantic gap in the standard lock set construction.
翻译:锁是一种同步并发线程的标准机制。标准锁集构造假设临界区被限制在单个线程内,因此仅考虑该线程内获取的锁。临界区的常用定义隐含假设被保护事件属于同一线程。我们证明这一假设对一般C/Pthread执行并不成立。通过一种能刻画C/Pthread程序本质的迹模型,我们给出了不施加单线程限制的临界区基于迹的表征。由此,临界区可跨越多个线程。这种多线程临界区在实际程序中自然产生,并填补了标准锁集构造中的语义空白。