WO2015096031A1 - Method and apparatus for allocating thread shared resource - Google Patents

Method and apparatus for allocating thread shared resource Download PDF

Info

Publication number
WO2015096031A1
WO2015096031A1 PCT/CN2013/090326 CN2013090326W WO2015096031A1 WO 2015096031 A1 WO2015096031 A1 WO 2015096031A1 CN 2013090326 W CN2013090326 W CN 2013090326W WO 2015096031 A1 WO2015096031 A1 WO 2015096031A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
long
delay operation
thread
target thread
Prior art date
Application number
PCT/CN2013/090326
Other languages
French (fr)
Chinese (zh)
Inventor
陈云
宋昆鹏
崔晓松
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201380077895.2A priority Critical patent/CN105378652B/en
Priority to PCT/CN2013/090326 priority patent/WO2015096031A1/en
Publication of WO2015096031A1 publication Critical patent/WO2015096031A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals

Definitions

  • the long delay operation of each thread is judged, and the long delay operation refers to an operation in which the processor needs dozens or even hundreds of processor clocks to return a result, if it is determined that a thread has a long delay Operation, the resources occupied by the thread in the shared resource are released.
  • determining, by the long delay operation determining signal sent by the target thread, that the target thread performs a long delay operation includes: receiving the target thread to send Long delay operation judgment signal;
  • the long delay operation determining signal includes: a long delay operation signal, and the long delay The corresponding access information of the operation signal; the long delay operation includes: an operation of accessing the main memory due to a cache miss, or an access operation of the remote shared memory.
  • a second aspect of the embodiments of the present invention provides a thread sharing resource allocation apparatus, including: a first determining module, configured to determine, according to a long delay operation determining signal sent by a target thread, that the target thread performs a long delay operation;
  • a counting module configured to count a number of times that the target thread performs a long delay operation in a preset time
  • a second determining module configured to perform a long delay operation according to the target thread, a preset system weight coefficient, and a preset Determining, by the weight adjustment policy value, the accessed frequency of the target resource in the target thread, the replaced weight value of the target resource, where the target resource is a multi-thread shared resource occupied by the target thread
  • the first determining module is specifically configured to receive a long delay operation determining signal sent by the target thread; The determination signal determines that the target thread has performed a long delay operation.
  • an obtaining module configured to acquire the preset system weight coefficient and the preset weight adjustment policy value before determining that the target thread performs a long delay operation according to the long delay operation judgment signal sent by the target thread.
  • the assigning module is specifically configured to: the target resource is preferentially replaced according to the replaced weight, or the target resource is reduced The probability of replacement.
  • a third aspect of the embodiments of the present invention provides a thread sharing resource allocation apparatus, including: a memory, configured to store an instruction;
  • a processor coupled to the memory, configured to execute an instruction stored in the memory, to determine that the target thread has performed a long delay operation according to a long delay operation determination signal sent by the target thread;
  • the number of times the target thread performs a long delay operation; the number of times of the long delay operation by the target thread, the preset system weight coefficient, the preset weight adjustment policy value, and the access of the target resource in the target thread Determining, by frequency, or the like, the replaced weight value of the target resource, where the target resource is a multi-thread shared resource occupied by the target thread; and the target resource is reallocated according to the replaced weight value.
  • the processor is configured to receive a long delay operation determination signal sent by the target thread, and determine a signal according to the long delay operation. It is determined that the target thread has performed a long delay operation.
  • the processor is further configured to send the length according to the target thread
  • the delay operation determining signal determines that the target system weight coefficient and the preset weight adjustment policy value are obtained before the target thread performs a long delay operation.
  • the processor is specifically configured to: the target resource is preferentially replaced according to the replaced weight, or the target resource is replaced The probability.
  • determining, according to the long delay operation judgment signal sent by the target thread, that the target thread performs a long delay operation, and counting the number of long delay operations, and then performing the long delay operation according to the target thread The system weight coefficient, the preset weight adjustment policy value, and the accessed frequency of the target resource in the target thread determine the replaced weight value of the target resource, and the target resource is reallocated when needed according to the replaced weight value. It realizes more reasonable allocation of multi-thread shared resources.
  • some target resources are preferentially replaced, so that other threads can compete, avoiding waste of resources, and reducing the probability that important resources of some key threads are replaced, and avoiding After the target thread releases some important resources and then reacquires it again, the target thread performance is degraded, thus ensuring the performance of the target thread.
  • FIG. 1 is a schematic flowchart of Embodiment 1 of a thread sharing resource allocation method provided by the present invention
  • FIG. 2 is a schematic structural diagram of Embodiment 1 of a thread sharing resource allocation apparatus provided by the present invention
  • FIG. 3 is a schematic diagram of a thread sharing resource allocation apparatus provided by the present invention
  • FIG. 4 is a schematic structural diagram of Embodiment 3 of a thread sharing resource allocation apparatus according to the present invention.
  • Embodiment 1 is a schematic flowchart of Embodiment 1 of a thread sharing resource allocation method provided by the present invention.
  • the method is implemented in a multi-thread system. As shown in FIG. 1, the method includes:
  • statistics are periodically performed, and can be timed by a time window timer.
  • the preset time can refer to a period of time.
  • the time window timer reaches the threshold, the previous count is cleared, that is, from the next cycle. Start recalculating.
  • the target resource is a multi-thread shared resource occupied by the target thread.
  • the target resource may be reallocated when needed. That is, resource re-allocation is not necessarily performed when the time window timer reaches the threshold, but resource re-allocation is performed when other threads or target threads need to apply for new shared resources.
  • the foregoing target resource is re-allocated according to the replaced weight value, and the target resource may be preferentially replaced according to the replaced weight value, or the probability that the target resource is replaced may be reduced.
  • the shared resource occupied by the target thread is preferentially replaced, or the probability that the shared resource occupied by the target thread is replaced is reduced.
  • the preset weight adjustment policy value can be adjusted.
  • the preset weight adjustment policy value can be set to 1, indicating that the longer the long delay operation, the smaller the replaced weight value, and the less the long delay operation is.
  • the replacement weight value is larger.
  • the contribution of the resources to the target thread is small or the target thread belongs to the background application (that is, its running time does not affect the work of the whole system), and these resources are Released, in order to let the thread that needs these resources to compete, then the target thread to compete for the more needed resources of the target thread to replace; in another range, reduce the probability that the shared resources occupied by the target thread are replaced, this In this case, it is indicated that these resources are more important to the target thread, and try not to let these resources be replaced.
  • determining, according to the long delay operation judgment signal sent by the target thread, that the target thread performs a long delay operation, and counting the number of long delay operations, and then performing the long delay operation according to the target thread The system weight coefficient, the preset weight adjustment policy value, and the accessed frequency of the target resource in the target thread determine the replaced weight value of the target resource, and the target resource is reallocated when needed according to the replaced weight value. It realizes more reasonable allocation of multi-thread shared resources.
  • some target resources are preferentially replaced, so that other threads can compete, avoiding waste of resources, and reducing the probability that important resources of some key threads are replaced, and avoiding After the target thread releases some important resources and then reacquires it again, the target thread performance is degraded, thus ensuring the performance of the target thread.
  • the foregoing determining, according to the LLE determination signal sent by the target thread, that the target thread performs a long delay operation, specifically: receiving an LLE determination signal sent by the target thread; determining, according to the LLE determination signal, that the target thread performs a long delay operating.
  • the long delay operation specifically refers to an operation that requires dozens or even hundreds of processor clocks to return a result, and may include: accessing a main memory operation due to a cache miss, or remote sharing Memory access operations, but not limited to this.
  • the target thread has a long-delay operation, for example, the last-level cache is lost, the remote data is accessed, and the like, the target thread sends a long-delay operation determination signal, and the LLE determination signal can be sent to the embodiment of the present invention.
  • the thread sharing resource allocation device is judged by the long delay judging module in the device, and the long delay judging module can judge whether the long delay operation is based on the judgment signal, and if the long delay operation is performed, the target thread is extended.
  • the number of operations is increased by one.
  • the long delay operation determination signal may include: the long delay operation signal (LLE-like), and the corresponding access information of the long delay operation signal.
  • the corresponding access information may be: an access request, target address information of the access, read and write information, target thread information of the access, and the like.
  • which signals can be used to judge the LLE can be configured by the whole system according to actual needs.
  • the method further includes acquiring the preset system weight coefficient and the preset weight adjustment policy value.
  • the preset system weight coefficient and the preset weight adjustment strategy are configured by the system administrator according to the application requirements of the whole system, for example, according to the application scenario, setting the preset weight adjustment policy value to 1, to represent The longer the long delay operation, the smaller the replacement weight value. The smaller the long delay operation, the larger the replacement weight value.
  • the above system administrator can also dynamically adjust the above settings according to actual conditions during system operation.
  • the number of times of performing the long delay operation, the preset system weight coefficient, the preset weight adjustment policy, and the visited frequency of the target resource in the target thread are determined by using the target thread to determine the replaced weight value of the target resource.
  • the weight adjustment policy value is 1, to indicate that the longer the long delay operation, the smaller the replacement weight value, and the smaller the long delay operation, the larger the replacement weight value.
  • the default weight adjustment policy value is W _ Wr (0, the default system weight coefficient is W (0, the target frequency of the target resource in the target thread is Re c fy (0, the target thread performs long delay operation).
  • the number of times is LLe _ cnt(i)
  • the preset should be adjusted if the cache of the second or third level (L2/L3) can be turned off or not.
  • the system weight coefficient makes the cache line in the first level cache as low as possible because of the long delay operation of other threads, so that the penalty is too large. It should be noted that the competition of resources in the first level cache by each thread is based on the Cache Line.
  • the number of threads running simultaneously in the system is relatively small. At this time, the competition of shared resources among multiple threads is small.
  • the preset system weight value can be adjusted to minimize the probability of target resources being replaced, and the target thread is reduced. Exchange and exchange of resources.
  • the length of the preset time also affects the adjustment frequency of the replacement weight value. In some application scenarios, a smaller preset time is set. The period of the meter is small, so that the replacement weight value can be adjusted in a shorter time.
  • FIG. 2 is a schematic structural diagram of Embodiment 1 of a thread sharing resource allocation apparatus according to the present invention.
  • the apparatus includes: a first determining module 201, a counting module 202, a second determining module 203, and an allocating module 204. among them:
  • the first determining module 201 is configured to determine, according to the long delay operation determining signal sent by the target thread, that the target thread performs a long delay operation.
  • the counting module 202 is configured to count the number of times the target thread performs a long delay operation within a preset time.
  • the second determining module 203 is configured to determine the target according to the number of times the target thread performs a long delay operation, a preset system weight coefficient, a preset weight adjustment policy value, and an accessed frequency of a target resource in the target thread.
  • the allocating module 204 is configured to re-allocate the target resource according to the replaced weight value.
  • the first determining module 201 is specifically configured to receive a long delay operation determining signal sent by the target thread, and determine, according to the long delay operation determining signal, that the target thread performs a long delay operation.
  • the long delay operation determination signal includes: a long delay operation signal, and access information corresponding to the long delay operation signal; the long delay operation includes: accessing the main memory due to a cache miss The operation, or access operation of the remote shared memory.
  • FIG. 3 is a schematic structural diagram of Embodiment 2 of a thread sharing resource allocation apparatus according to the present invention.
  • the apparatus includes:
  • the obtaining module 205 is configured to obtain the preset system weight coefficient and the preset weight adjustment policy value before determining that the target thread performs a long delay operation according to the long delay operation determining signal sent by the target thread.
  • the foregoing allocation module 204 is specifically configured to: the target resource is preferentially replaced according to the replaced weight, or the probability that the target resource is replaced is reduced.
  • FIG. 4 is a schematic structural diagram of Embodiment 3 of a thread sharing resource allocation apparatus according to the present invention. As shown in FIG. 4, the apparatus includes: a memory 401 and a processor 402, where
  • the memory 401 is configured to store an instruction.
  • the processor 402 coupled to the memory 401, is configured to execute an instruction stored in the memory 401, specifically, configured to determine, according to the long delay operation determination signal sent by the target thread, that the target thread performs a long delay operation; The number of times the target thread performs a long delay operation within a preset time; the number of times of the long delay operation by the target thread, the preset system weight coefficient, the preset weight adjustment policy value, and the target resource in the target thread The replaced weight value of the target resource is determined by the frequency of access, etc., wherein the target resource is a multi-thread shared resource occupied by the target thread; and the target resource is reallocated according to the replaced weight value.
  • the processor 402 is specifically configured to receive a long delay operation determination signal sent by the target thread, and determine, according to the long delay operation determination signal, that the target thread performs a long delay operation.
  • the processor 402 is specifically configured to: the target resource is preferentially replaced according to the replaced weight, or reduce a probability that the target resource is replaced.
  • the long delay operation determination signal includes: a long delay operation signal, and access information corresponding to the long delay operation signal; the long delay operation includes: accessing the main memory due to a cache miss The operation, or access operation of the remote shared memory.
  • the processor 402 is further configured to acquire the preset system weight coefficient and the preset weight adjustment before determining that the target thread performs a long delay operation according to the long delay operation determination signal sent by the target thread. Policy value.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

Embodiments of the present invention provide a method and an apparatus for allocating a thread shared resource. The method comprises: determining, according to a long delay operation judgment signal sent by a target thread, that the target thread performs a long delay operation; counting the number of times that the target thread performs a long delay operation in a preset time; determining a replaced weight value of the target resource according to the number of times that the target thread performs a long delay operation, a preset system weight coefficient, a preset weight adjustment policy value and frequencies of the target resource being accessed in the target thread; and reallocating the target resource according to the replaced weight value. In the embodiments of the present invention, allocation of a multi-thread shared resource is more proper, waste of a resource is avoided, the probability that important resources of some important threads are replaced, and it is avoided that performance of a target thread is decreased because after a target thread releases some important resources but needs to regain the resource when the resources are reused, thereby ensuring performance of the target thread.

Description

线程共享资源分配方法及装置  Thread sharing resource allocation method and device
技术领域 Technical field
本发明涉及通信技术, 尤其涉及一种线程共享资源分配方法及装置。 背景技术  The present invention relates to communications technologies, and in particular, to a thread sharing resource allocation method and apparatus. Background technique
同步多线程(Simultaneous Multi Threading, 简称 SMT)技术是一种处理 器技术, SMT结构通过复制处理器上的结构状态, 使处理器能够同时执行来 自不同线程的多条指令、 挖掘单线程内部的指令级并行和线程间的线程级并 行来降低处理器内部流水线的水平浪费和垂直浪费, 可最大限度地实现宽发 射、 乱序的超标量处理, 以提高处理器运算部件的利用率。 上述 SMT结构结 合了超标量结构多发射的能力和传统的多线程结构隐藏延时的能力, 不同的 是, 传统的多线程结构通过上下文的快速切换来共享处理器的执行资源, 而 上述 SMT结构使多个上下文保持同时活跃来竞争执行资源。 这种 SMT结构 通过线程对资源的共享来提高资源利用率。  Simultaneous Multi Threading (SMT) technology is a processor technology. The SMT structure enables the processor to execute multiple instructions from different threads and mine single-thread internal instructions by copying the structure state on the processor. Level-parallelism and thread-level parallelism between threads reduce horizontal waste and vertical waste in the processor's internal pipeline, maximizing wide-emission, out-of-order superscalar processing to improve processor utilization. The above SMT structure combines the capability of superscalar multi-emission and the traditional multi-threaded architecture to hide latency. The difference is that the traditional multi-threaded architecture shares the execution resources of the processor through fast context switching, and the above SMT structure Keep multiple contexts active at the same time to compete for execution resources. This SMT structure improves resource utilization by thread sharing of resources.
现有技术中, 对各线程的长延时操作进行判断, 该长延时操作指处理器 需要几十个甚至几百个的处理器时钟才能返回结果的操作, 如果判断某线程 有长延时操作, 则释放该线程在共享资源中所占的资源。  In the prior art, the long delay operation of each thread is judged, and the long delay operation refers to an operation in which the processor needs dozens or even hundreds of processor clocks to return a result, if it is determined that a thread has a long delay Operation, the resources occupied by the thread in the shared resource are released.
但是, 采用现有技术, 在共享资源竞争并不激烈的情况下, 反而会导致 上述线程的性能下降; 而且不能保证系统中关键线程对共享资源的优先权, 从而影响系统的关键性能指标。 发明内容  However, with the prior art, in the case where the competition of the shared resources is not fierce, the performance of the above-mentioned threads is degraded; and the priority of the key threads in the system to the shared resources cannot be guaranteed, thereby affecting the key performance indicators of the system. Summary of the invention
本发明实施例提供一种线程共享资源分配方法及装置, 用于解决现有共 享资源分配方法会影响线程性能的问题。  The embodiment of the invention provides a thread sharing resource allocation method and device, which are used to solve the problem that the existing shared resource allocation method affects thread performance.
本发明实施例第一方面提供一种线程共享资源分配方法, 包括: 根据目标线程发送的长延时操作判断信号确定所述目标线程进行了长延 时操作;  A first aspect of the embodiments of the present invention provides a thread sharing resource allocation method, including: determining, according to a long delay operation judgment signal sent by a target thread, that the target thread performs a long delay operation;
统计预设时间内所述目标线程进行长延时操作的次数; 根据所述目标线程进行长延时操作的次数、 预设系统权重系数、 预设权 重调整策略值以及所述目标线程中目标资源的被访问频次等确定所述目标资 源的被替换权重值, 其中, 所述目标资源为所述目标线程所占有的多线程共 享资源; Counting the number of times the target thread performs a long delay operation within a preset time period; Determining the replaced weight value of the target resource according to the number of times the target thread performs the long delay operation, the preset system weight coefficient, the preset weight adjustment policy value, and the visited frequency of the target resource in the target thread, where The target resource is a multi-thread shared resource occupied by the target thread;
根据所述被替换权重值对所述目标资源进行重新分配。  Reassigning the target resource according to the replaced weight value.
结合第一方面, 在第一方面的第一种可能的实施方式中, 根据目标线程 发送的长延时操作判断信号确定所述目标线程进行了长延时操作, 包括: 接收所述目标线程发送的长延时操作判断信号;  With reference to the first aspect, in a first possible implementation manner of the first aspect, determining, by the long delay operation determining signal sent by the target thread, that the target thread performs a long delay operation, the method includes: receiving the target thread to send Long delay operation judgment signal;
根据所述长延时操作判断信号确定所述目标线程进行了长延时操作。 结合第一方面的第一种可能的实施方式, 在第一方面的第二种可能的实 施方式中, 所述长延时操作判断信号包括: 长延时操作信号, 以及与所述长 延时操作信号相应的访问信息; 所述长延时操作包括: 由于缓存缺失而访问 主存的操作, 或者, 远端共享内存的访问操作。  Determining, according to the long delay operation judgment signal, that the target thread performs a long delay operation. With reference to the first possible implementation manner of the first aspect, in the second possible implementation manner of the first aspect, the long delay operation determining signal includes: a long delay operation signal, and the long delay The corresponding access information of the operation signal; the long delay operation includes: an operation of accessing the main memory due to a cache miss, or an access operation of the remote shared memory.
结合第一方面至第一方面的第二种可能的实施方式中任一种, 在第一方 面的第三种可能的实施方式中, 所述根据目标线程发送的长延时操作判断信 号确定所述目标线程进行了长延时操作之前, 还包括:  With reference to the first aspect to any one of the second possible implementation manners of the first aspect, in a third possible implementation manner of the first aspect, the determining, by the Before the target thread performs a long delay operation, it also includes:
获取所述预设系统权重系数和所述预设权重调整策略值。  Obtaining the preset system weight coefficient and the preset weight adjustment policy value.
结合第一方面, 在第一方面的第四种可能的实施方式中, 所述根据所述 被替换权重对所述目标资源进行重新分配, 包括:  With reference to the first aspect, in a fourth possible implementation manner of the first aspect, the re-allocating the target resource according to the replaced weight includes:
根据所述被替换权重, 让所述目标资源被优先替换, 或者降低所述目标 资源被替换的概率。  According to the replaced weight, the target resource is preferentially replaced, or the probability that the target resource is replaced is reduced.
本发明实施例第二方面提供一种线程共享资源分配装置, 包括: 第一确定模块, 用于根据目标线程发送的长延时操作判断信号确定所述 目标线程进行了长延时操作;  A second aspect of the embodiments of the present invention provides a thread sharing resource allocation apparatus, including: a first determining module, configured to determine, according to a long delay operation determining signal sent by a target thread, that the target thread performs a long delay operation;
计数模块, 用于统计预设时间内所述目标线程进行长延时操作的次数; 第二确定模块, 用于根据所述目标线程进行长延时操作的次数、 预设系 统权重系数、 预设权重调整策略值以及所述目标线程中目标资源的被访问频 次等确定所述目标资源的被替换权重值, 其中, 所述目标资源为所述目标线 程所占有的多线程共享资源;  a counting module, configured to count a number of times that the target thread performs a long delay operation in a preset time; a second determining module, configured to perform a long delay operation according to the target thread, a preset system weight coefficient, and a preset Determining, by the weight adjustment policy value, the accessed frequency of the target resource in the target thread, the replaced weight value of the target resource, where the target resource is a multi-thread shared resource occupied by the target thread;
分配模块, 用于根据所述被替换权重值对所述目标资源进行重新分配。 结合第二方面, 在第二方面的第一种可能的实施方式中, 所述第一确定 模块, 具体用于接收所述目标线程发送的长延时操作判断信号; 根据所述长 延时操作判断信号确定所述目标线程进行了长延时操作。 And an allocating module, configured to reallocate the target resource according to the replaced weight value. With reference to the second aspect, in a first possible implementation manner of the second aspect, the first determining module is specifically configured to receive a long delay operation determining signal sent by the target thread; The determination signal determines that the target thread has performed a long delay operation.
结合第二方面的第一种可能的实施方式, 在第二方面的第二种可能的实 施方式中, 所述长延时操作判断信号包括: 长延时操作信号, 以及与所述长 延时操作信号相应的访问信息; 所述长延时操作包括: 由于缓存缺失而访问 主存的操作, 或者, 远端共享内存的访问操作。  With reference to the first possible implementation manner of the second aspect, in the second possible implementation manner of the second aspect, the long delay operation determining signal includes: a long delay operation signal, and the long delay The corresponding access information of the operation signal; the long delay operation includes: an operation of accessing the main memory due to a cache miss, or an access operation of the remote shared memory.
结合第二方面至第二方面的第二种可能的实施方式中任一种, 在第二方 面的第三种可能的实施方式中, 所述装置还包括:  With reference to any one of the second aspect to the second possible implementation of the second aspect, in a third possible implementation manner of the second aspect, the device further includes:
获取模块, 用于在根据目标线程发送的长延时操作判断信号确定所述目 标线程进行了长延时操作之前, 获取所述预设系统权重系数和所述预设权重 调整策略值。  And an obtaining module, configured to acquire the preset system weight coefficient and the preset weight adjustment policy value before determining that the target thread performs a long delay operation according to the long delay operation judgment signal sent by the target thread.
结合第二方面, 在第二方面的第一种可能的实施方式中, 所述分配模块, 具体用于根据所述被替换权重, 让所述目标资源被优先替换, 或者降低所述 目标资源被替换的概率。  With reference to the second aspect, in a first possible implementation manner of the second aspect, the assigning module is specifically configured to: the target resource is preferentially replaced according to the replaced weight, or the target resource is reduced The probability of replacement.
本发明实施例第三方面提供一种线程共享资源分配装置, 包括: 存储器, 用于存储指令;  A third aspect of the embodiments of the present invention provides a thread sharing resource allocation apparatus, including: a memory, configured to store an instruction;
处理器, 与所述存储器耦合, 被配置为执行存储在所述存储器中的指 令, 用于根据目标线程发送的长延时操作判断信号确定所述目标线程进行了 长延时操作; 统计预设时间内所述目标线程进行长延时操作的次数; 根据所 述目标线程进行长延时操作的次数、 预设系统权重系数、 预设权重调整策略 值以及所述目标线程中目标资源的被访问频次等确定所述目标资源的被替换 权重值, 其中, 所述目标资源为所述目标线程所占有的多线程共享资源; 根 据所述被替换权重值对所述目标资源进行重新分配。  a processor, coupled to the memory, configured to execute an instruction stored in the memory, to determine that the target thread has performed a long delay operation according to a long delay operation determination signal sent by the target thread; The number of times the target thread performs a long delay operation; the number of times of the long delay operation by the target thread, the preset system weight coefficient, the preset weight adjustment policy value, and the access of the target resource in the target thread Determining, by frequency, or the like, the replaced weight value of the target resource, where the target resource is a multi-thread shared resource occupied by the target thread; and the target resource is reallocated according to the replaced weight value.
结合第三方面, 在第三方面的第一种可能的实施方式中, 所述处理器, 具体用于接收所述目标线程发送的长延时操作判断信号; 根据所述长延时操 作判断信号确定所述目标线程进行了长延时操作。  With reference to the third aspect, in a first possible implementation manner of the third aspect, the processor is configured to receive a long delay operation determination signal sent by the target thread, and determine a signal according to the long delay operation. It is determined that the target thread has performed a long delay operation.
结合第三方面的第一种可能的实施方式, 在第三方面的第二种可能的实 施方式中, 所述长延时操作判断信号包括: 长延时操作信号, 以及与所述长 延时操作信号相应的访问信息; 所述长延时操作包括: 由于缓存缺失而访问 主存的操作, 或者, 远端共享内存的访问操作。 With reference to the first possible implementation manner of the third aspect, in the second possible implementation manner of the third aspect, the long delay operation determining signal includes: a long delay operation signal, and the long delay The corresponding access information of the operation signal; the long delay operation includes: accessing due to a cache miss The main memory operation, or the access operation of the remote shared memory.
结合第三方面至第三方面的第二种可能的实施方式中任一种, 在第三方 面的第三种可能的实施方式中, 所述处理器, 还用于在根据目标线程发送的 长延时操作判断信号确定所述目标线程进行了长延时操作之前, 获取所述预 设系统权重系数和所述预设权重调整策略值。  With reference to any one of the third aspect to the second possible implementation manner of the third aspect, in a third possible implementation manner of the third aspect, the processor is further configured to send the length according to the target thread The delay operation determining signal determines that the target system weight coefficient and the preset weight adjustment policy value are obtained before the target thread performs a long delay operation.
结合第三方面, 在第三方面的第四种可能的实施方式中, 所述处理器具 体用于根据所述被替换权重, 让所述目标资源被优先替换, 或者降低所述目 标资源被替换的概率。  With reference to the third aspect, in a fourth possible implementation manner of the third aspect, the processor is specifically configured to: the target resource is preferentially replaced according to the replaced weight, or the target resource is replaced The probability.
本实施例中, 根据目标线程发送的长延时操作判断信号确定所述目标线 程进行了长延时操作, 并统计长延时操作的次数, 进而根据目标线程进行长 延时操作的次数、 预设系统权重系数、 预设权重调整策略值以及目标线程中 目标资源的被访问频次确定目标资源的被替换权重值, 根据该被替换权重值 对目标资源在需要时进行重新分配。 实现了对多线程共享资源的分配更加合 理, 根据具体情况, 让一些目标资源优先被替换, 使得其它线程可以竞争, 避免了资源的浪费, 而降低一些关键线程的重要资源被替换的概率, 避免目 标线程将一些重要资源释放后, 再使用时又得重新获取而导致目标线程性能 下降, 从而保证了目标线程的性能。 附图说明  In this embodiment, determining, according to the long delay operation judgment signal sent by the target thread, that the target thread performs a long delay operation, and counting the number of long delay operations, and then performing the long delay operation according to the target thread, The system weight coefficient, the preset weight adjustment policy value, and the accessed frequency of the target resource in the target thread determine the replaced weight value of the target resource, and the target resource is reallocated when needed according to the replaced weight value. It realizes more reasonable allocation of multi-thread shared resources. According to the specific situation, some target resources are preferentially replaced, so that other threads can compete, avoiding waste of resources, and reducing the probability that important resources of some key threads are replaced, and avoiding After the target thread releases some important resources and then reacquires it again, the target thread performance is degraded, thus ensuring the performance of the target thread. DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案, 下面将对 实施例或现有技术描述中所需要使用的附图作一简单地介绍, 显而易见 地, 下面描述中的附图是本发明的一些实施例, 对于本领域普通技术人员 来讲, 在不付出创造性劳动性的前提下, 还可以根据这些附图获得其他的 附图。  In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description of the drawings used in the embodiments or the prior art description will be briefly described below. Obviously, the drawings in the following description It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any inventive labor.
图 1为本发明提供的线程共享资源分配方法实施例一的流程示意图; 图 2为本发明提供的线程共享资源分配装置实施例一的结构示意图; 图 3为本发明提供的线程共享资源分配装置实施例二的结构示意图; 图 4为本发明提供的线程共享资源分配装置实施例三的结构示意图。 具体实施方式 为使本发明实施例的目的、 技术方案和优点更加清楚, 下面将结合本 发明实施例中的附图, 对本发明实施例中的技术方案进行清楚、 完整地描 述, 显然,所描述的实施例是本发明一部分实施例, 而不是全部的实施例。 基于本发明中的实施例, 本领域普通技术人员在没有作出创造性劳动前提 下所获得的所有其他实施例, 都属于本发明保护的范围。 1 is a schematic flowchart of Embodiment 1 of a thread sharing resource allocation method provided by the present invention; FIG. 2 is a schematic structural diagram of Embodiment 1 of a thread sharing resource allocation apparatus provided by the present invention; FIG. 3 is a schematic diagram of a thread sharing resource allocation apparatus provided by the present invention; FIG. 4 is a schematic structural diagram of Embodiment 3 of a thread sharing resource allocation apparatus according to the present invention. detailed description The technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
图 1为本发明提供的线程共享资源分配方法实施例一的流程示意图, 该 方法在多线程系统中执行, 如图 1所示, 该方法包括:  1 is a schematic flowchart of Embodiment 1 of a thread sharing resource allocation method provided by the present invention. The method is implemented in a multi-thread system. As shown in FIG. 1, the method includes:
S101、根据目标线程发送的长延时操作(Long Latency Event, 简称 LLE) 判断信号确定上述目标线程进行了长延时操作。  S101. Determine, according to the Long Latency Event (LLE) judgment signal sent by the target thread, that the target thread performs a long delay operation.
S102、 统计预设时间内上述目标线程进行长延时操作的次数。 具体地, 每进行一次长延时操作, 就在统计的次数上加 1。 即在根据长延时操作判断 信号确定出目标线程进行了长延时操作后, 就进行加 1操作。  S102. Count the number of times that the target thread performs a long delay operation within a preset time. Specifically, each time a long delay operation is performed, 1 is added to the number of statistics. That is, after determining that the target thread has performed a long delay operation according to the long delay operation judgment signal, the addition operation is performed.
具体实现过程中是周期性的进行统计, 可以通过时间窗口计时器进行计 时, 上述预设时间可以指一个周期的时间, 时间窗口计时器达到阈值时将之 前的计数清零, 即从下一个周期开始重新进行统计。  In the specific implementation process, statistics are periodically performed, and can be timed by a time window timer. The preset time can refer to a period of time. When the time window timer reaches the threshold, the previous count is cleared, that is, from the next cycle. Start recalculating.
5103、 根据上述目标线程进行长延时操作的次数、 预设系统权重系数、 预设权重调整策略值以及目标线程中目标资源的被访问频次确定该目标资源 的被替换权重值。其中, 上述目标资源为目标线程所占有的多线程共享资源。  5103. Determine, according to the number of times that the target thread performs the long delay operation, the preset system weight coefficient, the preset weight adjustment policy value, and the visited frequency of the target resource in the target thread, the replaced weight value of the target resource. The target resource is a multi-thread shared resource occupied by the target thread.
5104、 根据上述被替换权重值对上述目标资源进行重新分配。 具体地, 可以是在需要时, 对上述目标资源进行重新分配。 即并不一定在时间窗口计 时器达到阈值时就进行资源重新分配, 而是在其它线程或目标线程需要申请 新的共享资源时再进行资源重新分配。  5104. Re-allocate the target resource according to the replaced weight value. Specifically, the target resource may be reallocated when needed. That is, resource re-allocation is not necessarily performed when the time window timer reaches the threshold, but resource re-allocation is performed when other threads or target threads need to apply for new shared resources.
具体实现过程中, 上述根据上述被替换权重值对上述目标资源进行重新 分配, 可以是根据被替换权重值, 让目标资源优先被替换, 或者, 降低目标 资源被替换的概率。 即将目标线程所占有的共享资源优先替换, 或者降低目 标线程所占有的共享资源被替换的概率。 具体可以通过设置预设权重调整策 略值来实现: 例如可以设置预设权重调整策略值为 1, 来表示长延时操作越 多, 被替换权重值就越小, 长延时操作越少, 被替换权重值就越大; 设置预 设权重调整策略值为 0, 来表示长延时操作越多, 被替换权重值就越大, 长 延时操作越少, 被替换权重值就越小。 然后设置替换权重系数在一范围内时 将目标线程所占有的共享资源优先替换, 这种情况下说明这些资源对目标线 程的贡献较小或者该目标线程属于后台应用 (即它的运行时效不影响整机系 统的工作) , 将这些资源释放出去, 以便让需要这些资源的线程去竞争, 然 后该目标线程去竞争该目标线程更加需要的资源进行替换;在另一范围内时, 降低目标线程所占有的共享资源被替换的概率, 这种情况下说明这些资源对 目标线程较重要, 尽量不让这些资源被替换。 In a specific implementation process, the foregoing target resource is re-allocated according to the replaced weight value, and the target resource may be preferentially replaced according to the replaced weight value, or the probability that the target resource is replaced may be reduced. The shared resource occupied by the target thread is preferentially replaced, or the probability that the shared resource occupied by the target thread is replaced is reduced. Specifically, the preset weight adjustment policy value can be adjusted. For example, the preset weight adjustment policy value can be set to 1, indicating that the longer the long delay operation, the smaller the replaced weight value, and the less the long delay operation is. The replacement weight value is larger. Set the preset weight adjustment policy value to 0 to indicate that the longer the long delay operation, the larger the replacement weight value, and the smaller the long delay operation, the smaller the replacement weight value. Then set the replacement weight coefficient within a range The shared resources occupied by the target thread are preferentially replaced. In this case, the contribution of the resources to the target thread is small or the target thread belongs to the background application (that is, its running time does not affect the work of the whole system), and these resources are Released, in order to let the thread that needs these resources to compete, then the target thread to compete for the more needed resources of the target thread to replace; in another range, reduce the probability that the shared resources occupied by the target thread are replaced, this In this case, it is indicated that these resources are more important to the target thread, and try not to let these resources be replaced.
本实施例中, 根据目标线程发送的长延时操作判断信号确定所述目标线 程进行了长延时操作, 并统计长延时操作的次数, 进而根据目标线程进行长 延时操作的次数、 预设系统权重系数、 预设权重调整策略值以及目标线程中 目标资源的被访问频次确定目标资源的被替换权重值, 根据该被替换权重值 对目标资源在需要时进行重新分配。 实现了对多线程共享资源的分配更加合 理, 根据具体情况, 让一些目标资源优先被替换, 使得其它线程可以竞争, 避免了资源的浪费, 而降低一些关键线程的重要资源被替换的概率, 避免目 标线程将一些重要资源释放后, 再使用时又得重新获取而导致目标线程性能 下降, 从而保证了目标线程的性能。  In this embodiment, determining, according to the long delay operation judgment signal sent by the target thread, that the target thread performs a long delay operation, and counting the number of long delay operations, and then performing the long delay operation according to the target thread, The system weight coefficient, the preset weight adjustment policy value, and the accessed frequency of the target resource in the target thread determine the replaced weight value of the target resource, and the target resource is reallocated when needed according to the replaced weight value. It realizes more reasonable allocation of multi-thread shared resources. According to the specific situation, some target resources are preferentially replaced, so that other threads can compete, avoiding waste of resources, and reducing the probability that important resources of some key threads are replaced, and avoiding After the target thread releases some important resources and then reacquires it again, the target thread performance is degraded, thus ensuring the performance of the target thread.
进一步地, 上述根据目标线程发送的 LLE判断信号确定上述目标线程进 行了长延时操作, 具体为: 接收上述目标线程发送的 LLE判断信号; 根据该 LLE判断信号确定上述目标线程进行了长延时操作。  Further, the foregoing determining, according to the LLE determination signal sent by the target thread, that the target thread performs a long delay operation, specifically: receiving an LLE determination signal sent by the target thread; determining, according to the LLE determination signal, that the target thread performs a long delay operating.
具体地, 本发明实施例中, 长延时操作具体指需要几十个甚至几百个处 理器时钟才能返回结果的操作, 可以包括: 由于缓存缺失而访问主存的操作, 或者, 远端共享内存的访问操作, 但是并不以此为限。 当目标线程发生延时 较长的操作时, 例如: 末级缓存丢失、 远端数据访问等, 目标线程会发送长 延时操作判断信号, 可以将该 LLE判断信号发送给本发明实施例提供的线程 共享资源分配装置, 由装置中的长延时判断模块进行判断, 长延时判断模块 可以根据判断信号判断出是否是长延时操作, 如果是长延时操作, 则将目标 线程进行长延时操作的次数加 1。 需要说明的是, 上述长延时操作判断信号 可以包括: 上述长延时操作信号(LLE-like) , 以及该长延时操作信号相应的 访问信息。 其中相应的访问信息可以是: 访问请求、 该访问的目标地址信息、 读写信息、 该访问的目标线程信息等。 具体实现过程中, 哪些信号可以用于 判断 LLE, 可以由整机系统根据实际需要进行配置。 更进一步地, 上述根据目标线程发送的 LLE判断信号确定上述目标线程 进行了长延时操作之前, 还包括获取上述预设系统权重系数和预设权重调整 策略值。 具体实施过程中, 预设系统权重系数和预设权重调整策略都是系统 管理员根据整机系统的应用需求进行配置的, 例如: 根据应用场景, 设置预 设权重调整策略值为 1, 来表示长延时操作越多, 替换权重值就越小, 长延 时操作越少, 替换权重值就越大; 设置预设权重调整策略值为 0, 来表示长 延时操作越多, 替换权重值就越大, 长延时操作越少, 替换权重值就越小。 但并不以此为限, 而且, 上述系统管理员还可以在系统运行过程中根据实际 情况动态调整上述设置。 Specifically, in the embodiment of the present invention, the long delay operation specifically refers to an operation that requires dozens or even hundreds of processor clocks to return a result, and may include: accessing a main memory operation due to a cache miss, or remote sharing Memory access operations, but not limited to this. When the target thread has a long-delay operation, for example, the last-level cache is lost, the remote data is accessed, and the like, the target thread sends a long-delay operation determination signal, and the LLE determination signal can be sent to the embodiment of the present invention. The thread sharing resource allocation device is judged by the long delay judging module in the device, and the long delay judging module can judge whether the long delay operation is based on the judgment signal, and if the long delay operation is performed, the target thread is extended. The number of operations is increased by one. It should be noted that the long delay operation determination signal may include: the long delay operation signal (LLE-like), and the corresponding access information of the long delay operation signal. The corresponding access information may be: an access request, target address information of the access, read and write information, target thread information of the access, and the like. In the specific implementation process, which signals can be used to judge the LLE, can be configured by the whole system according to actual needs. Further, before determining that the target thread performs the long delay operation according to the LLE determination signal sent by the target thread, the method further includes acquiring the preset system weight coefficient and the preset weight adjustment policy value. In the specific implementation process, the preset system weight coefficient and the preset weight adjustment strategy are configured by the system administrator according to the application requirements of the whole system, for example, according to the application scenario, setting the preset weight adjustment policy value to 1, to represent The longer the long delay operation, the smaller the replacement weight value. The smaller the long delay operation, the larger the replacement weight value. Set the preset weight adjustment policy value to 0 to indicate that the long delay operation is more, and the replacement weight value is replaced. The larger, the less the long delay operation, the smaller the replacement weight value. However, it is not limited to this, and the above system administrator can also dynamically adjust the above settings according to actual conditions during system operation.
具体实现过程中, 举例说明根据上述目标线程进行长延时操作的次数、 预设系统权重系数、 预设权重调整策略以及目标线程中目标资源的被访问频 次确定该目标资源的被替换权重值, 该例中权重调整策略值为 1, 来表示长 延时操作越多, 替换权重值就越小, 长延时操作越少, 替换权重值就越大。 记预设权重调整策略值为 W _ Wr(0, 记预设系统权重系数为 W(0, 记目标线程 中目标资源的被访问频次为 Re c fy(0, 记目标线程进行长延时操作的次数为 LLe _ cnt(i) , 可以根据下述公式计算目标资源的被替换权重值 C。W(0: ( 1 )如 果 W _ str(i) = 1, Cost(i) = W(i) I LLe _ cnt(i) * Re cenly(i); ( 2 ) 如果 W _ str(i) = 0, Cost(i) = W(i) * Re cenly(i) * LLe _ cnt(i) 其中 "*,,表示乘号, 'Τ表示除号。  In the specific implementation process, the number of times of performing the long delay operation, the preset system weight coefficient, the preset weight adjustment policy, and the visited frequency of the target resource in the target thread are determined by using the target thread to determine the replaced weight value of the target resource. In this example, the weight adjustment policy value is 1, to indicate that the longer the long delay operation, the smaller the replacement weight value, and the smaller the long delay operation, the larger the replacement weight value. The default weight adjustment policy value is W _ Wr (0, the default system weight coefficient is W (0, the target frequency of the target resource in the target thread is Re c fy (0, the target thread performs long delay operation). The number of times is LLe _ cnt(i) , and the replaced weight value C of the target resource can be calculated according to the following formula: W(0: ( 1 ) If W _ str(i) = 1, Cost(i) = W(i I LLe _ cnt(i) * Re cenly(i); ( 2 ) If W _ str(i) = 0, Cost(i) = W(i) * Re cenly(i) * LLe _ cnt(i) Where "*,, means multiplication, and 'Τ" means division.
对上述实施例举例说明, 应用过程中: (1 )正常情况下, 设置合理的预 设系统权重系数和预设权重调整策略值, 使得长延时操作频率越高, 目标资 源被优先替换的概率越大, 以减少目标线程对多线程系统中其它线程的干扰。  For example, in the application process, in the application process: (1) Under normal circumstances, a reasonable preset system weight coefficient and a preset weight adjustment policy value are set, so that the higher the long delay operation frequency, the probability that the target resource is preferentially replaced. The larger, to reduce the interference of the target thread to other threads in the multi-threaded system.
(2) 以 SMT处理器中的缓存资源举例说明, 某些应用中, 在可以关闭或者 没有第二级或者第三级 (L2/L3 ) 等的缓存 (cache) 的情况下, 应当调整预 设系统权重系数, 使第一级缓存中的缓存行(Cache Line)尽量降低因为其他 线程的长延时操作而反复被替换出去的概率, 以免带来的代价 (penalty) 太 大。需要说明的是,这里各线程对第一级缓存中的资源的竞争是以 Cache Line 为单位的。 (3 )某些时刻, 系统中同时运行的线程数比较少, 此时多线程之 间共享资源的竞争较小, 可以调整预设系统权重值, 尽量降低目标资源被替 换的概率, 减少目标线程中资源的换入换出。 (4)上述预设时间的长短也会 影响替换权重值的调整频度, 某些应用场景下, 设置较小的预设时间, 即统 计的周期较小, 这样可以在较短的时间内调整替换权重值。 (2) Take the example of the cache resource in the SMT processor. In some applications, the preset should be adjusted if the cache of the second or third level (L2/L3) can be turned off or not. The system weight coefficient makes the cache line in the first level cache as low as possible because of the long delay operation of other threads, so that the penalty is too large. It should be noted that the competition of resources in the first level cache by each thread is based on the Cache Line. (3) At some time, the number of threads running simultaneously in the system is relatively small. At this time, the competition of shared resources among multiple threads is small. The preset system weight value can be adjusted to minimize the probability of target resources being replaced, and the target thread is reduced. Exchange and exchange of resources. (4) The length of the preset time also affects the adjustment frequency of the replacement weight value. In some application scenarios, a smaller preset time is set. The period of the meter is small, so that the replacement weight value can be adjusted in a shorter time.
本领域普通技术人员可以理解: 实现上述方法实施例的全部或部分步骤 可以通过程序指令相关的硬件来完成, 前述的程序可以存储于一计算机可读 取存储介质中, 该程序在执行时, 执行包括上述方法实施例的步骤; 而前述 的存储介质包括: ROM、 RAM, 磁碟或者光盘等各种可以存储程序代码的介 质。  A person skilled in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by using hardware related to program instructions, and the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed. The foregoing steps include the steps of the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
图 2为本发明提供的线程共享资源分配装置实施例一的结构示意图, 如 图 2所示, 该装置包括: 第一确定模块 201、 计数模块 202、 第二确定模块 203和分配模块 204。 其中:  FIG. 2 is a schematic structural diagram of Embodiment 1 of a thread sharing resource allocation apparatus according to the present invention. As shown in FIG. 2, the apparatus includes: a first determining module 201, a counting module 202, a second determining module 203, and an allocating module 204. among them:
第一确定模块 201, 用于根据目标线程发送的长延时操作判断信号确定 所述目标线程进行了长延时操作。  The first determining module 201 is configured to determine, according to the long delay operation determining signal sent by the target thread, that the target thread performs a long delay operation.
计数模块 202, 用于统计预设时间内所述目标线程进行长延时操作的次 数。  The counting module 202 is configured to count the number of times the target thread performs a long delay operation within a preset time.
第二确定模块 203, 用于根据所述目标线程进行长延时操作的次数、 预 设系统权重系数、 预设权重调整策略值以及所述目标线程中目标资源的被访 问频次等确定所述目标资源的被替换权重值, 其中, 所述目标资源为所述目 标线程所占有的多线程共享资源。  The second determining module 203 is configured to determine the target according to the number of times the target thread performs a long delay operation, a preset system weight coefficient, a preset weight adjustment policy value, and an accessed frequency of a target resource in the target thread. The replaced weight value of the resource, where the target resource is a multi-thread shared resource occupied by the target thread.
分配模块 204, 用于根据所述被替换权重值对所述目标资源进行重新分 配。  The allocating module 204 is configured to re-allocate the target resource according to the replaced weight value.
进一步地, 第一确定模块 201, 具体用于接收所述目标线程发送的长延 时操作判断信号; 根据所述长延时操作判断信号确定所述目标线程进行了长 延时操作。  Further, the first determining module 201 is specifically configured to receive a long delay operation determining signal sent by the target thread, and determine, according to the long delay operation determining signal, that the target thread performs a long delay operation.
需要说明的是, 所述长延时操作判断信号包括: 长延时操作信号, 以及 与所述长延时操作信号相应的访问信息; 所述长延时操作包括: 由于缓存缺 失而访问主存的操作, 或者, 远端共享内存的访问操作。  It should be noted that the long delay operation determination signal includes: a long delay operation signal, and access information corresponding to the long delay operation signal; the long delay operation includes: accessing the main memory due to a cache miss The operation, or access operation of the remote shared memory.
图 3为本发明提供的线程共享资源分配装置实施例二的结构示意图, 在 图 2的基础上, 该装置包括:  FIG. 3 is a schematic structural diagram of Embodiment 2 of a thread sharing resource allocation apparatus according to the present invention. On the basis of FIG. 2, the apparatus includes:
获取模块 205, 用于在根据目标线程发送的长延时操作判断信号确定所 述目标线程进行了长延时操作之前, 获取所述预设系统权重系数和所述预设 权重调整策略值。 另外, 上述分配模块 204, 具体用于根据所述被替换权重, 让所述目标 资源被优先替换, 或者降低所述目标资源被替换的概率。 The obtaining module 205 is configured to obtain the preset system weight coefficient and the preset weight adjustment policy value before determining that the target thread performs a long delay operation according to the long delay operation determining signal sent by the target thread. In addition, the foregoing allocation module 204 is specifically configured to: the target resource is preferentially replaced according to the replaced weight, or the probability that the target resource is replaced is reduced.
上述各模块用于执行前述方法实施例, 其实现原理和技术效果类似, 在 此不再赘述。  The foregoing modules are used to implement the foregoing method embodiments, and the implementation principles and technical effects are similar, and details are not described herein again.
图 4为本发明提供的线程共享资源分配装置实施例三的结构示意图, 如 图 4所示, 该装置包括: 存储器 401和处理器 402, 其中,  4 is a schematic structural diagram of Embodiment 3 of a thread sharing resource allocation apparatus according to the present invention. As shown in FIG. 4, the apparatus includes: a memory 401 and a processor 402, where
存储器 401, 用于存储指令。  The memory 401 is configured to store an instruction.
处理器 402, 与存储器 401耦合, 被配置为执行存储在存储器 401中的 指令, 具体地, 用于根据目标线程发送的长延时操作判断信号确定所述目标 线程进行了长延时操作; 统计预设时间内所述目标线程进行长延时操作的次 数; 根据所述目标线程进行长延时操作的次数、 预设系统权重系数、 预设权 重调整策略值以及所述目标线程中目标资源的被访问频次等确定所述目标资 源的被替换权重值, 其中, 所述目标资源为所述目标线程所占有的多线程共 享资源; 根据所述被替换权重值对所述目标资源进行重新分配。  The processor 402, coupled to the memory 401, is configured to execute an instruction stored in the memory 401, specifically, configured to determine, according to the long delay operation determination signal sent by the target thread, that the target thread performs a long delay operation; The number of times the target thread performs a long delay operation within a preset time; the number of times of the long delay operation by the target thread, the preset system weight coefficient, the preset weight adjustment policy value, and the target resource in the target thread The replaced weight value of the target resource is determined by the frequency of access, etc., wherein the target resource is a multi-thread shared resource occupied by the target thread; and the target resource is reallocated according to the replaced weight value.
进一步地, 上述处理器 402, 具体用于接收所述目标线程发送的长延时 操作判断信号; 根据所述长延时操作判断信号确定所述目标线程进行了长延 时操作。  Further, the processor 402 is specifically configured to receive a long delay operation determination signal sent by the target thread, and determine, according to the long delay operation determination signal, that the target thread performs a long delay operation.
处理器 402, 具体用于根据所述被替换权重, 让所述目标资源被优先替 换, 或者降低所述目标资源被替换的概率。  The processor 402 is specifically configured to: the target resource is preferentially replaced according to the replaced weight, or reduce a probability that the target resource is replaced.
需要说明的是, 所述长延时操作判断信号包括: 长延时操作信号, 以及 与所述长延时操作信号相应的访问信息; 所述长延时操作包括: 由于缓存缺 失而访问主存的操作, 或者, 远端共享内存的访问操作。  It should be noted that the long delay operation determination signal includes: a long delay operation signal, and access information corresponding to the long delay operation signal; the long delay operation includes: accessing the main memory due to a cache miss The operation, or access operation of the remote shared memory.
另外, 上述处理器 402, 还用于在根据目标线程发送的长延时操作判断 信号确定所述目标线程进行了长延时操作之前, 获取所述预设系统权重系数 和所述预设权重调整策略值。  In addition, the processor 402 is further configured to acquire the preset system weight coefficient and the preset weight adjustment before determining that the target thread performs a long delay operation according to the long delay operation determination signal sent by the target thread. Policy value.
最后应说明的是: 以上各实施例仅用以说明本发明的技术方案, 而非对 其限制; 尽管参照前述各实施例对本发明进行了详细的说明, 本领域的普通 技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改, 或者对其中部分或者全部技术特征进行等同替换; 而这些修改或者替换, 并 不使相应技术方案的本质脱离本发明各实施例技术方案的范围。  Finally, it should be noted that the above embodiments are only for explaining the technical solutions of the present invention, and are not intended to be limiting thereof; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will understand that The technical solutions described in the foregoing embodiments may be modified, or some or all of the technical features may be equivalently replaced; and the modifications or substitutions do not deviate from the technical solutions of the embodiments of the present invention. range.

Claims

权 利 要 求 书 claims
1、 一种线程共享资源分配方法, 其特征在于, 包括: 1. A thread shared resource allocation method, characterized by including:
根据目标线程发送的长延时操作判断信号确定所述目标线程进行了长延 时操作; Determine that the target thread has performed a long-delay operation based on the long-delay operation judgment signal sent by the target thread;
统计预设时间内所述目标线程进行长延时操作的次数; Count the number of long-delay operations performed by the target thread within the preset time;
根据所述目标线程进行长延时操作的次数、 预设系统权重系数、 预设权 重调整策略值以及所述目标线程中目标资源的被访问频次等确定所述目标资 源的被替换权重值, 其中, 所述目标资源为所述目标线程所占有的多线程共 享资源; The replaced weight value of the target resource is determined according to the number of long-delay operations performed by the target thread, the preset system weight coefficient, the preset weight adjustment strategy value, and the access frequency of the target resource in the target thread, where , the target resource is a multi-thread shared resource occupied by the target thread;
根据所述被替换权重值对所述目标资源进行重新分配。 The target resource is reallocated according to the replaced weight value.
2、 根据权利要求 1所述的方法, 其特征在于, 根据目标线程发送的长延 时操作判断信号确定所述目标线程进行了长延时操作, 包括: 2. The method according to claim 1, characterized in that determining that the target thread has performed a long-delay operation based on the long-delay operation judgment signal sent by the target thread includes:
接收所述目标线程发送的长延时操作判断信号; Receive the long-delay operation judgment signal sent by the target thread;
根据所述长延时操作判断信号确定所述目标线程进行了长延时操作。 It is determined according to the long-delay operation judgment signal that the target thread has performed a long-delay operation.
3、 根据权利要求 2所述的方法, 其特征在于, 所述长延时操作判断信号 包括: 长延时操作信号, 以及与所述长延时操作信号相应的访问信息; 所述 长延时操作包括: 由于缓存缺失而访问主存的操作, 或者, 远端共享内存的 访问操作。 3. The method according to claim 2, characterized in that, the long delay operation judgment signal includes: a long delay operation signal, and access information corresponding to the long delay operation signal; the long delay operation signal Operations include: accessing main memory due to cache misses, or accessing remote shared memory.
4、 根据权利要求 1-3任一项所述的方法, 其特征在于, 所述根据目标线 程发送的长延时操作判断信号确定所述目标线程进行了长延时操作之前, 还 包括: 4. The method according to any one of claims 1-3, characterized in that, before determining that the target thread has performed a long-delay operation based on the long-delay operation judgment signal sent by the target thread, it further includes:
获取所述预设系统权重系数和所述预设权重调整策略值。 Obtain the preset system weight coefficient and the preset weight adjustment strategy value.
5、 根据权利要求 1所述的方法, 其特征在于, 所述根据所述被替换权重 对所述目标资源进行重新分配, 包括: 5. The method according to claim 1, characterized in that: redistributing the target resource according to the replaced weight includes:
根据所述被替换权重, 让所述目标资源被优先替换, 或者降低所述目标 资源被替换的概率。 According to the replacement weight, the target resource is replaced with priority, or the probability of the target resource being replaced is reduced.
6、 一种线程共享资源分配装置, 其特征在于, 包括: 6. A thread shared resource allocation device, characterized by including:
第一确定模块, 用于根据目标线程发送的长延时操作判断信号确定所述 目标线程进行了长延时操作; The first determination module is used to determine that the target thread has performed a long-delay operation based on the long-delay operation judgment signal sent by the target thread;
计数模块, 用于统计预设时间内所述目标线程进行长延时操作的次数; 第二确定模块, 用于根据所述目标线程进行长延时操作的次数、 预设系 统权重系数、 预设权重调整策略值以及所述目标线程中目标资源的被访问频 次等确定所述目标资源的被替换权重值, 其中, 所述目标资源为所述目标线 程所占有的多线程共享资源; A counting module used to count the number of long-delay operations performed by the target thread within a preset time; The second determination module is used to determine the target resource based on the number of long-delay operations performed by the target thread, the preset system weight coefficient, the preset weight adjustment strategy value, and the access frequency of the target resource in the target thread. The replaced weight value of , wherein the target resource is a multi-thread shared resource occupied by the target thread;
分配模块, 用于根据所述被替换权重值对所述目标资源进行重新分配。 An allocation module, configured to reallocate the target resource according to the replaced weight value.
7、 根据权利要求 6所述的装置, 其特征在于, 所述第一确定模块, 具体 用于接收所述目标线程发送的长延时操作判断信号; 根据所述长延时操作判 断信号确定所述目标线程进行了长延时操作。 7. The device according to claim 6, wherein the first determination module is specifically configured to receive a long-delay operation judgment signal sent by the target thread; and determine the long-delay operation judgment signal according to the long-delay operation judgment signal. The above target thread performed a long-delay operation.
8、 根据权利要求 7所述的装置, 其特征在于, 所述长延时操作判断信号 包括: 长延时操作信号, 以及与所述长延时操作信号相应的访问信息; 所述 长延时操作包括: 由于缓存缺失而访问主存的操作, 或者, 远端共享内存的 访问操作。 8. The device according to claim 7, wherein the long delay operation judgment signal includes: a long delay operation signal, and access information corresponding to the long delay operation signal; the long delay operation signal Operations include: accessing main memory due to cache misses, or accessing remote shared memory.
9、 根据权利要求 6-8任一项所述的装置, 其特征在于, 还包括: 获取模块, 用于在根据目标线程发送的长延时操作判断信号确定所述目 标线程进行了长延时操作之前, 获取所述预设系统权重系数和所述预设权重 调整策略值。 9. The device according to any one of claims 6 to 8, further comprising: an acquisition module, configured to determine that the target thread has performed a long delay based on the long delay operation judgment signal sent by the target thread. Before operation, obtain the preset system weight coefficient and the preset weight adjustment strategy value.
10、 根据权利要求 6所述的装置, 其特征在于, 所述分配模块, 具体用 于根据所述被替换权重, 让所述目标资源被优先替换, 或者降低所述目标资 源被替换的概率。 10. The device according to claim 6, characterized in that the allocation module is specifically configured to allow the target resource to be replaced first according to the replacement weight, or to reduce the probability of the target resource being replaced.
11、 一种线程共享资源分配装置, 其特征在于, 包括: 11. A thread shared resource allocation device, characterized by including:
存储器, 用于存储指令; Memory, used to store instructions;
处理器, 与所述存储器耦合, 被配置为执行存储在所述存储器中的指 令, 用于根据目标线程发送的长延时操作判断信号确定所述目标线程进行了 长延时操作; 统计预设时间内所述目标线程进行长延时操作的次数; 根据所 述目标线程进行长延时操作的次数、 预设系统权重系数、 预设权重调整策略 值以及所述目标线程中目标资源的被访问频次等确定所述目标资源的被替换 权重值, 其中, 所述目标资源为所述目标线程所占有的多线程共享资源; 根 据所述被替换权重值对所述目标资源进行重新分配。 A processor, coupled to the memory, configured to execute instructions stored in the memory, for determining that the target thread has performed a long-delay operation based on a long-delay operation judgment signal sent by the target thread; statistical preset The number of times the target thread performs long-delay operations within the time period; According to the number of times the target thread performs long-delay operations, the preset system weight coefficient, the preset weight adjustment strategy value, and the access of the target resource in the target thread Frequency, etc. determine the replaced weight value of the target resource, wherein the target resource is a multi-thread shared resource occupied by the target thread; the target resource is reallocated according to the replaced weight value.
12、 根据权利要求 11所述的装置, 其特征在于, 所述处理器, 具体用于 接收所述目标线程发送的长延时操作判断信号; 根据所述长延时操作判断信 号确定所述目标线程进行了长延时操作。 12. The device according to claim 11, wherein the processor is specifically configured to receive a long-delay operation judgment signal sent by the target thread; and based on the long-delay operation judgment signal No. It is determined that the target thread has performed a long-delay operation.
13、 根据权利要求 12所述的装置, 其特征在于, 所述长延时操作判断信 号包括: 长延时操作信号, 以及与所述长延时操作信号相应的访问信息; 所 述长延时操作包括: 由于缓存缺失而访问主存的操作, 或者, 远端共享内存 的访问操作。 13. The device according to claim 12, wherein the long delay operation judgment signal includes: a long delay operation signal, and access information corresponding to the long delay operation signal; the long delay operation signal Operations include: accessing main memory due to cache misses, or accessing remote shared memory.
14、 根据权利要求 11-13任一项所述的装置, 其特征在于, 所述处理器, 还用于在根据目标线程发送的长延时操作判断信号确定所述目标线程进行了 长延时操作之前, 获取所述预设系统权重系数和所述预设权重调整策略值。 14. The device according to any one of claims 11 to 13, wherein the processor is further configured to determine that the target thread has performed a long delay based on the long delay operation judgment signal sent by the target thread. Before operation, obtain the preset system weight coefficient and the preset weight adjustment strategy value.
15、 根据权利要求 11 所述的装置, 其特征在于, 所述处理器具体用 于根据所述被替换权重, 让所述目标资源被优先替换, 或者降低所述目标资 源被替换的概率。 15. The apparatus according to claim 11, wherein the processor is specifically configured to allow the target resource to be replaced first according to the replacement weight, or to reduce the probability of the target resource being replaced.
PCT/CN2013/090326 2013-12-24 2013-12-24 Method and apparatus for allocating thread shared resource WO2015096031A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201380077895.2A CN105378652B (en) 2013-12-24 2013-12-24 Thread shared resource distribution method and device
PCT/CN2013/090326 WO2015096031A1 (en) 2013-12-24 2013-12-24 Method and apparatus for allocating thread shared resource

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2013/090326 WO2015096031A1 (en) 2013-12-24 2013-12-24 Method and apparatus for allocating thread shared resource

Publications (1)

Publication Number Publication Date
WO2015096031A1 true WO2015096031A1 (en) 2015-07-02

Family

ID=53477311

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/090326 WO2015096031A1 (en) 2013-12-24 2013-12-24 Method and apparatus for allocating thread shared resource

Country Status (2)

Country Link
CN (1) CN105378652B (en)
WO (1) WO2015096031A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017016480A1 (en) * 2015-07-27 2017-02-02 Huawei Technologies Co., Ltd. System and method for multithreaded processing

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109308220B (en) * 2017-07-26 2021-12-14 华为技术有限公司 Shared resource allocation method and device
CN109874027A (en) * 2019-03-11 2019-06-11 宸瑞普惠(广州)科技有限公司 A kind of low delay educational surgery demonstration live broadcasting method and its system
CN114138685B (en) * 2021-12-06 2023-03-10 海光信息技术股份有限公司 Cache resource allocation method and device, electronic device and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1955920A (en) * 2005-10-28 2007-05-02 国际商业机器公司 Method and apparatus for resource-based thread allocation in a multiprocessor computer system
CN101826003A (en) * 2010-04-16 2010-09-08 中兴通讯股份有限公司 Multithread processing method and device
US20130290675A1 (en) * 2012-04-26 2013-10-31 Yuan C. Chou Mitigation of thread hogs on a threaded processor

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040111594A1 (en) * 2002-12-05 2004-06-10 International Business Machines Corporation Multithreading recycle and dispatch mechanism
US7984248B2 (en) * 2004-12-29 2011-07-19 Intel Corporation Transaction based shared data operations in a multiprocessor environment
US8369356B2 (en) * 2007-03-21 2013-02-05 Qualcomm Incorporated Dynamic management of receiver resources
CN103440173B (en) * 2013-08-23 2016-09-21 华为技术有限公司 The dispatching method of a kind of polycaryon processor and relevant apparatus

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1955920A (en) * 2005-10-28 2007-05-02 国际商业机器公司 Method and apparatus for resource-based thread allocation in a multiprocessor computer system
CN101826003A (en) * 2010-04-16 2010-09-08 中兴通讯股份有限公司 Multithread processing method and device
US20130290675A1 (en) * 2012-04-26 2013-10-31 Yuan C. Chou Mitigation of thread hogs on a threaded processor

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017016480A1 (en) * 2015-07-27 2017-02-02 Huawei Technologies Co., Ltd. System and method for multithreaded processing
CN107924327A (en) * 2015-07-27 2018-04-17 华为技术有限公司 System and method for multiple threads
US10176014B2 (en) 2015-07-27 2019-01-08 Futurewei Technologies, Inc. System and method for multithreaded processing

Also Published As

Publication number Publication date
CN105378652B (en) 2018-02-06
CN105378652A (en) 2016-03-02

Similar Documents

Publication Publication Date Title
Usui et al. DASH: Deadline-aware high-performance memory scheduler for heterogeneous systems with hardware accelerators
US8141083B2 (en) Method, apparatus, and computer program product for providing a self-tunable parameter used for dynamically yielding an idle processor
Kim et al. Bounding memory interference delay in COTS-based multi-core systems
US8881157B2 (en) Allocating threads to cores based on threads falling behind thread completion target deadline
US10592279B2 (en) Multi-processor apparatus and method of detection and acceleration of lagging tasks
US8898434B2 (en) Optimizing system throughput by automatically altering thread co-execution based on operating system directives
US8219993B2 (en) Frequency scaling of processing unit based on aggregate thread CPI metric
US10241889B2 (en) Tracking pipelined activity during off-core memory accesses to evaluate the impact of processor core frequency changes
US20150058522A1 (en) Detection of hot pages for partition migration
US20130212594A1 (en) Method of optimizing performance of hierarchical multi-core processor and multi-core processor system for performing the method
US20130198758A1 (en) Task distribution method and apparatus for multi-core system
US20110161978A1 (en) Job allocation method and apparatus for a multi-core system
JP2017526996A5 (en)
US7895596B2 (en) Processor assignment in multi-processor systems
US20130246781A1 (en) Multi-core system energy consumption optimization
US20150058521A1 (en) Detection of hot pages for partition hibernation
WO2012008073A1 (en) Shared memory system and method of controlling same
WO2013044829A1 (en) Data readahead method and device for non-uniform memory access
WO2012016439A1 (en) Method, device and equipment for service management
JP6580307B2 (en) Multi-core apparatus and job scheduling method for multi-core apparatus
JP2011059777A (en) Task scheduling method and multi-core system
CN109308220B (en) Shared resource allocation method and device
WO2015096031A1 (en) Method and apparatus for allocating thread shared resource
US8671232B1 (en) System and method for dynamically migrating stash transactions
US8255721B2 (en) Seamless frequency sequestering

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 13900330

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 13900330

Country of ref document: EP

Kind code of ref document: A1