Multi-Core Lock Memory Index for Shared Data Consistency
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
In multi-core processor environments, concurrent updates to shared data can lead to unexpected behavior and low execution efficiency due to the need for locks and subsequent migration of locks and data between CPUs, affecting the completion time of multi-threaded tasks.
Innovation Solution
A method where a CPU requesting a lock sets a memory index in the lock's memory if occupied by another CPU, allowing the lock-owning CPU to execute the critical section function based on the memory index, eliminating the need for lock and data migration into a private cache, thereby improving processing efficiency.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If a lock is applied between threads to ensure safe access to shared data, then data consistency is improved, but execution efficiency deteriorates due to threads waiting for locks and migrating locks/data between CPUs
Solution Approach 1:
The patent extracts the lock from the traditional ownership model where it must be migrated to the requesting CPU. Instead, the lock remains stationary in the memory of the CPU that currently holds it, and the requesting CPU sets a memory index to indicate its wait status. This separates the lock's functional role (controlling access) from its physical location, eliminating migration overhead while maintaining data consistency.
Solution Approach 2:
The patent introduces a memory index as an intermediary mechanism between the requesting CPU and the lock. The memory index stores information about which CPU is waiting for the lock and what critical section function it needs to execute. This intermediary allows the lock to remain stationary while still enabling communication and coordination between CPUs, resolving the contradiction between maintaining lock ownership and enabling efficient access.
2Ease of operation
If locks are migrated to the requesting CPU upon acquisition, then ease of operation is improved, but loss of time increases due to migration overhead between CPUs
Solution Approach 1:
The patent segments the lock access process into two independent parts: the lock itself (which remains stationary in memory) and the critical section function information (stored in the memory index). This segmentation allows the lock to stay in place while the requesting CPU accesses and executes its critical section function using the information stored in the memory index, eliminating the need for lock migration and associated time losses.
Solution Approach 2:
The patent performs preliminary action by having the requesting CPU set the memory index with its critical section function information before actually acquiring the lock. This allows the lock-owning CPU to later retrieve and execute the critical section function directly without needing to migrate the lock or wait for additional setup, thereby reducing overall access time and improving ease of operation.
3Reliability
If locks are held by a single CPU to ensure exclusive access, then reliability is improved, but productivity deteriorates due to frequent lock migration and data transfer between CPUs
Solution Approach 1:
The patent merges the lock functionality with the memory index mechanism. Instead of treating the lock as a separate entity that must be physically transferred between CPUs, the solution combines lock ownership information with the memory index that already stores critical section function details. This merging allows exclusive access control to be maintained while eliminating the need for separate lock migration and data transfer operations, thereby improving productivity.
Data Source
Figure 1
Figure 2
Figure 3
AI summary
Embodiments of the specification provide a method and an apparatus for updating shared data in a multi-core processor environment. The multi-processor environment comprises a multi-core processor. The multi-core processor comprises a plurality of separate processing units (referred to as cores, or core processing units (CPUs) in the specification); the multi-core processor is configured to process a multi-threaded task; the multi-threaded task has shared data to update. The method is executed by any CPU. The method may comprise: requesting, by a first CPU, for a lock to execute a critical section function on the shared data, wherein the lock provides permission to update the shared data, and the critical section function updates the shared data; and setting, by the first CPU if the lock is occupied by a second CPU, a memory index corresponding to the critical section function in a memory of the lock for the second CPU to execute the critical section function based on the memory index.