A processing method and apparatus of a thread

By having a high-priority thread act as a proxy for a low-priority thread, the priority inversion problem in condition variable scenarios is solved, improving thread execution efficiency, ensuring that low-priority threads can successfully execute the condition of the condition variable, and reducing the waiting time of high-priority threads.

CN120762824BActive Publication Date: 2026-06-12HONOR DEVICE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-07-31
Publication Date
2026-06-12

AI Technical Summary

Technical Problem

In condition variable scenarios, when a high-priority thread waits for a low-priority thread to meet the condition variable, the CPU resources of the low-priority thread may be preempted by the medium-priority thread, leading to a priority inversion problem. This can cause the high-priority thread to wait longer, reducing execution efficiency.

Method used

By putting high-priority threads into a sleep state without removing them from the run queue, and using low-priority threads as their proxies, it ensures that low-priority threads can successfully execute the condition variable, allowing high-priority threads to continue running quickly and preventing medium-priority threads from preempting CPU resources.

🎯Benefits of technology

This reduces the time high-priority threads spend waiting for condition variables to become true, improves thread execution efficiency, and avoids wasting CPU resources and priority inversion issues.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120762824B_ABST
    Figure CN120762824B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a thread processing method and device, and relate to the technical field of computers, which can solve the priority inversion problem in the condition variable scenario and improve the execution efficiency of threads. The method is applied to an electronic device, the electronic device comprising a target processor, the target processor comprising a target run queue, the target run queue comprising a first thread, a second thread and a third thread, the method comprising: in the case where a condition of a target condition variable is not established, the first thread entering a sleep state and not being removed from the target run queue; the second thread setting the condition of the target condition variable to be established and waking up the first thread; in the case where the condition of the target condition variable is established, the first thread continuing to run; after the first thread finishes running, the third thread running, wherein the priority of the third thread is higher than the priority of the second thread and lower than the priority of the first thread.
Need to check novelty before this filing date? Find Prior Art