Lock-Free Shared-Memory Queues for Corruption-Free Process Communication
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing shared-memory communication systems face issues with data corruption, deadlocks, and interference due to the use of mutexes, unsafe buffer ownership transfer, and unprotected control data, which compromise the integrity and safety of data transfer between processes.
Innovation Solution
Implementing lock-free data structures with defined access rights and plausibility checks to manage memory region ownership, ensuring freedom from interference by using separate and redundant data structures to protect against corruption and deadlocks.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If mutexes are used to prevent data races in shared memory communication, then data integrity is improved, but deadlocks and system interference occur
Solution Approach 1:
The patent extracts the problematic mutex locking mechanism from the shared memory access control and replaces it with a lock-free approach using atomic operations and hazard pointers. This removes the source of deadlocks while maintaining data integrity through alternative synchronization methods.
Solution Approach 2:
The patent replaces the mechanical locking system (mutexes) with a software-based atomic operation system using compare-and-swap (CAS) instructions and hazard pointer tracking. This substitution eliminates the need for physical lock acquisition and release, preventing deadlocks while ensuring safe concurrent access.
2Productivity
If buffer ownership is transferred between processes in shared memory, then communication efficiency is improved, but data corruption risks increase
Solution Approach 1:
The patent implements feedback through hazard pointer tracking that continuously monitors buffer ownership status. When a buffer is being accessed, the hazard pointer provides feedback to prevent premature overwriting or deallocation, ensuring data integrity while maintaining efficient zero-copy communication.
Solution Approach 2:
The patent introduces hazard pointers as an intermediary mechanism between the buffer owner and potential corruptors. These pointers act as mediators that coordinate access without requiring mutual exclusion locks, allowing efficient ownership transfer while preventing data corruption through atomic operations.
3Speed
If control data is stored unprotected in shared memory, then access speed is improved, but corruption by interfering processes occurs
Solution Approach 1:
The patent applies preliminary action by pre-establishing hazard pointer protection around control data structures before access occurs. This proactive protection is set up in advance to prevent corruption without requiring slow protective measures during actual access, maintaining high speed while ensuring reliability.
Data Source
Figure 1A
Figure 1B
Figure 1C
AI summary
Embodiments are directed to safe shared-memory communication between processes. In an embodiment, a data structure for communicating data references, to data in a shared memory, from a sender to a receiver, free from interference, is generated and maintained. The data structure may comprise a queue of the data references that is both readable and writable by the sender and only readable by the receiver, a write index that indicates a write position within the queue, wherein the write index is both readable and writable by the sender and only readable by the receiver, and a read index that indicates a read position within the queue, wherein the read index is only readable by the sender and both readable and writable by the receiver. In addition, read and write operations from and to the queue may utilize plausibility checks to detect and resolve potential corruption of the data structure.