Scheduling strategy inheriting method, device, equipment, medium, program product and vehicle
By comparing the scheduling priorities of the client and the server, it is determined whether the threads on the server inherit the scheduling priorities of the client, which solves the problem of tasks blocking due to inter-process communication in the cockpit system, and improves system performance and user experience.
Patent Information
- Application Number
- CN202510038885.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-09
- Publication Date
- 2025-05-06
AI Technical Summary
Tasks in the cockpit system are blocked due to inter-process communication mechanisms, affecting the normal execution of tasks and the implementation of cockpit-related functions.
By comparing the scheduling priority of the first thread in the client and the scheduling priority of the second thread in the server, it is determined whether to make the second thread inherit the scheduling priority of the first thread, thereby solving the blocking problem caused by inter-process communication.
It effectively avoids the problem that the scheduling priority of the server is lowered due to priority inheritance, improves the performance of the client and server, and ensures the normal execution of tasks and the efficient implementation of cockpit functions.
Smart Images

Figure CN119938276A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of vehicle technology, and in particular to a scheduling strategy inheritance method, device, equipment, storage medium and vehicle. Background Art
[0002] The smart cockpit is an important part of the smart car, and the technical development of the smart cockpit is closely related to the development of smart cars. When implementing the functions related to the smart cockpit, technicians usually assign different scheduling strategies to tasks according to the importance of the tasks, and expect all tasks to be executed according to the configured scheduling strategies. However, each task in the cockpit system is often not independent, and generally involves the inter-process communication mechanism. Tasks may be blocked by the inter-process communication mechanism, that is, the current task is easily slowed down by a task that communicates with the current task, affecting the normal execution of the current task, which in turn affects the implementation of cockpit related functions. Summary of the invention
[0003] In view of this, the present invention provides a scheduling strategy inheritance method, apparatus, device, medium, program product and vehicle to solve the problem that tasks in a cockpit system may be blocked due to an inter-process communication mechanism.
[0004] In a first aspect, the present invention provides a scheduling strategy inheritance method, the method comprising:
[0005] According to the inter-process communication request sent by the client to the server, first priority information corresponding to the inter-process communication request is obtained, where the first priority information is used to represent the scheduling priority of the first thread in the client;
[0006] Obtaining second priority information, where the second priority information is used to represent the scheduling priority of a second thread in the server, where the second thread is a thread that the server serves the client;
[0007] The first priority information is compared with the second priority information, and whether the second thread inherits the scheduling priority of the first thread is controlled according to the comparison result.
[0008] The present invention compares the scheduling priority of the first thread in the client with the scheduling priority of the second thread in the server, and determines whether to make the second thread inherit the scheduling priority of the first thread according to the comparison result. When encountering the problem that the task is blocked due to the communication mechanism between processes, the present invention can cancel the priority inheritance when the scheduling priority of the second thread is higher than or equal to the scheduling priority of the first thread, or perform the priority inheritance when the scheduling priority of the second thread is lower than the scheduling priority of the first thread. It can be seen that the present invention solves the problem that the current task is easily slowed down by a task that communicates with the current task, and ensures the normal execution of the current task, thereby better and more reliably realizing the cockpit-related functions, improving the user's car experience, and higher user satisfaction.
[0009] In an optional implementation manner, the first priority information is a first priority value, and the second priority information is a second priority value; comparing the first priority information with the second priority information includes:
[0010] Compare the first priority value with the second priority value to obtain a comparison result;
[0011] The comparison result is: the first priority value is greater than the second priority value, or the first priority value is less than the second priority value, or the first priority value is equal to the second priority value.
[0012] Based on the comparison between the first priority value and the second priority value, the present invention realizes the quantitative comparison of the scheduling priorities of the client and the server, accurately determines the comparison results of the scheduling priorities of the client and the server, and provides a quantitative basis for whether the server inherits the scheduling priority of the client, so that the scheduling strategy inheritance effect is better.
[0013] In an optional implementation, controlling whether the second thread inherits the scheduling priority of the first thread according to the comparison result includes:
[0014] If the first priority value is less than the second priority value, the second thread is controlled to inherit the scheduling priority of the first thread.
[0015] The present invention allows the second thread of the server to inherit the scheduling priority of the first thread of the client only when the first priority value is less than the second priority value, that is, when the scheduling priority of the client is higher than the scheduling priority of the server. It can be seen that the present invention completely avoids the problem of the scheduling priority of the server being lowered due to priority inheritance; moreover, the present invention automatically controls the second thread of the server to inherit the first thread of the client, which significantly reduces the workload and is easier to operate compared to the method of manually enabling priority inheritance.
[0016] In an optional implementation, the first priority information is real-time priority information; the second priority information is completely fair scheduling priority information.
[0017] The present invention can implement the inheritance of scheduling priority when the scheduling priority of the client is the real-time priority and the scheduling priority of the server is the completely fair scheduling priority, and does not implement the scheduling priority inheritance when the scheduling priority of the client is the completely fair scheduling priority and the scheduling priority of the server is the real-time priority. It can be seen that the present invention can be well adapted to the scheduling priority inheritance optimization strategy of the server in the binder communication scenario to improve the performance of the client and the server in the binder communication scenario.
[0018] In an optional implementation, the scheduling strategy inheritance method further includes:
[0019] According to the inter-process communication request sent by the client to the server, current demand information corresponding to the inter-process communication request is obtained, where the current demand information is used to characterize the resource demand of the first thread;
[0020] According to the current demand information, the second thread is controlled to inherit the resource demand of the first thread.
[0021] The present invention can realize the inheritance of resource requirements on the basis of the scheduling priority inheritance function, thereby further improving the performance of the client and the server.
[0022] In an optional implementation, the current demand information is processor time slice demand information; and according to the current demand information, controlling the second thread to inherit the resource demand of the first thread includes:
[0023] If the processor time slice represented by the current demand information is greater than the processor time slice allocated to the second thread, the virtual time of the second thread is reduced.
[0024] By identifying the processor time slice requirement of the first thread and comparing it with the processor time slice allocated to the second thread, the present invention can also enable the server to inherit the client's demand for more time slices when the server responds to the client's request, thereby reducing the client's blocking time and improving the client's operating performance.
[0025] In an optional implementation, the current demand information is core demand information; and according to the current demand information, controlling the second thread to inherit the resource demand of the first thread includes:
[0026] If the core requirement represented by the current requirement information is higher than the performance of the core used by the second thread, the core used by the second thread is changed to a core that meets the core requirement.
[0027] For the situation where the core requirement of the first thread is higher than the core performance used by the second thread, for example, the first thread tends to run on large cores and the second thread tends to run on small cores, the present invention can enable the second thread to inherit the core requirement of the first thread, thereby achieving further inheritance of the scheduling strategy and significantly reducing the running time of the second thread.
[0028] In an optional implementation, the current demand information is resource anti-preemption demand information; and according to the current demand information, controlling the second thread to inherit the resource demand of the first thread includes:
[0029] According to the resource anti-preemption requirement information, the logic of preempting the resources being used by the second thread is skipped, or the thread to be preempted for the resources being used by the second thread is controlled to run on the target core; wherein the target core is different from the core being used by the second thread.
[0030] The present invention can also implement the inheritance function of resource anti-preemption requirements, so that the second thread inherits the logic of the first thread to skip preempting the resources in use or controls the thread to preempt the resources in use to run on a non-current core, further shortening the running time of the second thread and improving the performance of the client and the server.
[0031] In an optional implementation, the current demand information is a process descriptor, and the process descriptor includes multiple characters.
[0032] The present invention reduces the implementation cost of the resource demand inheritance function by configuring the current demand information in the process descriptor, and facilitates the debugging of the resource demand inheritance function.
[0033] In a second aspect, the present invention provides a scheduling strategy inheritance device, the device comprising:
[0034] A first acquisition module, configured to acquire first priority information corresponding to an inter-process communication request sent by a client to a server, wherein the first priority information is used to represent a scheduling priority of a first thread in the client;
[0035] A second acquisition module is used to acquire second priority information, where the second priority information is used to represent the scheduling priority of a second thread in the server, where the second thread is a thread that the server serves the client;
[0036] The priority comparison module is used to compare the first priority information with the second priority information, and to control whether the second thread inherits the scheduling priority of the first thread according to the comparison result.
[0037] In a third aspect, the present invention provides an electronic device comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, computer instructions being stored in the memory, and the processor executing the scheduling strategy inheritance method of the above-mentioned first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0038] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the scheduling strategy inheritance method of the above-mentioned first aspect or any corresponding embodiment thereof.
[0039] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the scheduling strategy inheritance method of the first aspect or any corresponding embodiment thereof.
[0040] In a sixth aspect, the present invention provides a vehicle, the vehicle comprising a vehicle controller, the vehicle controller being used to execute the scheduling strategy inheritance method of the above-mentioned first aspect or any corresponding implementation manner thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0042] Figure 1 It is a flowchart of a scheduling policy inheritance method according to an embodiment of the present invention.
[0043] Figure 2 It is a flowchart of another scheduling policy inheritance method according to an embodiment of the present invention.
[0044] Figure 3 It is a schematic diagram showing that the scheduling priority of a thread on the server side in the related art is lowered.
[0045] Figure 4 It is a schematic diagram of controlling the second thread not to inherit the scheduling priority of the first thread according to an embodiment of the present invention.
[0046] Figure 5 It is a schematic diagram of controlling the second thread to inherit the scheduling priority of the first thread according to an embodiment of the present invention.
[0047] Figure 6 It is a flowchart of another scheduling strategy inheritance method according to an embodiment of the present invention.
[0048] Figure 7 This is a schematic diagram of the problem of long running time caused by the server inheriting the scheduling strategy of the client in the related art.
[0049] Figure 8 It is a schematic diagram of controlling a second thread to inherit resource requirements of a first thread according to processor time slice requirement information according to an embodiment of the present invention.
[0050] Fig. 9 It is a schematic diagram of controlling the second thread to inherit the resource requirement of the first thread according to the core requirement information according to an embodiment of the present invention.
[0051] Fig.10 It is a schematic diagram of controlling the second thread to inherit the resource requirement of the first thread according to resource anti-preemption requirement information according to an embodiment of the present invention.
[0052] Fig.11 It is a schematic diagram of the comparison result between the cross-process communication time consumption of an embodiment of the present invention and the cross-process communication time consumption of related technologies.
[0053] Fig.12 4 is a structural block diagram of a scheduling strategy inheritance device according to an embodiment of the present invention.
[0054] Fig.13 It is a schematic diagram of the hardware structure of the electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0056] For the cockpit system configured on the vehicle, different tasks involve inter-process communication mechanisms; for technicians, it is expected that all participating threads in the logical link initiated by the task can run according to the pre-configured strategy, but the reality is that tasks are easily slowed down by the inter-process communication mechanism. For example, a higher scheduling priority is configured for task A so that the logic of task A can be executed as soon as possible, but task A may be blocked on a low-priority task B due to the inter-process communication mechanism. Task B is frequently preempted due to its low priority and gives up the CPU (Central Processing Unit), resulting in a large number of runnables (waiting for execution) that consume time, and eventually task A is slowed down by task B. It can be seen that the relevant technology is difficult to ensure that all participating threads in the entire logical link can run at a high priority, which seriously affects the performance of the cockpit system and the user's car experience.
[0057] In the native implementation of binder (a cross-process communication method) in the Android operating system, the binder inter-process communication mechanism in Android can be optimized so that the binder peer task inherits the scheduling policy of the binder initiator thread. For example, some binder services are allowed to enable scheduling priority inheritance. If the client is RT priority, it will also run at RT priority during the period when the server responds to the client request (client blocking), and if the client is CFS priority, it will also run at CFS priority during the period when the server responds to the client request (client blocking). However, when the client is CFS priority and the server is RT priority, the scheduling priority of the server after inheriting the CFS priority is lowered, and the low-priority task executes the same logic, which takes longer time, resulting in the server's binder thread being delayed in being released, and then the server's binder thread may be exhausted, that is, there is a problem of no threads available on the server. Moreover, whether the server is allowed to inherit the client's scheduling priority depends on whether it is manually enabled when registering the service. In fact, each service requires the user to manually configure the scheduling priority inheritance. Most function modules (such as cockpit-related functions) do not enable binder scheduling priority inheritance when they are implemented because they do not consider performance too much. However, the process of manually enabling scheduling priority inheritance for all servers is labor-intensive and very troublesome.
[0058] According to an embodiment of the present invention, a scheduling policy inheritance method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0059] In this embodiment, a scheduling strategy inheritance method is provided, which can be used in vehicle-mounted electronic equipment, and specifically can be used in a scheduler for cross-process communication (binder) in the vehicle-mounted electronic equipment. Figure 1 is a flow chart of a scheduling policy inheritance method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps S101 to S103.
[0060] Step S101: According to a cross-process communication request sent by a client to a server, first priority information corresponding to the cross-process communication request is obtained, where the first priority information is used to represent a scheduling priority of a first thread in the client.
[0061] Specifically, the scheduler may discover the cross-process communication request sent by the client to the server, and thus may obtain the first priority information corresponding to the first thread in the client.
[0062] Among them, the client can be the binder (a cross-process communication method) initiator, and the server can be the binder peer.
[0063] Step S102, obtaining second priority information, where the second priority information is used to represent the scheduling priority of a second thread in the server, where the second thread is a thread used by the server to serve the client.
[0064] Specifically, the first priority information may be acquired first and then the second priority information, or the first priority information and the second priority information may be acquired simultaneously.
[0065] The second thread is a service thread, which is used to provide thread services for the client.
[0066] Step S103, comparing the first priority information with the second priority information, and controlling whether the second thread inherits the scheduling priority of the first thread according to the comparison result.
[0067] In this embodiment, whether to make the second thread inherit the scheduling priority of the first thread is determined based on the comparison result of the scheduling priority of the first thread and the scheduling priority of the second thread. The scheduling priority comparison result of this embodiment includes that the scheduling priority of the first thread is higher than the scheduling priority of the second thread, the scheduling priority of the first thread is equal to the scheduling priority of the second thread, and the scheduling priority of the first thread is lower than the scheduling priority of the second thread; for example, the scheduling priority is inherited when the scheduling priority of the first thread is higher, and the scheduling priority is not inherited when the scheduling priority of the second thread is higher or the scheduling priority of the first thread is the same as the scheduling priority of the second thread.
[0068] Specifically, the scheduler can obtain the first priority information, the second priority information, perform priority comparison, and control whether the second thread inherits the scheduling priority of the first thread based on the method of inserting a pile in the binder transmission path (globally enabled by default).
[0069] The scheduling policy inheritance method provided in this embodiment adopts a method of comparing the scheduling priority of the first thread in the client with the scheduling priority of the second thread in the server, so as to determine whether to make the second thread inherit the scheduling priority of the first thread according to the comparison result. When encountering the problem that the task / process is blocked due to the communication mechanism between processes, this embodiment can cancel the priority inheritance when the scheduling priority of the second thread is higher than or equal to the scheduling priority of the first thread, or inherit the priority when the scheduling priority of the second thread is lower than the scheduling priority of the first thread. It can be seen that this embodiment solves the problem that the current task is easily slowed down by a task that communicates with the current task, thereby ensuring the normal execution of the current task, and then better realizing the cockpit-related functions, improving the user's car experience, and higher user satisfaction.
[0070] In this embodiment, a scheduling strategy inheritance method is provided, which can be used in vehicle-mounted electronic equipment, and specifically can be used in a scheduler for cross-process communication (binder) in the vehicle-mounted electronic equipment. Figure 2 is a flow chart of a scheduling policy inheritance method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps S201 to S203.
[0071] Step S201: According to the client sending an inter-process communication request to the server, first priority information corresponding to the inter-process communication request is obtained, and the first priority information is used to represent the scheduling priority of the first thread in the client. Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0072] Step S202, obtaining second priority information, the second priority information is used to represent the scheduling priority of the second thread in the server, the second thread is the thread of the server serving the client. Figure 1 Step S102 of the illustrated embodiment will not be described in detail here.
[0073] Step S203, comparing the first priority information with the second priority information, and controlling whether the second thread inherits the scheduling priority of the first thread according to the comparison result.
[0074] Specifically, the first priority information is a first priority value, the second priority information is a second priority value, the first priority value is a quantitative representation of the first priority information, and the second priority value is a quantitative representation of the second priority information; the above step S203 may include steps S2031 to S2034.
[0075] Step S2031, comparing the first priority value with the second priority value to obtain a comparison result.
[0076] The comparison result is: the first priority value is greater than the second priority value, or the first priority value is less than the second priority value, or the first priority value is equal to the second priority value.
[0077] In this embodiment, the scheduling priority is specifically represented by a priority value. The smaller the priority value, the higher the priority, and the larger the priority value, the lower the priority. For example, the RT priority (Real Time Priority) value range can be [0,99], and the CFS priority (Completely Fair Scheduler Priority) value range can be [100,139]. The RT priority is higher than the CFS priority.
[0078] Step S2032, determine whether the first priority value is less than the second priority value. If yes, execute step S2033, if not, execute step S2034.
[0079] Step S2033: If the first priority value is smaller than the second priority value, the second thread is controlled to inherit the scheduling priority of the first thread.
[0080] In this embodiment, the duration for which the second thread inherits the scheduling priority of the first thread is the execution time of the second process corresponding to the first process in the first thread. After the second process is executed, the second thread is controlled to restore the scheduling priority before inheriting the scheduling priority of the first thread. The second process is specifically the process in the second thread, and the cross-process communication request sent by the client to the server is specifically the cross-process communication request sent by the first process to the second process; thus, the second thread in the server will be temporarily set to the scheduling priority of the first thread in the client during the period of responding to the client request, and the second thread in the server will restore the original scheduling priority after the response is completed.
[0081] The process involved in this embodiment is a task. One process represents a task and is the smallest scheduling unit. For a specific service (such as display driver service, Bluetooth service, file service or audio service, etc.), it can be implemented through one or more processes. For example, the audio service in the smart cockpit system on the vehicle generally needs to be implemented through multiple processes. The binder communication often involves multiple processes / tasks, and the solution of this embodiment can be implemented.
[0082] Step S2034: If the first priority value is greater than or equal to the second priority value, the second thread is controlled not to inherit the scheduling priority of the first thread.
[0083] In some optional implementations, the first priority information is real-time priority information, and the second priority information is completely fair scheduling priority information.
[0084] Specifically, the real-time priority information indicates that the priority is RT priority (Real Time Priority), and the completely fair scheduling priority information indicates that the priority is CFS priority (Completely Fair Scheduler Priority).
[0085] like Figure 3 As shown, if the client's scheduling priority (priority value prio=125) is directly inherited to the server's scheduling priority, the server's scheduling priority value during the period of responding to the client's request (transaction-reply, request transaction-response) changes from prio=98 to prio=125, the priority value increases, and the priority decreases. In this case, the server will be in a runnable state and a sleep state during the time of responding to the client's request, that is, the second thread of the server is occupied for a long time, resulting in a long execution time of the process in the server; wherein, sleep indicates a sleeping state, runnable indicates a state of waiting for execution, and running indicates an executing state.
[0086] like Figure 4 As shown, compared to Figure 3 In this embodiment, when it is determined that the scheduling priority value prio=98 of the server is less than the scheduling priority value prio=125 of the client, that is, the first priority value is greater than the second priority value, the second thread is controlled not to inherit the scheduling priority of the first thread, so that the scheduling priority of the server is still maintained, that is, the scheduling priority value prio of the server is maintained at 98. In this way, the second thread of the server can be executed preferentially, so the server often appears in the running state during the time of responding to the client request, avoiding the problem of process execution time in the server due to scheduling priority inheritance.
[0087] like Figure 5 As shown, compared to Figure 3 In this embodiment, when it is determined that the scheduling priority value prio=120 of the server is greater than the scheduling priority value prio=98 of the client, that is, the first priority value is less than the second priority value, the second thread is controlled to inherit the scheduling priority of the first thread, so that the scheduling priority of the second thread is updated to the scheduling priority of the first thread, and the scheduling priority value of the server is prio=98. In this way, the second thread of the server can be executed preferentially, so the server often appears in the running state during the time of responding to the client request, thereby achieving that the process execution time in the server is shortened by inheriting the scheduling priority.
[0088] Therefore, this embodiment allows the second thread of the server to inherit the scheduling priority of the first thread of the client only when the first priority value is less than the second priority value, that is, the scheduling priority of the client is higher than the scheduling priority of the server. That is, this embodiment only allows the server to inherit to a high priority, not to a low priority. It can be seen that this embodiment can completely avoid the problem that the scheduling priority of the server is lowered due to priority inheritance, and avoid the situation that the binder thread of the server is exhausted; moreover, this embodiment controls the second thread of the server to inherit the first thread of the client through the scheduler, does not distinguish between services, and adopts a method of inserting piles in the binder transmission path, which is globally enabled by default, avoiding the trouble of manually configuring each service. Compared with the method of manually enabling priority inheritance, the workload is significantly reduced and it is easier to operate. Based on the comparison of the first priority value and the second priority value, this embodiment realizes the quantitative comparison of the scheduling priorities of the client and the server, accurately determines the comparison result of the scheduling priorities of the client and the server, and provides a quantitative basis for whether the server inherits the scheduling priority of the client, so that the scheduling policy inheritance effect is better.
[0089] In the binder communication scenario, this embodiment can implement scheduling priority inheritance when the scheduling priority of the client is the real-time priority and the scheduling priority of the server is the completely fair scheduling priority. When the scheduling priority of the client is the completely fair scheduling priority and the scheduling priority of the server is the real-time priority, scheduling priority inheritance is not performed. It can be seen that this embodiment can better adapt to the scheduling priority inheritance optimization strategy of the server in the binder communication scenario to improve the performance of the client and the server in the binder communication scenario.
[0090] In this embodiment, a scheduling strategy inheritance method is provided, which can be used in vehicle-mounted electronic equipment, and specifically can be used in a scheduler for cross-process communication (binder) in the vehicle-mounted electronic equipment. Figure 6 is a flow chart of a scheduling policy inheritance method according to an embodiment of the present invention. Figure 6 As shown, the process includes the following steps S601 to S605.
[0091] Step S601: According to the client sending an inter-process communication request to the server, first priority information corresponding to the inter-process communication request is obtained, and the first priority information is used to represent the scheduling priority of the first thread in the client. Figure 1 Step S101 of the embodiment shown or Figure 2 Step S201 of the illustrated embodiment will not be described in detail here.
[0092] Step S602: Obtain second priority information, where the second priority information is used to represent the scheduling priority of the second thread in the server, where the second thread is the thread that the server serves the client. Figure 1 Step S102 of the embodiment shown or Figure 2 Step S202 of the illustrated embodiment will not be described in detail here.
[0093] Step S603, compare the first priority information with the second priority information, and control whether the second thread inherits the scheduling priority of the first thread according to the comparison result. Figure 1 Step S103 of the embodiment shown or Figure 2 Step S203 of the illustrated embodiment will not be described in detail here.
[0094] Step S604: according to the inter-process communication request sent by the client to the server, current demand information corresponding to the inter-process communication request is obtained, where the current demand information is used to characterize the resource demand of the first thread.
[0095] In some optional implementations, step S604 can be executed in parallel with step S601 or in a sequential order.
[0096] Step S605: Control the second thread to inherit the resource demand of the first thread according to the current demand information.
[0097] Therefore, this embodiment can implement inheritance of resource requirements on the basis of the scheduling priority inheritance function, thereby further improving the performance of the client and the server.
[0098] For threads that are considered important to the business from the client's perspective, more CPU time slices may be allocated to the threads in the client, so that the process can be completed as soon as possible under high load. However, the service threads that respond to client requests in conventional solutions often do not inherit this feature. Under high load, they may not be allocated enough CPU time slices, causing the client to be blocked for too long, which in turn affects performance.
[0099] By identifying the processor time slice requirement of the first thread and comparing it with the processor time slice allocated to the second thread, this embodiment can also enable the server to inherit the client's demand for more time slices while responding to the client's request, thereby reducing the client's blocking time and significantly improving the client's operating performance.
[0100] In some optional implementations, the current demand information is processor time slice demand information; step S605 includes: if the processor time slice represented by the current demand information is greater than the processor time slice allocated to the second thread, reducing the virtual time of the second thread.
[0101] The processor time slice requirement information is used to represent the CPU time slice requirement.
[0102] The virtual time in this embodiment is vruntime, and reducing the virtual time of the second thread means lowering the virtual time of the second thread.
[0103] In the case where the core requirement of the first thread is higher than the core performance used by the second thread, for example, the first thread tends to run on large cores and the second thread tends to run on small cores, this embodiment enables the second thread to inherit the core requirement of the first thread, thereby further inheriting the core-related scheduling policies, which significantly shortens the running time of the second thread.
[0104] like Figure 7 As shown, in the case where the client has always tended to run on large cores (high-computing-power CPU cores) before requesting a service, if the server that responds to the client's request tends to run on small cores (low-computing-power CPU cores), the service thread that responds to the client's request in the conventional solution does not inherit this property of tending to run on large cores, and the small core has weak computing power, which will cause the server's process to run for a particularly long time, resulting in performance degradation.
[0105] In some optional implementations, the current demand information is core demand information; step S605 includes: if the core demand represented by the current demand information is higher than the performance of the core used by the second thread, changing the core used by the second thread to a core that meets the core demand.
[0106] The core requirement information is used to characterize the core requirements in a heterogeneous large and small core system. In a heterogeneous large and small core system, large cores and small cores are configured. Large cores have higher computing power than small cores, while small cores have lower computing power than large cores.
[0107] This embodiment can also implement the inheritance function of resource anti-preemption requirements, so that the second thread inherits the logic of the first thread to skip preempting the resources in use or controls the thread to preempt the resources in use to run on a non-current core, further shortening the running time of the second thread and improving the performance of the client and the server.
[0108] In combination with the above-mentioned embodiment, if the thread that initially initiates the binder communication is of high priority and runs on large cores first, then all participating binder threads on the entire link are of high priority and run on large cores first.
[0109] For threads that are judged to be important to the current business from the client's perspective, anti-preemption measures may be set for them, such as skipping wake-up preemption or shielding tick (clock cycle) preemption. However, conventional solutions do not inherit this anti-preemption feature. Therefore, under high load, they may be frequently preempted by other threads and forced to give up the CPU, affecting performance.
[0110] In some optional implementations, the current demand information is resource anti-preemption demand information; step S605 includes: according to the resource anti-preemption demand information, skipping the logic of preempting the resources being used by the second thread, or controlling the thread to preempt the resources being used by the second thread to run on the target core; wherein the target core is different from the core being used by the second thread.
[0111] Among them, resource anti-preemption demand information is used to characterize scheduling timeliness requirements.
[0112] Specifically, for the situation where the client triggers anti-preemption according to a periodic tick or the situation where the client anti-preempts when other threads are awakened, the scheduler can adopt the logic of skipping preemption of resources being used by the second thread, or control the thread to preempt the resources being used by the second thread to run on the core other than the second thread.
[0113] The scheduling policy involved in this embodiment includes scheduling priority, processor time slice requirement information, core requirement information, and resource anti-preemption requirement information.
[0114] In some optional implementations, the current demand information is a process descriptor, and the process descriptor includes multiple characters.
[0115] The multi-bit character may be, for example, a 32-bit character, and the 32-bit character may be a newly added 32-bit mask. In conjunction with the following example, a member (a 32-bit mask in the form of a structure) may be added to the process descriptor, where bits 0-7 represent CPU slice demand information, bits 8-15 represent CPU power demand information, and bits 16-23 represent CPU preemption demand information.
[0116]
[0117] This embodiment reduces the implementation cost of the resource requirement inheritance function by configuring the current requirement information in the process descriptor, and facilitates the debugging of the resource requirement inheritance function.
[0118] like Figure 8 As shown, the scheduling policy inheritance method of the embodiment of the present invention may specifically include steps S801 to S804.
[0119] Step S801, in response to the client sending a binder communication request to the server, the binder thread (ie, the second thread) of the server is awakened.
[0120] Step S802: when the current demand information includes processor time slice demand information, it is determined whether the client demands more CPU time slices.
[0121] Step S803, if yes, it means that the server needs to inherit the client's processor time slice requirement, then reduce its virtual time (vruntime), that is, lower the virtual time of the second thread; if no, it means that the server's currently allocated CPU time slice is sufficient and does not need to inherit the client's processor time slice requirement.
[0122] Step S804: For the CPU, the CPU gives priority to tasks with smaller virtual time and lets them run until the virtual time increases to the same size as other tasks.
[0123] like Fig. 9 As shown, the scheduling policy inheritance method of the embodiment of the present invention may specifically include steps S901 to S903.
[0124] Step S901, in response to the client sending a binder communication request to the server, the server binder thread (ie, the second thread) is awakened.
[0125] Step S902: when the current demand information includes core demand information, determine whether the client demand is a high-performance core (large core).
[0126] Step S903, if yes, it means that the server needs to inherit the client's core running requirements and skip the small core when selecting the core; if no, it means that the core used to run the server meets the requirements and does not need to inherit the client's core running requirements.
[0127] like Fig.10 As shown, the scheduling policy inheritance method of the embodiment of the present invention may specifically include steps S1010 to S1012 or steps S1020 to S1022.
[0128] Step S1010: If the client triggers anti-preemption according to the periodic tick, the resource anti-preemption requirement is inherited to the server.
[0129] In step S1011 , the scheduler determines whether the client demand of the current thread indicates that preemption is required.
[0130] Step S1012, if yes, skip the logic of preempting the current thread (the thread other than the second thread on the server); if no, do not skip preempting the current thread.
[0131] Step S1020: If there is a situation where the client needs to prevent preemption when other threads are awakened, the resource anti-preemption requirement is inherited to the server.
[0132] In step S1021, the scheduler determines whether the client demand of the current thread indicates that preemption is required.
[0133] Step S1022, if yes, the scheduler allows other tasks (not the second thread) to be selected on other CPU cores as much as possible; if no, other tasks are allowed to preempt the second thread.
[0134] Take the binder communication between high-priority task A1 and low-priority task B1 as an example. When task B1 responds to task A1, that is, executes binder reply, this embodiment will make task B1 inherit the scheduling policy of task A1 (for example, priority running on large cores, high scheduling timeliness, more CPU time slices or various locking mechanisms, etc.). When task B1 completes binder reply, the previous scheduling policy will be restored. Through the inheritance of scheduling policy, task B1 will be executed quickly, and then task A1 can be quickly replied and woken up, reducing the blocking time of task A1. Fig.11As shown, taking the actual project of the smart cockpit as an example, under a high load situation, a schematic diagram comparing the binder communication time (binder transaction) of the traditional solution and the present invention is shown. The binder communication time of the traditional solution is 17ms892μs (before optimization), and the binder communication time of the present invention is 5ms765μs (after optimization). The performance index of the communication between the binder processes is improved by (17.892-5.765) / 17.892=67.78%. It can be seen that the present invention greatly improves the communication performance between the binder processes, shortens the execution time of the current process, improves the satisfaction with the cockpit related functions, and provides a better car experience for users.
[0135] In this embodiment, a scheduling strategy inheritance device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0136] This embodiment provides a scheduling strategy inheritance device, such as Fig.12 As shown, including:
[0137] The first acquisition module 1201 is used to acquire first priority information corresponding to the inter-process communication request sent by the client to the server, where the first priority information is used to represent the scheduling priority of the first thread in the client.
[0138] The second acquisition module 1202 is used to acquire second priority information, where the second priority information is used to represent the scheduling priority of a second thread in the server, where the second thread is a thread that the server serves the client.
[0139] The priority comparison module 1203 is used to compare the first priority information with the second priority information, and control whether the second thread inherits the scheduling priority of the first thread according to the comparison result.
[0140] In some optional implementations, the first priority information is a first priority value, and the second priority information is a second priority value; the priority comparison module 1203 includes a comparison unit.
[0141] A comparison unit is used to compare the first priority value with the second priority value to obtain a comparison result; wherein the comparison result is: the first priority value is greater than the second priority value or the first priority value is less than the second priority value or the first priority value is equal to the second priority value.
[0142] In some optional implementations, the priority comparison module 1203 further includes a control unit.
[0143] A control unit is used to control the second thread to inherit the scheduling priority of the first thread based on the first priority value being less than the second priority value, or to control the second thread not to inherit the scheduling priority of the first thread based on the first priority value being greater than or equal to the second priority value.
[0144] In some optional implementations, the first priority information is real-time priority information, and the second priority information is completely fair scheduling priority information.
[0145] In some optional implementations, the scheduling strategy inheritance device further includes a third acquisition module and a demand inheritance module.
[0146] The third acquisition module is used to acquire current demand information corresponding to the cross-process communication request sent by the client to the server, where the current demand information is used to represent the resource demand of the first thread.
[0147] The demand inheritance module is used to control the second thread to inherit the resource demand of the first thread according to the current demand information.
[0148] In some optional implementations, the current demand information is processor time slice demand information; the demand inheritance module is specifically used to reduce the virtual time of the second thread according to the processor time slice represented by the current demand information being greater than the processor time slice allocated to the second thread.
[0149] In some optional implementations, the current demand information is core demand information; the demand inheritance module is specifically used to change the core used by the second thread to a core that meets the core demand based on the core demand represented by the current demand information being higher than the performance of the core used by the second thread.
[0150] In some optional implementations, the current demand information is resource anti-preemption demand information; the demand inheritance module is specifically used to skip the logic of preempting the resources being used by the second thread according to the resource anti-preemption demand information, or to control the thread to preempt the resources being used by the second thread to run on the target core; wherein the target core is different from the core being used by the second thread.
[0151] In some optional implementations, the current demand information is a process descriptor, and the process descriptor includes multiple characters.
[0152] The further functional description of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0153] The scheduling policy inheritance device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0154] The embodiment of the present invention further provides a vehicle, the vehicle comprising a vehicle controller, the vehicle controller can be used to execute the scheduling strategy inheritance method provided in any of the above embodiments. The embodiment of the vehicle controller executing the scheduling strategy inheritance method is the same as the above corresponding embodiment, and will not be repeated here.
[0155] The vehicle controller may be, for example, a VCU (Vehicle Control Unit). Of course, based on the embodiment of the present invention, the vehicle controller may also be any vehicle-mounted controller that can execute the above-mentioned scheduling strategy inheritance method.
[0156] The embodiment of the present invention can also provide an electronic device having the above Fig.12 The scheduling policy shown inherits the device.
[0157] See also Fig.13 , Fig.13 is a schematic diagram of the structure of an electronic device provided by an optional embodiment of the present invention, such as Fig.13 As shown, the electronic device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig.13 A processor 10 is taken as an example.
[0158] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0159] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0160] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0161] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0162] The electronic device further comprises a communication interface 30 for the electronic device to communicate with other devices or a communication network.
[0163] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0164] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0165] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A scheduling strategy inheritance method, characterized in that: The method comprises: According to the inter-process communication request sent by the client to the server, first priority information corresponding to the inter-process communication request is obtained, where the first priority information is used to represent the scheduling priority of a first thread in the client; Acquire second priority information, where the second priority information is used to represent the scheduling priority of a second thread in the server, where the second thread is a thread that the server serves the client; The first priority information is compared with the second priority information, and whether the second thread inherits the scheduling priority of the first thread is controlled according to the comparison result.
2. The method according to claim 1, characterized in that The first priority information is a first priority value, and the second priority information is a second priority value; and comparing the first priority information with the second priority information includes: Comparing the first priority value with the second priority value to obtain the comparison result; The comparison result is: the first priority value is greater than the second priority value, or the first priority value is less than the second priority value, or the first priority value is equal to the second priority value.
3. The method according to claim 2, characterized in that The controlling, according to the comparison result, whether the second thread inherits the scheduling priority of the first thread includes: If the first priority value is smaller than the second priority value, the second thread is controlled to inherit the scheduling priority of the first thread.
4. The method according to claim 1, characterized in that: The first priority information is real-time priority information; The second priority information is completely fair scheduling priority information.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: According to the inter-process communication request sent by the client to the server, current demand information corresponding to the inter-process communication request is obtained, where the current demand information is used to characterize the resource demand of the first thread; According to the current demand information, the second thread is controlled to inherit the resource demand of the first thread.
6. The method according to claim 5, characterized in that The current demand information is processor time slice demand information; The controlling the second thread to inherit the resource demand of the first thread according to the current demand information includes: If the processor time slice represented by the current demand information is greater than the processor time slice allocated to the second thread, the virtual time of the second thread is reduced.
7. The method according to claim 5, characterized in that The current demand information is core demand information; and controlling the second thread to inherit the resource demand of the first thread according to the current demand information includes: If the core requirement represented by the current requirement information is higher than the performance of the core used by the second thread, the core used by the second thread is changed to a core that meets the core requirement.
8. The method according to claim 5, characterized in that The current demand information is resource anti-preemption demand information; and controlling the second thread to inherit the resource demand of the first thread according to the current demand information includes: According to the resource anti-preemption requirement information, the logic of preempting the resources being used by the second thread is skipped, or the thread to be preempted for the resources being used by the second thread is controlled to run on a target core; wherein the target core is different from the core being used by the second thread.
9. The method according to claim 5, characterized in that The current demand information is a process descriptor, and the process descriptor includes multiple characters.
10. A scheduling strategy inheritance device, characterized in that: The device comprises: A first acquisition module, configured to acquire first priority information corresponding to an inter-process communication request sent by a client to a server, wherein the first priority information is used to represent a scheduling priority of a first thread in the client; A second acquisition module is used to acquire second priority information, where the second priority information is used to represent the scheduling priority of a second thread in the server, where the second thread is a thread that the server serves the client; A priority comparison module is used to compare the first priority information with the second priority information, and control whether the second thread inherits the scheduling priority of the first thread according to the comparison result.
11. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the scheduling strategy inheritance method according to any one of claims 1 to 9 by executing the computer instructions.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the scheduling strategy inheritance method according to any one of claims 1 to 9.
13. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the scheduling strategy inheritance method according to any one of claims 1 to 9.
14. A vehicle, characterized in that: The vehicle includes a vehicle controller, and the vehicle controller is used to execute the scheduling strategy inheritance method according to any one of claims 1 to 9.
Citation Information
Cited By
Scheduling method of acceleration device, server cluster, device, medium and product
CN120407194A