Reader-Writer Lock Mechanism for Concurrent Thread Access

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

In multiprocessor environments, existing locking mechanisms hinder efficient access to shared computer resources, causing threads to wait unnecessarily for locks to be released, leading to inefficient resource utilization and increased context switches.

Innovation Solution

Implementing a reader-writer lock mechanism that allows multiple reader threads to access a program resource simultaneously while writer threads wait in a separate queue, enabling automatic lock acquisition without additional context switches.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If a single exclusion lock is used for both reading and writing operations, then data consistency is maintained, but resource utilization deteriorates and context switches increase

Engineering Contradiction:
Improvedata consistencyVSAvoidresource utilization
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The single exclusion lock is segmented into two separate locks: a reader lock for read operations and a writer lock for write operations. This segmentation allows multiple reader threads to acquire the reader lock simultaneously and access the shared resource concurrently, while writer threads acquire the writer lock exclusively. The segmentation resolves the contradiction by maintaining data consistency through dedicated writer lock protection while improving resource utilization through concurrent reader access.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

A lock manager component is introduced as an intermediary to manage the reader and writer locks. The lock manager maintains queues for both reader and writer threads, coordinates lock acquisition and release, and ensures proper synchronization. This intermediary mechanism enables the system to maintain reliability through controlled access while improving productivity by efficiently managing concurrent reader operations and reducing unnecessary context switches.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Reliability

If a single exclusion lock is used for both reading and writing operations, then data consistency is maintained, but context switches increase due to threads waiting for lock release

Engineering Contradiction:
Improvedata consistencyVSAvoidcontext switch overhead
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The single exclusion lock is segmented into two separate locks: a reader lock for read operations and a writer lock for write operations. This segmentation allows multiple reader threads to acquire the reader lock simultaneously and access the shared resource concurrently, while writer threads acquire the writer lock exclusively. The segmentation resolves the contradiction by maintaining data consistency through dedicated writer lock protection while improving resource utilization through concurrent reader access.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system performs preliminary actions by pre-establishing separate queues for reader and writer threads, and pre-defining the two-lock structure before threads attempt to access the shared resource. This preliminary organization allows threads to be directed to appropriate queues based on their operation type (read or write), reducing unnecessary context switches by avoiding repeated lock contention and queue switching during runtime.

Inventive Principle:
Principle #10Preliminary action

3Productivity

If multiple reader threads access the program resource simultaneously, then resource utilization improves, but lock management complexity increases

Engineering Contradiction:
Improveresource utilizationVSAvoidlock management complexity
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

A lock manager component is introduced as an intermediary to manage the reader and writer locks. The lock manager maintains queues for both reader and writer threads, coordinates lock acquisition and release, and ensures proper synchronization. This intermediary mechanism enables the system to maintain reliability through controlled access while improving productivity by efficiently managing concurrent reader operations and reducing unnecessary context switches.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The lock manager implements self-service mechanisms by automatically managing the state of reader and writer locks, maintaining thread queues, and coordinating access without requiring complex intervention from individual threads. Threads simply request access through the established protocol, and the lock manager handles the complexity of synchronization, queue management, and state transitions, thereby reducing the perceived complexity for thread developers while enabling concurrent reader access.

Inventive Principle:
Principle #25Self-service

Data Source

PatentUS9798585B2Context switching with reader-writer locks
Publication Date: 2017.10.24 ORACLE INT CORP
  • US9798585B2 patent drawing
  • US9798585B2 patent drawing
  • US9798585B2 patent drawing

AI summary

A method for scheduling threads for a software application. The method may include obtaining a thread from a thread queue. The thread may be a program segment of a software process. The method may include determining that the thread is for reading data from a program resource. The method may include, in response to determining that the thread is for reading the program resource, designating an exclusion lock on the program resource to various reader threads. The reader threads may include the thread from the thread queue. The method may include retrieving, by the reader threads, data from the program resource.