Mutual Trust Locking for Concurrent Writes to Shared Resources
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Current read-write lock mechanisms in multi-thread programming lead to low efficiency in concurrent access to shared resources, particularly when large-scale concurrency involves threads accessing different ranges of a protected resource, as they require a write lock on the entire resource, serially processing it despite threads operating on different data units.
Innovation Solution
Implementing a mutual trust lock state that allows multiple threads to concurrently perform write operations on different data units of a shared resource, using a lock status variable to manage lock acquisition and release, ensuring non-exclusive write operations and avoiding conflicts.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If a write lock is acquired to lock the entire shared resource to ensure consistency, then security of the shared resource is improved, but efficiency of concurrent access by multiple threads deteriorates
Solution Approach 1:
The patent segments the shared resource into multiple data units (e.g., array elements, struct fields) and introduces fine-grained locks that can lock individual data units rather than the entire resource. This allows threads to access different data units concurrently while maintaining consistency within each locked unit, thereby improving concurrent access efficiency while preserving security.
Solution Approach 2:
The patent applies different locking strategies to different parts of the shared resource based on access patterns. Threads accessing different data units can acquire fine-grained locks on specific units rather than a global lock, allowing local concurrent access while maintaining global consistency. This localizes the quality of locking to match the scope of actual data access.
2Productivity
If a fine-grained lock is used to allow concurrent access to different data units, then efficiency of concurrent access is improved, but complexity of lock management deteriorates
Solution Approach 1:
The patent merges multiple fine-grained locks into a coarse-grained lock structure that automatically manages the locking hierarchy. The lock manager consolidates lock acquisition and release operations, reducing the burden on programmers to manually manage individual fine-grained locks while still enabling concurrent access to different data units.
Solution Approach 2:
The patent introduces a lock manager as an intermediary component that handles fine-grained lock operations. This mediator abstracts the complexity of managing multiple fine-grained locks, providing a simplified interface for thread synchronization while maintaining the benefits of fine-grained locking for concurrent access efficiency.
Data Source
Figure 1~2
Figure 3
Figure 4
AI summary
Embodiments of this application disclose a multi-thread concurrent access method, to improve efficiency of concurrent access to a shared resource by a plurality of threads. The method in embodiments of this application includes: A computing device receives a first lock acquire request, where the first lock acquire request is used to request a mutual trust lock for performing a write operation on a shared resource by a first thread, and the mutual trust lock is used for performing a non-exclusive write operation on the shared resource. The computing device issues the mutual trust lock to the first thread based on the first lock acquire request. The first thread and a second thread concurrently perform write operations on the shared resource based on the mutual trust lock, where the second thread is a thread that has acquired the mutual trust lock.