Read-Write Spinlock Atomic Counter Design

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current read-write spinlocks are inefficient due to the need for multiple guard lock acquisitions and releases, leading to high CPU usage, processor contention, and cache penalties, especially in multi-processor systems, and require larger data structures.

Innovation Solution

A read-write spinlock design that uses a compact data structure with a standard mutual-exclusion spinlock and fetch-and-add or compare-and-swap instructions to manage reader and writer access, eliminating the need for guard locks among readers and reducing CPU spin time.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If multiple guard locks are used to manage reader-writer access, then mutual exclusion among readers and writers is ensured, but CPU time is wasted due to multiple acquisition and release operations

Engineering Contradiction:
Improvemutual exclusionVSAvoidCPU time
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent extracts the guard lock mechanism from the reader-writer spinlock implementation. Readers no longer acquire or release guard locks; instead, they perform atomic increment operations on a reader count. Only writers acquire and release the guard lock, eliminating the multiple guard lock operations that wasted CPU time while maintaining mutual exclusion through the atomic reader count updates.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent merges the reader entry and exit operations into a single atomic counter mechanism. Instead of separate guard lock acquisitions and releases for each reader operation, the system uses a single atomic increment for reader entry and a single atomic decrement for reader exit, combining multiple operations into fewer atomic instructions.

Inventive Principle:
Principle #5Merging (Combining)

2Reliability

If multiple guard locks are used to manage reader-writer access, then access control is maintained, but processor contention increases causing CPUs to spin while waiting

Engineering Contradiction:
Improveaccess controlVSAvoidprocessor utilization
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent removes guard locks from the reader path, eliminating the source of processor contention. Readers perform lock-free atomic increment operations that do not require acquiring guards, allowing multiple readers to enter simultaneously without spinning. Only writers contend for the single guard lock, dramatically reducing processor contention while maintaining access control through the atomic reader count.

Inventive Principle:
Principle #2Taking out (Extraction)

3Reliability

If guard locks are used as shared objects, then reader-writer coordination is achieved, but cache penalties occur under heavy use

Engineering Contradiction:
ImprovecoordinationVSAvoidcache penalties
Core Design Contradiction:
ReliabilityVSLoss of energy

Solution Approach 1:

The patent extracts guard locks from the reader-writer coordination mechanism. Readers use atomic increment/decrement operations on a counter that can be implemented with better cache characteristics. The single guard lock is only held by writers during write operations, reducing the frequency and duration of cache line invalidations and penalties under heavy reader-writer mixing.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent changes the operational parameters of the lock mechanism by reducing the number of times guard locks are acquired and released. Writers hold the guard lock only during the critical write section, and readers perform lock-free operations, changing the temporal pattern of lock usage to reduce cache contention and penalties.

Inventive Principle:
Principle #35Parameter changes

4Reliability

If two guard locks are used, then reader entry and exit can be tracked separately, but the data structure size increases

Engineering Contradiction:
Improvetracking accuracyVSAvoiddata structure size
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The patent merges the separate guard lock structures into a single atomic counter mechanism. Instead of maintaining two separate guard lock data structures for entry and exit tracking, the system uses a single atomic integer counter that is incremented for reader entry and decremented for reader exit, maintaining full tracking accuracy while halving the lock-related data structure size.

Inventive Principle:
Principle #5Merging (Combining)

Data Source

PatentUS8799591B2Read-write spinlock
Publication Date: 2014.08.05 HEWLETT PACKARD ENTERPRISE DEV LP
  • US8799591B2 patent drawing
  • US8799591B2 patent drawing
  • US8799591B2 patent drawing

AI summary

An embodiment of the invention provides an apparatus and method for controlling access by a read-write spinlock with no mutual exclusion among readers. The apparatus and method perform the steps of using values in a data structure in the read-write spinlock to control read access to a shared object and using values in the data structure and a guard lock to control write access to the shared object.