Thread-Specific Read Mode Counters for Multithreaded Lock Management
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Conventional operating systems' read-write lock implementations degrade processing performance in multithreaded environments, especially when read-write locks are frequently acquired and released, due to the use of internal mutexes, particularly noticeable in multi-CPU hardware.
Innovation Solution
The implementation of thread-specific read mode counters and memory barriers to serialize instruction execution, allowing reader threads to increment and decrement use counters independently, and writer threads to check for active readers before acquiring locks, thereby reducing the need for internal mutexes and enhancing processing efficiency.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If conventional read-write lock implementation using internal mutex is used, then data access control is ensured, but processing performance significantly degrades in multithreaded environments with frequent lock acquisitions
Solution Approach 1:
The patent segments the lock management mechanism by introducing thread-specific read mode counters that are independently managed by each reader thread. This segmentation allows reader threads to increment and decrement their own counters without acquiring internal mutexes, thereby improving processing performance while maintaining data access control through the counter-based tracking of active readers
Solution Approach 2:
The patent introduces an intermediary mechanism (thread-specific counters and memory barriers) between reader threads and the shared data. This intermediary allows readers to track their activity without direct mutex acquisition, while writer threads can still enforce exclusive access by checking the counter values, thus resolving the contradiction between control and performance
2Reliability
If internal mutex is used during read mode lock acquisition, then mutual exclusion is guaranteed, but processing efficiency is reduced due to frequent mutex acquisition and release operations
Solution Approach 1:
The patent applies preliminary action by having reader threads increment their thread-specific counters before accessing shared data and decrement them after release. This preliminary counter management eliminates the need for repeated mutex acquisition and release during read operations, reducing time loss while maintaining mutual exclusion through the counter-based tracking mechanism
Solution Approach 2:
Reader threads perform self-service by independently managing their own counters without requiring internal mutex acquisition. Each thread increments its counter upon entering read mode and decrements it upon exit, allowing autonomous lock management that eliminates the performance overhead of frequent mutex operations while ensuring mutual exclusion is maintained
3Productivity
If multiple reader threads access shared data simultaneously, then processing throughput is improved, but ensuring write exclusivity becomes more complex
Solution Approach 1:
The patent applies universality by creating a unified counter-based mechanism that serves multiple functions: tracking reader activity, enabling simultaneous reader access, and preventing writer access when readers are active. This single counter mechanism handles all lock management needs for both readers and writers, improving throughput while avoiding increased complexity
Solution Approach 2:
Writer threads use feedback from the thread-specific counters to determine whether to proceed with write access. By checking the counter values before acquiring write locks, writers receive feedback about current reader activity and adjust their behavior accordingly, enabling efficient concurrent reader access while maintaining write exclusivity without increasing system complexity
Data Source
AI summary
Apparatus, systems, and methods may operate to construct a memory barrier to protect a thread-specific use counter by serializing parallel instruction execution. If a reader thread is new and a writer thread is not waiting to access data to be read by the reader thread, the thread-specific use counter is created and associated with a read data structure and a write data structure. The thread-specific use counter may be incremented if a writer thread is not waiting. If the writer thread is waiting to access the data after the thread-specific use counter is created, then the thread-specific use counter is decremented without accessing the data by the reader thread. Otherwise, the data is accessed by the reader thread and then the thread-specific use counter is decremented. Additional apparatus, systems, and methods are disclosed.


