Atomic Versioned Data Structure Updates
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
In computer systems where memory is shared between multiple threads, there is a challenge in ensuring that readers do not return corrupt data when writers update the shared memory simultaneously, and traditional solutions involving locks can lead to issues if the writing thread crashes, especially if it belongs to the operating system.
Innovation Solution
A method using a cyclic array in shared memory where each element stores a version of data with a version number including an index and cycle number, allowing writers to atomically update the current version number and readers to safely retrieve data without locks by comparing cycle numbers to ensure data integrity.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If locks are used to protect shared memory during updates, then data integrity is maintained, but system performance and concurrency are reduced
Solution Approach 1:
The patent extracts the version number metadata from the data structure itself and stores it separately in a dedicated version field. This separation allows the data to be accessed and modified independently while the version number tracks changes, eliminating the need for locks during data access operations and improving concurrency while maintaining data integrity.
Solution Approach 2:
The patent performs preliminary version number assignment before data modification. The version number is incremented and assigned in advance, allowing readers to check the version number before accessing data to ensure consistency. This preliminary action prevents data corruption without requiring locks during the actual data access, thereby maintaining both reliability and productivity.
2Ease of operation
If locks are used to protect shared memory, then concurrent access is controlled, but system reliability decreases if the writing thread crashes
Solution Approach 1:
The patent implements a self-service mechanism where each data element carries its own version number. Readers independently verify data validity by checking the version number against the current version stored in memory, without requiring the writing thread to maintain locks or state. This self-verifying approach ensures that even if a writing thread crashes, readers can still identify and use valid data versions, significantly improving system reliability while maintaining ease of concurrent access control.
3Reliability
If version numbers are stored with each data element, then data validity can be verified, but memory usage increases
Solution Approach 1:
The patent merges the version number storage with the existing data structure by utilizing unused or spare fields within the same memory allocation. Instead of allocating separate memory for version numbers, the version information is combined with the data elements themselves, often by repurposing existing metadata fields or using compact encoding schemes. This approach enables data validity verification while minimizing the increase in memory usage.
Data Source
AI summary
Described embodiments include an apparatus that includes circuitry, configured to facilitate writing to a shared memory, and a processor. The processor is configured to compute a local current-version number by incrementing a shared current-version number that is stored in the shared memory. The processor is further configured to, subsequently to computing the local current-version number, using the circuitry, atomically write at least part of the local current-version number to a portion of the shared memory that is referenced by the local current-version number. The processor is further configured to, subsequently to atomically writing the at least part of the local current-version number, store data in the shared memory in association with the at least part of the local current-version number, and subsequently to storing the data, atomically overwrite the shared current-version number with the local current-version number. Other embodiments are also described.


