Dynamic Atomic Array Resizing via Compare-and-Swap

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Standard dynamic arrays are not thread-safe and require locks for concurrent access, leading to processing overhead and priority inversion issues in multi-threaded environments, while atomic arrays are not dynamic and cannot grow or shrink.

Innovation Solution

A dynamic atomic array that is non-blocking, wait-free, and thread-safe, allowing resizing through a compare and swap operation, and using a COPIED indicator to ensure accurate element copying without locks.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If locks are used for concurrent access to dynamic arrays, then thread safety is improved, but processing overhead and priority inversion issues occur

Engineering Contradiction:
Improvethread safetyVSAvoidprocessing overhead
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The array is divided into multiple independent segments or slots, each capable of being accessed independently by different threads. Instead of locking the entire array, individual segments can be accessed without mutual exclusion, reducing contention and overhead while maintaining thread safety through structured access patterns.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The mechanical locking system is replaced with an atomic compare-and-swap operation at the hardware level. This substitution eliminates the need for software-based locks and blocking mechanisms, providing thread safety through atomic instructions that operate without requiring thread suspension or context switching.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

2Reliability

If locks are used for concurrent access to dynamic arrays, then thread safety is improved, but priority inversion occurs

Engineering Contradiction:
Improvethread safetyVSAvoidpriority inversion
Core Design Contradiction:
ReliabilityVSEase of operation

Solution Approach 1:

The lock-based synchronization mechanism is replaced with atomic compare-and-swap operations that do not require thread blocking. This eliminates priority inversion by allowing threads to attempt access without being suspended by lower-priority threads holding locks, as the atomic operation completes in a single indivisible step.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

Solution Approach 2:

The system provides self-service thread safety through atomic hardware instructions that inherently protect against concurrent access conflicts without requiring external lock management. Threads independently perform atomic operations on their target elements, and the hardware ensures mutual exclusion at the instruction level, eliminating the need for lock acquisition and release protocols.

Inventive Principle:
Principle #25Self-service

3Adaptability or versatility

If atomic arrays are made dynamic with resizing capability, then adaptability is improved, but thread safety becomes difficult to maintain

Engineering Contradiction:
Improveresizing capabilityVSAvoidthread safety
Core Design Contradiction:
Adaptability or versatilityVSReliability

Solution Approach 1:

A new array structure is pre-allocated and prepared before the resizing operation begins. The atomic compare-and-swap operation then atomically transitions from the old array to the pre-prepared new array, ensuring that no thread observes a partially resized state. This preliminary preparation eliminates the need for locking during the transition.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The array structure is made dynamic through atomic transitions between different array instances. Rather than modifying a single array in place (which would require locks), the system dynamically switches between array versions using atomic compare-and-swap on the array reference, allowing resizing without compromising thread safety.

Inventive Principle:
Principle #15Dynamics

4Productivity

If standard dynamic array techniques are used, then resizing is efficient, but thread safety is lost

Engineering Contradiction:
Improveresizing efficiencyVSAvoidthread safety
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The software-based locking mechanism is replaced with a hardware-level atomic compare-and-swap instruction. This substitution maintains resizing efficiency by operating at the hardware level in a single atomic step, while simultaneously providing thread safety that software locks cannot achieve without blocking other threads.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

Data Source

PatentUS8312053B2Dynamic atomic arrays
Publication Date: 2012.11.13 ORACLE INT CORP
  • US8312053B2 patent drawing
  • US8312053B2 patent drawing
  • US8312053B2 patent drawing

AI summary

Embodiments of the present invention provide techniques, including systems, methods, and computer readable medium, for dynamic atomic arrays. A dynamic atomic array is a data structure that provides an array that can grow or shrink in size as required. The dynamic atomic array is non-blocking, wait-free, and thread-safe. The dynamic atomic array may be used to provide arrays of any primitive data type as well as complex types, such as objects.