Realization method, device, terminal and storage medium for reentry of read-write lock

The embodiment of the invention discloses a method, a device, a terminal and a storage medium for realizing the re-entry of a read-write lock. The method comprises the following steps: receiving a current locking request of any thread to a target resource; if the target resource is in a write lock e...

Ausführliche Beschreibung

Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: PENG RONGGUI, NI ZHONGJUN, CHEN ZHUO, BAO WANYU, FENG KAIWEN, DANG YUEDONG
Format: Patent
Sprache:chi ; eng
Schlagworte:
Online-Zugang:Volltext bestellen
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
Beschreibung
Zusammenfassung:The embodiment of the invention discloses a method, a device, a terminal and a storage medium for realizing the re-entry of a read-write lock. The method comprises the following steps: receiving a current locking request of any thread to a target resource; if the target resource is in a write lock exclusive state, acquiring a historical write lock thread that is in a write lock exclusive state tothe target resource; if the thread is the same as the history write lock thread, adding a new lock of the thread for the target resource. The technical proposal of the invention avoids the deadlock problem and improves the performance of the system by supporting the reentry of the write lock in a single thread. 本发明实施例公开了种读写锁重入的实现方法、装置、终端及存储介质。该方法包括:接收任线程对目标资源的当前加锁请求;若所述目标资源处于写锁独占状态,则获取对所述目标资源处于写锁独占状态的历史写锁线程;若该线程与所述历史写锁线程相同,则为所述目标资源添加该线程的新锁。通过本发明的技术方案,通过单线程内支持写锁重入,避免了死锁问题,提高了系统的性能。