摘要
针对Windows环境下多线程同步缺乏标准的读写锁机制,本文逐步论述利用临界区对读写锁的3种实现方式。通过对不同数量的临界区进行组合操作,可以达到读写锁的设计目的,并产生不同的读/写优先倾向。由于尝试在多线程中对读写锁进行复杂的交叉操作,故进一步对特定环境下的临界区内部细节进行分析和测试,并最终确保利用临界区实现读写锁的可靠性。最后是对读写锁尝试加解锁补充功能的一些讨论。
For the lack of a standard reader-writer lock mechanism for the multi-thread synchronization in the Windows environment,the paper discusses three implementations on the reader-writer lock in use of the critical section and gradually reveals the advantages and disadvantages.The design of a reader-writer lock can be achieved by numbers of critical sections,and the different combinations will have the diverse read / write priority tendencies.Because multiple threads try to enter and leave the reader-writer lock on the complex cross-operation,there needs further analysis and testing for the internal details of the critical section in the specific circumstances to ultimately ensure the reliability of the reader-writer lock's implementation.The paper also provides some details on try-lock mechanism.
出处
《计算机与现代化》
2011年第9期215-219,共5页
Computer and Modernization
关键词
多线程同步
读写锁
临界区
死锁
写优先
multi-thread synchronization
reader-writer lock
critical section
dead lock
write priority