Shared Data Access Locking for Reader-Writer Thread Coordination
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for handling multiple parallel threads in accessing a shared data set, such as hardware and software transactional memory, are resource-intensive and inefficient, particularly when writer threads block reader threads with exclusive locks.
Innovation Solution
A method that records reader thread states in a data structure, selectively acquires shared locks, interrupts processing in response to exclusive lock requests, restores thread states, and resumes processing after exclusive locks are released, minimizing the need for transactional memory implementations.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If exclusive locks are used to block writer threads, then data consistency is ensured, but reader thread productivity deteriorates
Solution Approach 1:
The lock mechanism is segmented into shared locks for readers and exclusive locks for writers. Multiple reader threads can simultaneously hold shared locks on the same data set, while writer threads require exclusive locks that prevent other writers but allow readers to proceed. This segmentation resolves the contradiction by allowing concurrent reader access while maintaining data consistency through controlled writer access.
Solution Approach 2:
The locking mechanism dynamically adjusts based on thread type and access patterns. Reader threads acquire shared locks that coexist with other shared locks, while writer threads transition to exclusive locks that block other writers. The system dynamically manages lock states, thread priorities, and wait queues to optimize both data consistency and reader productivity simultaneously.
2Reliability
If transactional memory implementations are used to manage parallel threads, then thread coordination reliability is improved, but resource consumption increases
Solution Approach 1:
The patent replaces expensive hardware transactional memory with lighter-weight software lock objects. These lock objects are simple data structures that track lock state, owner thread, and wait queues without requiring complex hardware support or extensive software transaction logs. The simplified lock mechanism achieves thread coordination reliability with significantly reduced resource consumption.
Solution Approach 2:
The patent extracts the essential locking functionality from complex transactional memory systems, isolating only the necessary lock acquisition, release, and waiting mechanisms. This extracted locking subsystem provides sufficient thread coordination for reader-writer scenarios without the overhead of full transactional memory implementation, reducing both memory usage and processing overhead.
3Productivity
If shared locks are held for extended periods to complete read operations, then reader thread productivity is improved, but exclusive lock acquisition time worsens
Solution Approach 1:
Writer threads are placed in wait queues before attempting to acquire exclusive locks, allowing the system to prepare for the transition from shared to exclusive locking in advance. Reader threads are notified of pending writer requests, enabling them to voluntarily yield or complete critical sections before the exclusive lock is granted. This preliminary preparation reduces the actual lock acquisition time while maintaining reader productivity.
Solution Approach 2:
The locking mechanism implements feedback loops where writer threads signal their intent to acquire exclusive locks, and reader threads receive notifications about pending writers. This feedback enables readers to adjust their behavior dynamically - either completing read operations faster or yielding gracefully - thereby reducing exclusive lock acquisition time without permanently sacrificing reader productivity.
Data Source
AI summary
A computer implemented method of accessing a shared data set using a shared and an exclusive lock is provided. The method includes: initiating at least one reader thread configured to perform a read operation; recording a reader thread state for the at least one reader thread in a data structure; selectively acquiring the shared lock for the at least one reader thread; implementing processing of the at least one reader thread; selectively interrupting the processing of the at least one reader thread in response to an exclusive lock request; restoring the at least one reader thread state using the reader thread state recorded in the data structure and releasing the shared lock; acquiring an exclusive lock; resuming the processing of the at least one reader thread; reacquiring the shared lock for the at least one reader thread in response to determining a releasing of the exclusive lock.


