Dynamic Thread Spin Control for Lock Contention

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

In parallel processing systems, threads often waste resources by repeatedly checking for available locks while waiting, leading to inefficient thread management due to a fixed spinning mechanism that does not adapt to the number of waiting threads or processors.

Innovation Solution

A computer system dynamically controls the number of spins for a selected processing thread based on its turn, which is calculated as the total number of waiting threads after arrival at the processor, and adjusts this number according to the number of waiting threads and processors, allowing threads to yield when necessary to optimize processing efficiency.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Speed

If threads repeatedly check for available locks using a fixed spinning mechanism, then threads can quickly acquire locks when available, but threads waste processing resources and reduce overall system efficiency when locks are held for extended periods

Engineering Contradiction:
Improvelock acquisition speedVSAvoidprocessing resource waste
Core Design Contradiction:
SpeedVSLoss of energy

Solution Approach 1:

The patent implements dynamic spinning by adjusting the number of spin iterations based on the thread's turn position in the waiting queue. Threads that arrive earlier (lower turn numbers) perform more spins, while later threads perform fewer spins. This dynamic adjustment allows the system to maintain fast lock acquisition when locks are frequently available while reducing resource waste when locks are held for extended periods.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent changes the spinning parameter (number of iterations) based on system conditions, specifically the thread's turn position and the holding thread's priority level. By varying this parameter dynamically rather than using a fixed spin count, the system optimizes the balance between lock acquisition speed and resource consumption under different workload conditions.

Inventive Principle:
Principle #35Parameter changes

2Device complexity

If threads spin for a fixed number of iterations, then the spinning behavior is simple to implement, but the system cannot adapt to varying numbers of waiting threads or processor availability

Engineering Contradiction:
Improvespinning mechanism complexityVSAvoidadaptation to system conditions
Core Design Contradiction:
Device complexityVSAdaptability or versatility

Solution Approach 1:

The patent introduces feedback mechanisms where threads query the holding thread's priority level and determine their own turn position in the waiting queue. This feedback information is used to dynamically adjust the spinning behavior. The system continuously monitors these conditions and adapts the spinning parameters accordingly, enabling scalability from single-core to multi-core systems without fundamental redesign.

Inventive Principle:
Principle #23Feedback

Solution Approach 2:

The patent segments the spinning behavior into different phases based on the thread's turn position. Early-turn threads perform longer spin sequences, while later-turn threads perform shorter sequences or yield to lower-priority threads. This segmentation allows the system to handle different waiting scenarios efficiently and adapt to varying processor availability without increasing overall system complexity.

Inventive Principle:
Principle #1Segmentation

3Reliability

If all waiting threads spin equally, then fairness is maintained among threads, but processing efficiency decreases when some threads can proceed while others continue spinning

Engineering Contradiction:
Improvethread fairnessVSAvoidprocessing efficiency
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent introduces asymmetry in spinning behavior based on the holding thread's priority level and the waiting thread's turn position. When a high-priority thread holds a lock, lower-priority waiting threads are encouraged to yield rather than spin, creating an asymmetric spinning pattern. This asymmetric approach maintains fairness by respecting priority levels while improving overall processing efficiency by reducing unnecessary spinning by lower-priority threads.

Inventive Principle:
Principle #4Asymmetry

Data Source

PatentUS8997101B2Scalable thread locking with customizable spinning
Publication Date: 2015.03.31 MICROSOFT TECHNOLOGY LICENSING LLC
  • US8997101B2 patent drawing
  • US8997101B2 patent drawing
  • US8997101B2 patent drawing

AI summary

Embodiments described herein are directed to dynamically controlling the number of spins for a selected processing thread among a plurality of processing threads. A computer system tracks both the number of waiting processing threads and each thread's turn, wherein a selected thread's turn comprises the total number of waiting processing threads after the selected thread's arrival at the processor. Next, the computer system determines, based on the selected thread's turn, the number of spins that are to occur before the selected thread checks for an available thread lock. The computer system also, based on the selected thread's turn, changes the number of spins, such that the number of spins for the selected thread is a function of the number of waiting processing threads and processors in the computer system.