Lockword Thread Synchronization for Low-Stall Shared Resource Access

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing multi-thread synchronization methods in Android operating systems lead to increased access duration and stalling probability, degrading user experience due to inefficient lock management.

Innovation Solution

A multi-thread synchronization method that utilizes a lockword with a lock thread identifier, blocked thread quantity, and repeated lock times fields, allowing threads to manage lock acquisition and release efficiently without unnecessary suspensions or monitor object allocation.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If a lock coarsening policy is used to protect shared resources in multi-thread Android applications, then thread safety is improved, but access duration increases and stalling probability increases

Engineering Contradiction:
Improvethread safetyVSAvoidaccess duration
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent implements dynamic lock management by introducing a spin wait mechanism with configurable thresholds. Threads dynamically adjust their waiting behavior based on the number of contending threads, transitioning between spin waiting and blocking states. This dynamic approach optimizes the balance between thread safety and access duration by avoiding unnecessary long-term blocking when contention is low.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent changes the parameter of thread waiting strategy by introducing spin wait count thresholds. Instead of immediately blocking when a lock is contested, threads perform a limited number of spin waits before blocking. This parameter change reduces access duration for lightly contended locks while maintaining thread safety through controlled contention handling.

Inventive Principle:
Principle #35Parameter changes

2Reliability

If a lock coarsening policy is used to protect shared resources in multi-thread Android applications, then thread safety is improved, but stalling probability increases

Engineering Contradiction:
Improvethread safetyVSAvoidstalling probability
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent implements dynamic lock management by introducing a spin wait mechanism with configurable thresholds. Threads dynamically adjust their waiting behavior based on the number of contending threads, transitioning between spin waiting and blocking states. This dynamic approach optimizes the balance between thread safety and access duration by avoiding unnecessary long-term blocking when contention is low.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent incorporates feedback mechanisms by monitoring the number of contending threads and adjusting thread waiting behavior accordingly. When contention is detected, threads perform spin waits with a maximum count before blocking. This feedback-driven approach reduces stalling probability by adapting the locking strategy to actual contention levels rather than using a fixed coarse-grained approach.

Inventive Principle:
Principle #23Feedback

3Loss of time

If threads perform spin wait for lock acquisition, then access duration is reduced for low contention, but energy consumption increases due to continuous checking

Engineering Contradiction:
Improveaccess durationVSAvoidenergy consumption
Core Design Contradiction:
Loss of timeVSUse of energy by moving object

Solution Approach 1:

The patent applies partial action by limiting spin wait to a maximum count rather than continuous spinning. Threads perform spin waits for a controlled number of iterations before transitioning to blocking state. This partial approach reduces energy consumption compared to unlimited spinning while still providing the benefit of reduced access duration for low-contention scenarios.

Inventive Principle:
Principle #16Partial or excessive action

Solution Approach 2:

The patent implements periodic action through the spin wait mechanism where threads check for lock availability at regular intervals (each spin iteration) rather than continuously. This periodic checking reduces energy consumption compared to continuous spinning while maintaining the ability to quickly acquire locks when available.

Inventive Principle:
Principle #19Periodic action

Data Source

PatentEP4020210B1Multi-thread synchronization method and electronic device
Publication Date: 2026.04.01 HUAWEI TECH CO LTD
  • EP4020210B1 patent drawingFigure 1
  • EP4020210B1 patent drawingFigure 2
  • EP4020210B1 patent drawingFigure 3

AI summary

A multi-thread synchronization method and an electronic device are disclosed, and relate to the field of terminal technologies. The method includes: A first thread requests to obtain a target lock. Specifically, that the first thread requests to obtain the target lock includes the following steps: The first thread obtains a lockword of the target lock, where the lockword includes a lock thread identifier field and a blocked thread quantity field. Then, the first thread checks the lock thread identifier field. The first thread checks the blocked thread quantity field if checking that the lock thread identifier field is a valid thread and is not the first thread. The first thread performs spin wait if checking that the blocked thread quantity field is less than a first threshold. When a quantity of times for spin wait reaches a second threshold, if it is checked that the lock thread identifier field is the valid thread and is not the first thread, the first thread performs an operation of adding 1 to the blocked thread quantity field, and suspends to enter a blocked state. This technical solution helps reduce duration for gaining access to a shared resource by a lock thread, and reduce a stalling probability of an electronic device.