Thread priority control methods, devices, computer equipment, readable storage media, and program products
By setting the highest and lowest priorities in the container configuration structure, the problem of thread priority conflict in the container environment is resolved, achieving efficient resource allocation and improved system real-time performance.
Patent Information
- Application Number
- CN202411616009.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2044-11-13
AI Technical Summary
In a multi-container environment, existing technologies lack fine-grained real-time scheduling capabilities, leading to conflicts in thread priority configurations within different containers. Low-priority threads preempt CPU resources, affecting the real-time response of high-priority tasks and causing overall system real-time performance instability.
By predetermining the container configuration structure, setting the highest and lowest priorities for each container, determining the priority range, responding to thread creation operations, verifying and determining the thread priority parameters, ensuring that they are within a reasonable range, and avoiding uncontrolled resource contention.
It ensures the resource access rights of high-priority tasks, reduces the obstruction of critical tasks by low-priority tasks, and improves the real-time performance and resource scheduling efficiency of the system.
Smart Images

Figure CN119597420B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of container technology, and in particular to a thread priority control method, apparatus, computer device, computer-readable storage medium, and computer program product. Background Technology
[0002] With the development of container technology, container-based real-time systems have emerged. This technology is characterized by its lightweight nature and strong isolation, enabling the deployment of different applications in multi-container environments. However, it lacks fine-grained real-time scheduling capabilities. In current container scheduling methods, thread priority configurations within different containers are prone to conflict. The lack of fine-grained real-time scheduling capabilities leads to low-priority threads unreasonably preempting CPU resources during CPU resource allocation, thus affecting the real-time response of high-priority tasks and causing overall system real-time performance instability. Summary of the Invention
[0003] Therefore, it is necessary to provide a thread priority control method, apparatus, computer device, computer-readable storage medium, and computer program product that can improve the real-time performance of the above-mentioned technical problems.
[0004] Firstly, this application provides a thread priority control method, including:
[0005] By using a pre-determined container configuration structure, the highest and lowest priorities of container threads within multiple containers are determined, and the priority range corresponding to the container is determined based on the highest and lowest priorities.
[0006] In response to a thread creation operation, determine the priority parameters of the currently created thread;
[0007] If the priority parameter falls within the priority range, then the priority parameter is used as the priority control parameter for the thread in the container.
[0008] If the priority parameter is higher than the highest priority of the container thread, then the highest priority is used as the priority control parameter of the thread in the container;
[0009] If the priority parameter is lower than the lowest priority of the container thread, then the lowest priority is used as the priority control parameter of the thread in the container.
[0010] In one embodiment, the method further includes: determining the default priority of the container threads within a plurality of containers through the container configuration structure;
[0011] In response to the thread creation operation, if the thread priority parameter fails to be determined, the thread is controlled in the container according to the default priority of the container thread.
[0012] In one embodiment, determining the highest and lowest priorities of container threads within multiple containers using a pre-determined container configuration structure includes:
[0013] Determine the current running configuration corresponding to the container configuration structure, and adjust the current running configuration through the priority management interface to obtain the target running configuration;
[0014] Based on the state of the container, the adjusted target runtime configuration is applied to the container, and the highest and lowest priorities of the container threads are determined.
[0015] In one embodiment, applying the adjusted target runtime configuration to the container based on the container's state, and determining the highest and lowest priorities of the container threads, includes:
[0016] If the container's status indicates that the container has not been started, then according to the target runtime configuration, the container is created, and the highest and lowest priorities of the container threads are determined;
[0017] If the container's status indicates that the container is running, then a new highest priority and lowest priority are determined based on the target highest priority and target lowest priority in the target running configuration.
[0018] In one embodiment, the method further includes:
[0019] The container configuration structure is used to determine the multiple processing core units corresponding to the container;
[0020] Based on the priority control parameters and the load status of the processing core unit, the processing core unit to which the thread corresponding to the priority control parameters is bound is determined.
[0021] In one embodiment, after determining the processing core unit to which the thread is bound according to the priority control parameter based on the priority control parameter and the load state of the processing core unit, the method further includes:
[0022] The load status of the processing core unit is detected to obtain the load status detection result;
[0023] If the load status detection result indicates that the processing core unit is overloaded, the thread corresponding to the highest priority control parameter is bound to the processing core unit according to the priority control parameters, and the threads other than the thread corresponding to the highest priority control parameter are unbound from the processing core unit.
[0024] Secondly, this application also provides a thread priority control device, including:
[0025] The container priority range setting module is used to determine the highest and lowest priorities of container threads within multiple containers based on a pre-defined container configuration structure, and to determine the corresponding priority range of the container based on the highest and lowest priorities.
[0026] The thread priority parameter determination module is used to respond to thread creation operations and determine the priority parameters of the currently created thread;
[0027] The priority range matching module is used to use the priority parameter as the priority control parameter for the thread in the container if the priority parameter belongs to the priority range.
[0028] The high-priority boundary control module is used to use the highest priority as the priority control parameter for the thread in the container if the priority parameter is higher than the highest priority of the container thread.
[0029] The low-priority boundary control module is used to use the lowest priority as the priority control parameter for the thread in the container if the priority parameter is lower than the lowest priority of the container thread.
[0030] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0031] By using a pre-determined container configuration structure, the highest and lowest priorities of container threads within multiple containers are determined, and the priority range corresponding to the container is determined based on the highest and lowest priorities.
[0032] In response to a thread creation operation, determine the priority parameters of the currently created thread;
[0033] If the priority parameter falls within the priority range, then the priority parameter is used as the priority control parameter for the thread in the container.
[0034] If the priority parameter is higher than the highest priority of the container thread, then the highest priority is used as the priority control parameter of the thread in the container;
[0035] If the priority parameter is lower than the lowest priority of the container thread, then the lowest priority is used as the priority control parameter of the thread in the container.
[0036] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0037] By using a pre-determined container configuration structure, the highest and lowest priorities of container threads within multiple containers are determined, and the priority range corresponding to the container is determined based on the highest and lowest priorities.
[0038] In response to a thread creation operation, determine the priority parameters of the currently created thread;
[0039] If the priority parameter falls within the priority range, then the priority parameter is used as the priority control parameter for the thread in the container.
[0040] If the priority parameter is higher than the highest priority of the container thread, then the highest priority is used as the priority control parameter of the thread in the container;
[0041] If the priority parameter is lower than the lowest priority of the container thread, then the lowest priority is used as the priority control parameter of the thread in the container.
[0042] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:
[0043] By using a pre-determined container configuration structure, the highest and lowest priorities of container threads within multiple containers are determined, and the priority range corresponding to the container is determined based on the highest and lowest priorities.
[0044] In response to a thread creation operation, determine the priority parameters of the currently created thread;
[0045] If the priority parameter falls within the priority range, then the priority parameter is used as the priority control parameter for the thread in the container.
[0046] If the priority parameter is higher than the highest priority of the container thread, then the highest priority is used as the priority control parameter of the thread in the container;
[0047] If the priority parameter is lower than the lowest priority of the container thread, then the lowest priority is used as the priority control parameter of the thread in the container.
[0048] The aforementioned thread priority control method, apparatus, computer device, computer-readable storage medium, and computer program product, through a pre-determined container configuration structure, determine the highest and lowest priorities of container threads within multiple containers, and determine the corresponding priority range for each container based on these highest and lowest priorities; respond to thread creation operations by determining the priority parameters of the currently created thread; if the priority parameter falls within the priority range, it is used as the thread's priority control parameter within the container; if the priority parameter is higher than the highest priority of the container thread, the highest priority is used as the thread's priority control parameter within the container; if the priority parameter is lower than the lowest priority of the container thread, the lowest priority is used as the thread's priority control parameter within the container. In this application, by pre-setting the highest and lowest priorities of each container in the container configuration structure and clearly defining the priority control range, the situation of uncontrolled resource contention caused by excessively high or low thread priorities is avoided. When creating a thread, the priority control parameters can be verified and determined based on the priority range, which not only ensures the resource occupancy rights of high-priority tasks but also reduces the obstruction of critical tasks by low-priority tasks, effectively guaranteeing the rapid response requirements of important tasks in the system and improving system real-time performance. Attached Figure Description
[0049] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0050] Figure 1 This is a container architecture diagram from one embodiment;
[0051] Figure 2 This is a flowchart illustrating a thread priority control method in one embodiment;
[0052] Figure 3 This is a flowchart illustrating the thread priority control method in another embodiment;
[0053] Figure 4 This is a structural block diagram of a thread priority control device in one embodiment;
[0054] Figure 5 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0055] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0056] To enable those skilled in the art to better understand this application, the relevant technologies are first introduced below.
[0057] Container technology is a virtualization technology used to provide lightweight, isolated environments suitable for software development, deployment, and operation. Its application ensures consistency across development, testing, and deployment environments, allowing application software to encapsulate its dependencies and software configurations into a unified container image. This avoids package dependency conflicts that arise when multiple versions of application software are deployed and run in parallel. Therefore, container technology effectively decouples software development teams from software users (production operations), allowing developers to focus on the development iteration process without excessive concern for software deployment and operation. Simultaneously, software users can provide feedback on issues based on a specific software version (container image), significantly reducing troubleshooting time. Docker, as one of the mainstream container technologies, provides container configuration, execution environment, and lifecycle management.
[0058] In one embodiment, the thread priority control method, apparatus, computer device, computer-readable storage medium, and computer program product of this application can be applied to... Figure 1 The container architecture shown is a distributed system architecture based on container technology, used to deploy, manage and run applications, packaging the application and all its dependencies together so that the application can run consistently in different environments. The container architecture of this application includes a priority management interface, a container configuration layer, a real-time container thread layer and a thread scheduling control layer, which can improve the real-time performance of the system during thread scheduling.
[0059] In one embodiment, such as Figure 2 As shown, a thread priority control method is provided. This embodiment illustrates the method applied to a server. It is understood that this method can also be applied to a terminal, or to a system including both a terminal and a server, and implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0060] Step S202: Determine the highest and lowest priorities of container threads within multiple containers using a pre-defined container configuration structure, and determine the priority range corresponding to each container based on the highest and lowest priorities.
[0061] The container configuration structure is a structured data collection describing the runtime parameters within the container. It can exist in the form of a static configuration file (JSON) and is used to pre-set resource limits and priority parameters (such as highest and lowest priorities) for threads within the container. The highest priority defines the highest preemption level that a container thread can achieve, controlling the thread's maximum preemption capability. The lowest priority defines the lowest preemption level for a thread, limiting its minimum response time.
[0062] Priority range refers to the numerical range defined by the highest and lowest priority fields in the container configuration structure. It represents the effective limit range of thread priorities within that container, preventing low-priority threads from affecting the response time of high-priority threads. Priority ranges are independent between containers to avoid duplicate threads across containers during thread scheduling, thus preventing unreasonable CPU resource contention.
[0063] For example, the server reads the predefined configuration structure of each container and obtains the thread priority setting parameters contained therein, including the highest and lowest priorities. Based on the highest and lowest priorities in the container configuration structure, the server determines the priority range for each container. This range limits the preemption rights of threads within the container, ensuring that the priorities set when threads are created remain within a reasonable range. During container configuration initialization, the server sets this priority range in the container environment so that subsequent threads can be created and run within this range.
[0064] Optionally, when setting the priority parameter, a larger value indicates a lower priority. In one embodiment, when the priority parameter value is limited to the range of 0-255, the highest priority value is 0 and the lowest priority value is 255.
[0065] Step S204: Respond to the thread creation operation and determine the priority parameter of the currently created thread.
[0066] The thread creation operation is triggered by a user or system call. The server responds to this operation by creating a new thread within the container based on task requirements and allocating task execution flow. The priority parameter is a value set by the server when creating a thread, used to determine the thread's priority in resource contention. The priority parameter can affect the order and frequency at which the thread acquires CPU resources.
[0067] For example, when a system task requires the creation of a new thread, in response to the thread creation operation, the server analyzes the basic parameters required for the creation of the new thread, such as task type and priority parameters. The server assigns the determined priority parameters to the thread, giving it the corresponding priority in resource contention.
[0068] Step S206: If the priority parameter is within the priority range, then the priority parameter is used as the priority control parameter for the thread in the container.
[0069] Among them, the priority control parameter is the determined valid priority parameter value, which controls the priority behavior of threads in resource scheduling. The priority control parameter and the priority parameter value can be consistent in measurement to ensure that the thread's resource acquisition right is within a controllable range.
[0070] For example, the server first reads the priority parameter of the newly created thread and determines whether the priority parameter meets the requirements based on the priority range of the container. If the priority parameter is within the priority range, the server directly recognizes it as the thread's priority control parameter. The server assigns the determined priority control parameter to the thread, making its subsequent resource acquisition and scheduling entirely based on this parameter.
[0071] Step S208: If the priority parameter is higher than the highest priority of the container thread, then the highest priority is used as the priority control parameter of the thread in the container.
[0072] For example, the server reads the priority parameter value from the thread creation request to determine the priority range. If the priority parameter is higher than the highest priority, it means that the parameter exceeds the container's priority limit. The server sets the highest priority as the thread's priority control parameter to ensure that the thread does not exceed the container's priority limit during execution.
[0073] Step S210: If the priority parameter is lower than the lowest priority of the container thread, then the lowest priority is used as the priority control parameter of the thread in the container.
[0074] For example, the server obtains the priority parameter value of the newly created thread, preparing to perform a range check. If the priority parameter is lower than the lowest priority, it is determined that the parameter is below the container's priority limit range. The server assigns the lowest priority value to the thread's priority control parameter to ensure that the thread's execution priority meets the container's minimum requirements.
[0075] In the aforementioned thread priority control method, the highest and lowest priorities of container threads within multiple containers are determined through a pre-defined container configuration structure. Based on these highest and lowest priorities, the priority range corresponding to each container is determined. In response to thread creation operations, the priority parameter of the currently created thread is determined. If the priority parameter falls within the priority range, it is used as the thread's priority control parameter within the container. If the priority parameter is higher than the highest priority of the container thread, the highest priority is used as the thread's priority control parameter within the container. If the priority parameter is lower than the lowest priority of the container thread, the lowest priority is used as the thread's priority control parameter within the container. In this embodiment, by pre-setting the highest and lowest priorities of each container in the container configuration structure, the priority control range is clearly defined, avoiding situations where thread priorities are set too high or too low, leading to uncontrolled resource contention. When creating a thread, the priority control parameter can be verified and determined based on the priority range. This not only ensures the resource occupancy rights of high-priority tasks but also reduces the obstruction of critical tasks by low-priority tasks, effectively guaranteeing the rapid response requirements of important tasks in the system and improving system real-time performance.
[0076] In an exemplary embodiment, the thread priority control method further includes the following steps: determining the default priority of container threads in multiple containers through a container configuration structure; and, in response to a thread creation operation, controlling the thread in the container according to the default priority of the container thread if the thread priority parameter determination fails.
[0077] In this context, "priority parameter determination failure" means that during thread creation, the server failed to obtain a valid priority parameter because the request did not provide this parameter or the parameter value was not within an reasonable range. The default priority refers to the preset priority value in the container configuration structure, used to provide basic priority settings for threads when the priority parameter is missing or fails to be determined.
[0078] Specifically, when initializing a container, the server obtains the default priority value of the threads within that container by reading the container's configuration structure. This default priority is loaded during container initialization and remains unchanged throughout the container's lifecycle. When a new thread needs to be created in the container, the server receives a thread creation operation request and attempts to retrieve the priority parameter from the request. The server determines whether the priority parameter in the thread creation request is valid. If the priority parameter cannot be determined (e.g., the parameter is missing or exceeds a reasonable range), the server discards the parameter value and uses the default priority instead, using the default priority as the scheduling basis to ensure that the thread can obtain resource scheduling according to the default priority.
[0079] In this embodiment, by applying the default priority, even if the priority parameter fails to be determined, it is still possible to set effective priority control parameters for threads, thereby avoiding scheduling uncertainty caused by missing priority parameters and maintaining the stability of the priority structure and resource scheduling of threads within the container.
[0080] In an exemplary embodiment, step S202 involves determining the highest and lowest priorities of container threads within multiple containers based on a pre-determined container configuration structure. This includes: determining the current running configuration corresponding to the container configuration structure; adjusting the current running configuration through a priority management interface to obtain a target running configuration; applying the adjusted target running configuration to the container based on the container's state; and determining the highest and lowest priorities of the container threads.
[0081] The current runtime configuration refers to the configuration state adopted by the container at runtime, including but not limited to parameters such as the priority range of the current thread and resource allocation. The target runtime configuration is the new configuration obtained after the server adjusts the current configuration, used to better adapt to the current task load. The priority management interface is a multi-faceted interface mechanism, including but not limited to adjusting static configuration files (JSON files) and real-time command lines, used to configure and dynamically adjust the priority range of the container.
[0082] Specifically, the server reads the current runtime configuration from the container configuration structure, including the currently set highest and lowest priorities. The server uses the priority management interface to adjust the current runtime configuration, modifying the highest and lowest priority values to generate a new target runtime configuration. Based on the container's current state, the server applies the target runtime configuration to the container, replacing the old priority settings. The server confirms and records the highest and lowest priorities in the target runtime configuration to control the resource scheduling priority of container threads.
[0083] In this embodiment, a priority management method combining static and dynamic approaches is provided through the priority management interface. This ensures that the container has a reasonable priority range during initialization and allows the container to quickly adapt to new task requirements during operation, thereby improving the scheduling efficiency and responsiveness of system resources.
[0084] In an exemplary embodiment, the adjusted target runtime configuration is applied to the container based on the container's state, and the highest and lowest priorities of the container threads are determined, including: if the container's state indicates that the container has not been started, the container is created according to the target runtime configuration, and the highest and lowest priorities of the container threads are determined; if the container's state indicates that the container is running, a new highest and lowest priority are determined according to the target highest and target lowest priorities in the target runtime configuration.
[0085] Specifically, the server first checks the container's status to determine if it has started. If the container status indicates it has not started, the server creates a new container based on the target runtime configuration. When creating the container, the server extracts the highest and lowest priorities from the target runtime configuration and uses them as the initial priority range for the container's threads. In one embodiment, if the container is not started, the server generates the target runtime configuration based on the priority settings in the static configuration file within the container configuration structure specified by the administrator.
[0086] If the container status indicates it is running, the server applies the target highest and lowest priorities from the target run configuration to the container, resetting the current priority range. This adjusted priority range takes effect immediately, ensuring that threads within the container schedule resources according to the new priority range. In one embodiment, if the container is running, an administrator can modify the priority settings in real time using a command line. The server adjusts the highest and lowest priorities in the current run configuration based on this command-line input to obtain the new target run configuration.
[0087] In this embodiment, depending on whether a container has been started, the priority range of a new container or an existing container can be selectively created or updated to ensure the rationality and flexibility of the priority configuration. At the same time, regardless of whether a container is newly started or running, the setting or updating of the target priority range can respond to task requirements in real time and optimize the efficiency of resource allocation.
[0088] In an exemplary embodiment, the thread priority control method further includes determining multiple processing core units corresponding to a container through a container configuration structure; and determining the processing core unit to which the thread corresponding to the priority control parameter is bound based on the priority control parameter and the load status of the processing core unit.
[0089] Among them, the load status of the processing core unit refers to the current task load of each core unit, indicating its available resources and processing capacity.
[0090] Specifically, the server uses a container configuration structure to determine multiple processing core units corresponding to the current container. The server monitors the load status of each processing core unit in real time and records the current processing task status. Based on the thread's priority control parameters and the current load status of the processing core unit, the server selects a suitable processing core unit and binds the thread to that selected unit. When a thread's priority control parameters are high, the server binds it to a lightly loaded or idle processing core unit. When a thread's priority is low, it is bound to a heavily loaded processing core unit to balance resource usage. After selecting a processing core unit, the server binds the thread's execution to that core unit to ensure that the thread can continuously utilize the specified processing core during subsequent execution.
[0091] In this embodiment, threads are bound according to the load status of the processing core unit, which effectively avoids the overload of some cores and optimizes the overall resource allocation of the system. At the same time, the thread binding strategy based on priority control parameters and load status makes the system more real-time and flexible in a multi-tasking environment and improves scheduling efficiency.
[0092] In an exemplary embodiment, after determining the processing core unit to which the thread corresponding to the priority control parameter is bound based on the priority control parameter and the load status of the processing core unit, the method further includes: performing load status detection on the processing core unit to obtain a load status detection result; if the load status detection result indicates that the processing core unit is overloaded, binding the thread corresponding to the highest priority control parameter to the processing core unit according to the priority control parameter, and unbinding all threads except the thread corresponding to the highest priority control parameter from the processing core unit.
[0093] Specifically, the server monitors the load status of each processing core unit corresponding to the container, assessing its current operating pressure, including but not limited to metrics such as CPU utilization and task backlog. Based on the monitoring results, the server determines whether the processing core unit is overloaded. If the monitoring results indicate that the processing core unit is overloaded, it means that the core unit cannot efficiently handle the current task load, and task binding needs to be adjusted. In the case of an overloaded processing core unit, the server binds the thread corresponding to the highest priority control parameter to that processing core unit, ensuring that critical tasks can preferentially utilize the core's computing resources. Except for the thread corresponding to the highest priority control parameter, the server unbinds other threads from the processing core unit to release resources and reduce the core's load pressure.
[0094] In this embodiment, by dynamically adjusting the thread binding strategy, performance degradation caused by core unit overload is effectively avoided, thereby improving the stability and reliability of the system.
[0095] To enable those skilled in the art to better understand the above steps, the following example illustrates the embodiments of this application, but it should be understood that the embodiments of this application are not limited thereto.
[0096] In one exemplary embodiment, such as Figure 3 As shown, the server reads the configuration parameters from the container configuration structure, which includes information such as the container's highest priority, lowest priority, default priority, and bindable processing unit cores.
[0097] The server determines the highest and lowest priorities of threads within the container based on the parameters in the container's configuration structure, forming a priority range. When a new thread is created, the server receives a creation request and retrieves or calculates the thread's priority parameter from the request.
[0098] The server compares the thread's priority parameter with the container's priority range to determine if the parameter falls within that range. If it does, the server directly uses this parameter as the thread's priority control parameter. If it doesn't, the server checks if the parameter is higher than the container's highest priority (i.e., the parameter value is less than the highest priority value). If it is, the highest priority is used. If it's not higher, the server further checks if it's lower than the container's lowest priority (i.e., the parameter value is greater than the lowest priority value). If it is, the lowest priority is used. Finally, the server determines the final priority control parameter, assigns it to the thread, and controls the thread's resource scheduling based on this parameter.
[0099] In this embodiment, by rationally allocating thread priorities, the server can maximize resource utilization efficiency while ensuring the priority response of critical tasks. This process ensures that each thread in the system runs according to preset priority requirements, avoiding delays in the execution of high-priority tasks due to excessive occupation by low-priority tasks, thereby optimizing overall resource scheduling.
[0100] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0101] Based on the same inventive concept, this application also provides a thread priority device for implementing the thread priority method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more thread priority device embodiments provided below can be found in the limitations of the thread priority method described above, and will not be repeated here.
[0102] In one exemplary embodiment, such as Figure 4 As shown, a thread priority device is provided, including: a container priority range setting module 410, a thread priority parameter determination module 420, a priority range matching module 430, a high-priority boundary control module 440, and a low-priority boundary control module 450, wherein:
[0103] The container priority range setting module 410 is used to determine the highest and lowest priorities of container threads within multiple containers through a pre-determined container configuration structure, and to determine the corresponding priority range of the container based on the highest and lowest priorities.
[0104] The thread priority parameter determination module 420 is used to respond to thread creation operations and determine the priority parameters of the currently created thread.
[0105] Priority range matching module 430 is used to use the priority parameter as the priority control parameter of the thread in the container if the priority parameter belongs to the priority range.
[0106] The high-priority boundary control module 440 is used to use the highest priority as the priority control parameter for the thread in the container if the priority parameter is higher than the highest priority of the container thread.
[0107] The low-priority boundary control module 450 is used to use the lowest priority as the priority control parameter for the thread in the container if the priority parameter is lower than the lowest priority of the container thread.
[0108] In one embodiment, the container priority range setting module 410 is further configured to determine the default priority of the container threads in multiple containers through the container configuration structure; and in response to the thread creation operation, if the priority parameter of the thread fails to be determined, control the thread in the container according to the default priority of the container thread.
[0109] In one embodiment, the container priority range setting module 410 is further configured to determine the current running configuration corresponding to the container configuration structure, adjust the current running configuration through the priority management interface to obtain the target running configuration, apply the adjusted target running configuration to the container according to the container's state, and determine the highest and lowest priorities of the container threads.
[0110] In one embodiment, the container priority range setting module 410 is further configured to: if the status of the container indicates that the container has not been started, create the container according to the target running configuration and determine the highest and lowest priorities of the container thread; if the status of the container indicates that the container is running, redetermine the new highest and lowest priorities according to the target highest and lowest priorities in the target running configuration.
[0111] In one embodiment, the container priority range setting module 410 is further configured to determine multiple processing core units corresponding to the container through the container configuration structure; and to determine the processing core unit to which the thread corresponding to the priority control parameter is bound based on the priority control parameter and the load status of the processing core unit.
[0112] In one embodiment, the container priority range setting module 410 is further configured to perform load status detection on the processing core unit and obtain a load status detection result; if the load status detection result indicates that the processing core unit is overloaded, the thread corresponding to the highest priority control parameter is bound to the processing core unit according to the priority control parameter, and the threads other than the thread corresponding to the highest priority control parameter are unbound from the processing core unit.
[0113] Each module in the aforementioned thread priority device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0114] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores container configuration structure data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a thread priority method.
[0115] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0116] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0117] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0118] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0119] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0120] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0121] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0122] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A thread priority control method, characterized in that, The method includes: Based on a pre-determined container configuration structure, the current running configuration corresponding to the container configuration structure is determined, and the current running configuration is adjusted through a priority management interface to obtain the target running configuration; Based on the state of the container, the adjusted target runtime configuration is applied to the container, and the highest and lowest priorities of container threads within multiple containers are determined. The priority range corresponding to the container is determined based on the highest priority and the lowest priority; In response to thread creation operations, determine the priority parameters of the currently created thread; If the priority parameter falls within the priority range, then the priority parameter is used as the priority control parameter for the thread in the container. If the priority parameter is higher than the highest priority of the container thread, then the highest priority is used as the priority control parameter of the thread in the container; If the priority parameter is lower than the lowest priority of the container thread, then the lowest priority is used as the priority control parameter for the thread in the container: The default priority of the container threads within multiple containers is determined through the container configuration structure. In response to the thread creation operation, if the thread priority parameter fails to be determined, the thread is controlled in the container according to the default priority of the container thread.
2. The method according to claim 1, characterized in that, The step of applying the adjusted target runtime configuration to the container based on the container's state, and determining the highest and lowest priorities of the container threads, includes: If the container's status indicates that the container has not been started, then according to the target runtime configuration, the container is created, and the highest and lowest priorities of the container threads are determined; If the container's status indicates that the container is running, then the new highest and lowest priorities are redefined based on the target highest and lowest priorities in the target running configuration.
3. The method according to any one of claims 1 to 2, characterized in that, The method further includes: The container configuration structure is used to determine the multiple processing core units corresponding to the container; Based on the priority control parameters and the load status of the processing core unit, the processing core unit to which the thread corresponding to the priority control parameters is bound is determined.
4. The method according to claim 3, characterized in that, After determining the processing core unit to which the thread is bound according to the priority control parameter based on the priority control parameter and the load state of the processing core unit, the method further includes: The load status of the processing core unit is detected to obtain the load status detection result; If the load status detection result indicates that the processing core unit is overloaded, the thread corresponding to the highest priority control parameter is bound to the processing core unit according to the priority control parameters, and the threads other than the thread corresponding to the highest priority control parameter are unbound from the processing core unit.
5. A thread priority control device, characterized in that, The device includes: The container priority range setting module is used to determine the current running configuration corresponding to the container configuration structure through a pre-determined container configuration structure, adjust the current running configuration through the priority management interface to obtain the target running configuration; apply the adjusted target running configuration to the container according to the container's state, determine the highest and lowest priorities of container threads in multiple containers, and determine the priority range corresponding to the container based on the highest and lowest priorities; The thread priority parameter determination module is used to respond to thread creation operations and determine the priority parameter of the currently created thread; determine the default priority of the container threads in multiple containers through the container configuration structure; and, in response to the thread creation operation, control the thread in the container according to the default priority of the container thread if the thread priority parameter determination fails. The priority range matching module is used to use the priority parameter as the priority control parameter for the thread in the container if the priority parameter belongs to the priority range. The high-priority boundary control module is used to use the highest priority as the priority control parameter for the thread in the container if the priority parameter is higher than the highest priority of the container thread. The low-priority boundary control module is used to use the lowest priority as the priority control parameter for the thread in the container if the priority parameter is lower than the lowest priority of the container thread.
6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Processing method based on client request and related device
CN118445043A
Method and device for setting priority of processes in container
CN118535274A