Task scheduling method and device, electronic equipment, storage medium and program product
By identifying resource contention in the vehicle infotainment system and generating deadlines, and dynamically allocating processor resources, the resource contention problem of high-concurrency tasks in the vehicle infotainment system is solved, improving CPU utilization efficiency and overall performance.
Patent Information
- Application Number
- CN202410627851.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-20
- Publication Date
- 2025-11-21
AI Technical Summary
Existing Linux or Android operating systems cannot effectively manage resource contention for high-concurrency, performance-sensitive tasks in in-vehicle infotainment systems, resulting in low CPU utilization and increased scheduling latency, which affects overall performance.
By assessing the competition for computing resources between tasks, a deadline is generated, and processor resources are allocated to priority tasks within that deadline. This accelerates the computing process by monitoring resource requirements and dynamically adjusting resource allocation to ensure that critical tasks are completed within the deadline.
It effectively avoids competition for computing resources between tasks, ensures that critical tasks receive sufficient resources, improves processor core utilization and the balance of system resource allocation, and reduces resource idleness and task completion time.
Smart Images

Figure CN120994318A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a method and apparatus for task scheduling, an electronic device, and a storage medium. Background Technology
[0002] Currently, mainstream in-vehicle infotainment systems are primarily built on Linux or Android operating systems. Linux or Android use the Completely Fair Scheduler (CFS) for process (task) scheduling to ensure that all processes receive approximately equal CPU frame time, thus achieving global process scheduling fairness. However, in actual operation, especially when facing complex and diverse in-vehicle application environments, the CFS scheduler reveals some issues that are not entirely compatible with in-vehicle application scenarios, affecting CPU utilization efficiency and overall performance.
[0003] In-vehicle infotainment systems typically run multiple background services, real-time interactive applications, and vehicle control programs simultaneously. This high-concurrency nature of in-vehicle systems, compared to devices like smartphones, results in a significantly increased number of system tasks; this places higher demands on the real-time responsiveness and task scheduling efficiency of the CFS scheduler. As the number of tasks increases, the overhead of CFS also increases, potentially leading to increased scheduling latency. Simultaneously, in-vehicle systems also contain numerous performance-sensitive tasks, such as real-time navigation calculations, high-definition video stream encoding / decoding, and intelligent driving assistance calculations. These tasks have high CPU computing power requirements and are latency-sensitive. Furthermore, the in-vehicle system needs to ensure the smooth operation of basic services such as dashboard displays and voice recognition. Under the CFS scheduling framework, all tasks, regardless of priority, are allocated CPU time according to the same fair principle. When multiple high-performance tasks are active simultaneously, resource competition intensifies, potentially causing critical tasks to fail to obtain sufficient CPU time in a timely manner, resulting in performance degradation and increased latency. Especially in multi-core processor environments, CFS may be unable to allocate computing resources reasonably and efficiently when faced with a large number of concurrent performance-sensitive tasks, thus affecting the overall performance of the in-vehicle system and the user experience. Therefore, improving the vehicle's ability to handle complex application scenarios with high concurrency and multiple performance-sensitive tasks, and reducing resource contention and scheduling latency, has become an urgent problem to be solved. Summary of the Invention
[0004] This disclosure provides a task scheduling method, apparatus, electronic device, and storage medium. Its main purpose is to improve the processing capabilities of in-vehicle systems in complex application scenarios with high concurrency and multiple performance-sensitive tasks coexisting, reduce resource contention, and reduce scheduling latency.
[0005] According to a first aspect of this disclosure, a method for task scheduling is provided, comprising:
[0006] Determine whether there is a competition for computing resources when the first thread to be accelerated in the first task and the second thread to be accelerated in the second task are performing accelerated calculations respectively, wherein the first task and the second task are different tasks to be scheduled and processed;
[0007] If there is competition for computing resources, calculate the deadline for generating the first thread to be accelerated;
[0008] Within the deadline, the processor's computing resources will be allocated to the second task so that the second thread to be accelerated can be accelerated based on the computing resources;
[0009] When it is detected that the remaining time of the deadline is less than or equal to the time threshold, the computing resources are allocated to the first task to accelerate the computing of the first thread to be accelerated.
[0010] In some embodiments, before determining whether there is computing resource contention when the first thread to be accelerated in the first task and the second thread to be accelerated in the second task perform accelerated computation respectively, the method further includes:
[0011] The threads to be run are parsed, and those that need accelerated computation are marked as threads to be accelerated, wherein the threads to be accelerated include the first thread to be accelerated and the second thread to be accelerated.
[0012] In some embodiments, calculating the deadline for generating the first thread to be accelerated includes:
[0013] Obtain the shortest processing time of the first task and the frame time of the first task, wherein the frame time is the operating frequency or sampling rate of a specific task or device;
[0014] The frame time is determined to be the time after the second thread to be accelerated finishes its accelerated calculation and the remaining time is sufficient to process the frame time of the first thread to be accelerated.
[0015] The deadline is obtained by subtracting the shortest processing time from the end time of the target frame time.
[0016] In some embodiments, allocating the computing resources to the first task to accelerate the computation of the first thread to be accelerated includes:
[0017] Insert the first thread to be accelerated into the head of the processor's run queue linked list;
[0018] The processor core with the highest performance evaluation is invoked to accelerate the calculation of the first thread to be accelerated.
[0019] In some embodiments, the step of invoking a high-performance processing core in the processor to accelerate the computation of the first thread to be accelerated includes:
[0020] Monitor the load and number of active threads of each processing core in the processor to obtain the processing cores in an idle state;
[0021] The first thread to be accelerated is input into a processing core that is idle and has high rated computing power for accelerated computation.
[0022] If there are no idle processing cores, then iterate through all processing cores, exclude a preset number of processing cores running high-priority tasks, and obtain a list of non-idle cores.
[0023] Based on real-time computing power information, the list of non-idle cores is sorted, and the first thread to be accelerated is input into the processing core ranked first for accelerated computing.
[0024] In some embodiments, the method further includes:
[0025] Threads that are related among the threads to be accelerated are marked as related threads, wherein the scheduling priority of each thread marked as a related thread is the same.
[0026] Other threads that require accelerated computation and are associated with the first thread to be accelerated will undergo accelerated computation.
[0027] According to a second aspect of this disclosure, a task scheduling apparatus is provided, comprising:
[0028] The judgment unit is used to determine whether there is a competition for computing resources when the first thread to be accelerated in the first task and the second thread to be accelerated in the second task are performing accelerated calculations respectively, wherein the first task and the second task are different tasks to be scheduled and processed.
[0029] The generation unit is used to calculate the deadline for generating the first thread to be accelerated when there is a competition for computing resources between the first thread to be accelerated and the second thread to be accelerated.
[0030] The first computing unit is configured to allocate the processor's computing resources to the second task within the deadline, so as to accelerate the second thread to be accelerated based on the computing resources.
[0031] The second computing unit is used to detect when the remaining time of the deadline is less than or equal to the time threshold, so as to allocate the computing resources to the first task and accelerate the computing of the first thread to be accelerated.
[0032] In some embodiments, the apparatus further includes:
[0033] The first marking unit is used to parse the threads to be run before the judgment unit determines whether there is a competition for computing resources between the first thread to be accelerated and the second thread to be accelerated, and to mark the threads to be run that need to be accelerated as threads to be accelerated, wherein the threads to be accelerated include the first thread to be accelerated and the second thread to be accelerated.
[0034] In some embodiments, the generation unit includes:
[0035] The acquisition module is used to acquire the shortest processing time of the first task and the frame time of the first task, wherein the frame time is the operating frequency or sampling rate of a specific task or device.
[0036] The determining module is used to determine the frame time after the second thread to be accelerated finishes the accelerated calculation, and the remaining time length is sufficient to process the first thread to be accelerated, as the target frame time;
[0037] The calculation module is used to subtract the shortest processing time from the end time of the target frame time to obtain the deadline.
[0038] In some embodiments, the second computing unit includes:
[0039] An insertion module is used to insert the first thread to be accelerated into the head of the processor's run queue linked list;
[0040] The acceleration module is used to call upon the high-performance processing cores in the processor to accelerate the computation of the first thread to be accelerated.
[0041] In some embodiments, the acceleration module is further configured to:
[0042] Monitor the load and number of active threads of each processing core in the processor to obtain the processing cores in an idle state;
[0043] The first thread to be accelerated is input into a processing core that is idle and has high rated computing power for accelerated computation.
[0044] If there are no idle processing cores, then iterate through all processing cores, exclude a preset number of processing cores running high-priority tasks, and obtain a list of non-idle cores.
[0045] Based on real-time computing power information, the list of non-idle cores is sorted, and the first thread to be accelerated is input into the processing core ranked first for accelerated computing.
[0046] In some embodiments, the apparatus further includes:
[0047] The second marking unit is used to mark the threads that have a relationship among the threads to be accelerated as associated threads, wherein the threads marked as associated threads have the same scheduling priority.
[0048] The third computing unit is used to perform accelerated computing on other threads that need to be accelerated and are associated with the first thread to be accelerated.
[0049] According to a third aspect of this disclosure, an electronic device is provided, comprising:
[0050] At least one processor; and
[0051] A memory communicatively connected to the at least one processor; wherein,
[0052] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect above.
[0053] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are configured to cause the computer to perform the method described in the first aspect above.
[0054] According to a fifth aspect of this disclosure, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the method described in the first aspect above.
[0055] This disclosure provides a task scheduling method, apparatus, electronic device, and storage medium. It determines whether there is computational resource contention when a first thread to be accelerated in a first task and a second thread to be accelerated in a second task are performing accelerated computations, wherein the first task and the second task are different tasks to be scheduled. If computational resource contention exists, a deadline for the first thread to be accelerated is calculated and generated. Within the deadline, processor resources are allocated to the second task to accelerate the second thread based on these resources. When the remaining time of the deadline is less than or equal to a time threshold, the computational resources are allocated to the first task to accelerate the first thread. Compared with related technologies, this disclosure, by identifying and scheduling the first thread to be accelerated in the first task and the second thread to be accelerated in the second task to perform accelerated computations at different times, avoids both threads competing for processor resources at the same time. Even in the case of concurrent execution of multiple tasks, it ensures that at a certain moment, the important thread to be accelerated can obtain sufficient computational resources, avoiding performance bottlenecks caused by resource contention.
[0056] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become readily apparent from the following description. Attached Figure Description
[0057] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0058] Figure 1 A flowchart illustrating a task scheduling method provided in an embodiment of this disclosure;
[0059] Figure 2 This is a schematic diagram of a task scheduling boost conflict.
[0060] Figure 3 A schematic diagram of a task scheduling method provided in an embodiment of this disclosure;
[0061] Figure 4 A flowchart illustrating another task scheduling method provided in this embodiment of the disclosure;
[0062] Figure 5 A schematic diagram of the structure of a task scheduling device provided in an embodiment of this disclosure;
[0063] Figure 6 A schematic diagram of another task scheduling apparatus provided in an embodiment of this disclosure;
[0064] Figure 7A schematic block diagram of an example electronic device provided for embodiments of this disclosure. Detailed Implementation
[0065] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0066] The following description, with reference to the accompanying drawings, outlines a method, apparatus, electronic device, and storage medium for task scheduling according to embodiments of the present disclosure.
[0067] Figure 1 This is a flowchart illustrating a task scheduling method provided in an embodiment of the present disclosure.
[0068] like Figure 1 As shown, the method includes the following steps:
[0069] Step 101: Determine whether there is a competition for computing resources when the first thread to be accelerated in the first task and the second thread to be accelerated in the second task are performing accelerated calculations respectively. Here, the first task and the second task are different tasks to be scheduled and processed.
[0070] Currently, the CFS scheduler often encounters problems when dealing with high-concurrency scenarios, such as... Figure 2 This illustrates a resource contention scenario. A conflict occurs when task A and task B are boosted (the black line perpendicular to tasks A and B represents the frame time of task A).
[0071] In the embodiments of this disclosure, an analysis is conducted to determine whether there is computational resource contention, i.e., whether there is a boost conflict, between the first thread to be accelerated in the first task (taking task A as an example) and the second thread to be accelerated in the second task (taking task B as an example) during their respective boost calculations. To determine whether there is computational resource contention between the first thread to be accelerated in the first task and the second thread to be accelerated in the second task during boost calculations, an in-depth analysis can be performed from multiple perspectives, including thread resource requirements, task execution environment, and system optimization measures. By comprehensively considering these factors, the likelihood of resource contention can be assessed more accurately.
[0072] Step 102: If there is competition for computing resources, calculate the deadline for generating the first thread to be accelerated.
[0073] In the embodiments of this disclosure, in complex multi-tasking environments, especially those with competition for computing resources, to improve system resource utilization and ensure that the performance requirements of critical services are met, task execution can be managed in a refined manner by combining service characteristics and preset customized processing times. For each service, its minimum necessary processing time (i.e., customized processing time) is pre-determined based on its service characteristics, and then the final deadline for the task is set based on this. In this way, while meeting its service requirements, the computing resources occupied by the portion of the task exceeding the customized processing time can be allocated to other tasks in a timely manner, achieving effective resource sharing.
[0074] A comprehensive review of all business types involved in the system is conducted to gain a deep understanding of their respective business processes, data processing logic, performance requirements, and resource consumption characteristics. Based on these business characteristics, a reasonable "customized processing time" is set for each business, which is the shortest necessary time required to complete the business. This time should fully consider the basic functional requirements of the business, service quality standards, and potential performance bottlenecks to ensure that even under high load or resource constraints, the business can still receive minimum effective processing within this time. General processing time is a relative concept, depending on the operating frequency or sampling rate of a specific task or device; it can also be set based on human perception of time. If the first task corresponds to a video rendering task, in 60Hz video rendering, the general processing time (T_general) is the time required to render one frame, and the rendering thread needs to complete the rendering of one frame every 0.01667 seconds.
[0075] Based on the customized processing time for each type of business, a deadline is set for each specific business task. This deadline is equal to the general processing time minus the corresponding customized processing time. Different businesses will have different general processing times.
[0076] Step 103: Within the deadline, allocate the processor's computing resources to the second task so as to accelerate the second thread to be accelerated based on the computing resources.
[0077] In the embodiments of this disclosure, in complex environments facing competition for computing resources, to maximize system performance and resource utilization while ensuring the efficient execution of critical tasks, processor computing resources can be flexibly allocated, especially dynamically adjusted within specific deadlines for different tasks. A deadline for the first task (corresponding to the first thread to be accelerated) is clearly defined. This deadline is set based on full consideration of its business characteristics and customized processing time, ensuring that within this deadline, the first task can complete the acceleration computation (boost) for the first thread to be accelerated and its related threads, meeting basic business needs, while releasing computing resources beyond the customized processing time. Please refer to [link to relevant documentation]. Figure 3 After determining the deadline for task A, the computing resources in the system can be allocated to the second task in the Deadline to accelerate the computation (boost) of the second thread to be accelerated and its related threads.
[0078] In some other embodiments of this disclosure, if, within the deadline of the first task, it is detected that its remaining computing demand is significantly lower than the currently occupied computing resources, and the remaining time is sufficient to ensure its timely completion, it can be determined that there is room for resource allocation. At this time, the system should trigger a resource allocation mechanism to transfer some of the excess computing resources from the first task to the second task.
[0079] Step 104: When it is detected that the remaining time of the deadline is less than or equal to the time threshold, the computing resources are allocated to the first task to accelerate the first thread to be accelerated.
[0080] In the embodiments of this disclosure, in complex multi-tasking environments, especially when there is competition for computing resources, in order to ensure that critical tasks (i.e., the first task corresponding to the first thread to be accelerated) can be completed smoothly within the predetermined deadline, and at the same time maximize the utilization of system resources, the task execution status can be dynamically monitored and computing resources can be flexibly allocated when necessary.
[0081] Set a clear deadline for the primary task. This deadline should be determined comprehensively based on factors such as business needs, performance metrics, and resource constraints, ensuring that the task can complete its core functions within this timeframe. Simultaneously, set a time threshold, typically lower than the deadline, to trigger emergency allocation of computing resources. It should be noted that this time threshold needs to be determined based on the computing power information of different processors to ensure the task can be completed within the deadline. Continuously monitor the remaining time before the deadline. When the remaining time is less than or equal to the preset time threshold, the system should trigger the resource allocation mechanism. At this point, the task may face challenges such as time constraints, increased resource demands, or prominent performance bottlenecks, requiring additional computing resources to ensure timely completion. Please continue reading... Figure 3After determining the deadline for task A, the system's computing resources can be allocated to task B during the deadline period to accelerate the second thread to be accelerated and its related threads (boost). As the deadline approaches, the system should quickly adjust its resource allocation strategy, allocating more processor computing resources to task A for DL boost.
[0082] During task execution, the progress of the first task is monitored in real time, including key indicators such as completed workload, remaining workload, and current execution speed. Simultaneously, its usage of processor computing resources, such as CPU utilization, memory usage, and I / O operation frequency, is closely monitored to accurately assess the task's resource requirements.
[0083] This disclosure provides a task scheduling method that determines whether there is computational resource contention when a first thread to be accelerated in a first task and a second thread to be accelerated in a second task are performing accelerated computations, wherein the first task and the second task are different tasks to be scheduled and processed; if computational resource contention exists, a deadline for the first thread to be accelerated is calculated and generated; within the deadline, the processor's computational resources are allocated to the second task to accelerate the second thread to be accelerated based on the computational resources; when it is detected that the remaining time of the deadline is less than or equal to a time threshold, the computational resources are allocated to the first task to accelerate the first thread to be accelerated. Compared with related technologies, this disclosure, by identifying and scheduling the first thread to be accelerated in the first task and the second thread to be accelerated in the second task to perform accelerated computations at different times, can avoid the two threads competing for processor computational resources at the same time. Even in the case of multi-task concurrent execution, it can ensure that at a certain time, the important thread to be accelerated can obtain sufficient computational resources, avoiding performance bottlenecks caused by resource contention; it helps to improve the utilization of processor cores, make the system resource allocation more balanced, and reduce resource idleness.
[0084] To clearly illustrate the embodiments of this disclosure, this embodiment provides a flowchart of another task scheduling method.
[0085] like Figure 4 As shown, the method includes the following steps:
[0086] Step 201: parse the threads to be run and mark the threads that need to be accelerated as threads to be accelerated, wherein the threads to be accelerated include the first thread to be accelerated and the second thread to be accelerated.
[0087] Specifically, in step 201, in a complex vehicle system with multi-threaded concurrent execution, in order to optimize system resource allocation and ensure that critical tasks can be executed efficiently, it is necessary to conduct in-depth analysis and refined management of all threads to be run.
[0088] We conduct in-depth analysis of running threads, examining key factors such as their execution logic, computational complexity, data dependencies, expected execution time, and resource consumption characteristics. Through performance analysis tools, code review, and logging, we quantify and evaluate the performance characteristics of each thread, including CPU utilization, memory usage, I / O operation frequency, and context switching frequency, providing data support for subsequent resource scheduling decisions.
[0089] Based on business needs, performance metrics, and user priorities, threads requiring high computing performance or significantly impacting overall system response speed and service quality are identified. These threads typically involve complex data processing, real-time computing, and critical business logic, needing to complete computational tasks efficiently within a short timeframe and heavily reliant on system resources, especially processor resources. These identified threads requiring accelerated computing are marked as "threads to be accelerated." Threads marked as "threads to be accelerated" receive special attention and processing during system scheduling, resource allocation, priority adjustment, and load balancing. The scheduler can prioritize allocating processor resources to these threads based on the marking information, ensuring they receive sufficient computing power for accelerated computation.
[0090] Step 202: Mark the threads that have a relationship among the threads to be accelerated as associated threads, wherein the threads marked as associated threads have the same scheduling priority.
[0091] Specifically, in step 202, after identifying the threads to be accelerated among the pending threads in the vehicle system, threads with related relationships are further marked as "related threads." These threads have interdependent and collaborative relationships, and their execution progress directly affects each other's running status and the overall task completion. The tasks of related threads are usually interdependent; the output of one thread may serve as the input of another thread, or they may jointly operate on shared data. When one related thread executes slowly due to insufficient computing resources, it may cause other related threads that depend on its output or share resources to enter a waiting state, thus causing process blocking. This may lead to the entire process being paused or delayed, reducing the overall throughput of the system.
[0092] Step 203: Determine whether there is a competition for computing resources when the first thread to be accelerated in the first task and the second thread to be accelerated in the second task are performing accelerated calculations respectively. Here, the first task and the second task are different tasks to be scheduled and processed.
[0093] Specifically, in step 203, the existence of resource contention can be determined by obtaining the processing priorities of the first thread to be accelerated and the second thread to be accelerated when performing accelerated calculations; if the difference between the processing priorities of the first thread to be accelerated and the second thread to be accelerated does not exceed the priority threshold, it is determined that there is computational resource contention when the first thread to be accelerated and the second thread to be accelerated perform accelerated calculations.
[0094] Step 204: Obtain the shortest processing time of the first task and the frame time of the first task.
[0095] Step 205: Determine the frame time as the time after the second thread to be accelerated finishes its acceleration calculation and the remaining time is sufficient to process the frame time of the first thread to be accelerated.
[0096] Step 206: Subtract the shortest processing time from the end time of the target frame time to obtain the deadline.
[0097] Specifically, in steps 204 to 206, a comprehensive review of all business types involved in the system is conducted to gain a deep understanding of their respective business processes, data processing logic, performance requirements, and resource consumption characteristics. Based on these business characteristics, a reasonable "customized processing time" is set for each business, which is the shortest processing time required to complete the business. This time should fully consider the basic functional requirements of the business, service quality standards, and potential performance bottlenecks to ensure that even under high load or resource constraints, the business can still receive minimum effective processing within this time. Frame time (i.e., general processing time) is a relative concept, depending on the operating frequency or sampling rate of a specific task or device; at the same time, general processing time can also be set according to the time that humans can perceive. If the first task corresponds to a video rendering task, in 60Hz video rendering, the general processing time (T_general) is the time required to render one frame, and the rendering thread needs to complete the rendering of one frame every 0.01667 seconds. The frame time of the first task is the general processing time; please refer to [link / reference]. Figure 3 , Figure 3 Each vertical black line represents a frame.
[0098] Based on the customized processing time for each business function, a deadline is set for each specific business task. This deadline equals the general processing time minus the corresponding customized processing time. Different businesses will have different general processing times. For example, if the general processing time for a business is T seconds and its customized processing time is t seconds, then the deadline for that business is Tt seconds. This means that as long as the task is completed within the deadline, the basic requirements of the business will be met, and computing resources will be freed up for other tasks to use in the remaining time.
[0099] Specifically, the deadline is calculated based on the first thread to be accelerated. Based on its business characteristics and the current resource competition situation, the actual deadline is calculated using the aforementioned deadline principle.
[0100] Step 207: Within the deadline, allocate the processor's computing resources to the second task so as to accelerate the second thread to be accelerated based on the computing resources.
[0101] Specifically, in step 207, in a complex environment facing competition for computing resources, to maximize system performance and resource utilization while ensuring the efficient execution of critical tasks, processor computing resources can be flexibly allocated, especially dynamically adjusted within specific deadlines for different tasks. The deadline for the first task (corresponding to the first thread to be accelerated) is clearly defined. This deadline is set based on a full consideration of its business characteristics and customized processing time, ensuring that within this deadline, the first task can complete the acceleration computation (boost) for the first thread to be accelerated and its related threads, meeting basic business needs, while releasing computing resources beyond the customized processing time. Please refer to [link to relevant documentation]. Figure 3 After determining the deadline for task A, the computing resources in the system can be allocated to the second task in the Deadline to accelerate the computation (boost) of the second thread to be accelerated and its related threads.
[0102] When accelerating the calculation of the second thread to be accelerated and its associated threads in the second task, the acceleration processing method shown in steps 208 to 210 can be adopted.
[0103] Step 208: Insert the first thread to be accelerated into the head of the processor's run queue linked list.
[0104] Specifically, in step 208, after completing the accelerated calculation for the second thread to be accelerated and its associated threads, the first thread to be accelerated needs to be accelerated. By inserting the first thread to be accelerated into the head of the run queue linked list, it is given priority for acceleration processing. The virtual compensation time (vruntime) generated by the CFS scheduler can be ignored, and it can be directly scheduled with priority.
[0105] Step 209: Invoke the high-performance processing core in the processor to accelerate the calculation of the first thread to be accelerated.
[0106] Furthermore, as a refinement of this disclosure, the step of calling the high-performance processing core in the processor to accelerate the first thread to be accelerated includes: monitoring the load and number of active threads of each processing core in the processor to obtain idle processing cores; inputting the first thread to be accelerated into an idle processing core with high rated computing power for accelerated computation; if there are no idle processing cores, traversing all processing cores, excluding a preset number of processing cores running high-priority tasks to obtain a list of non-idle cores; sorting the list of non-idle cores according to real-time computing power information, and inputting the first thread to be accelerated into the processing core ranked first for accelerated computation.
[0107] Specifically, in step 209, during the operation of the vehicle system, to ensure that the first thread to be accelerated can obtain sufficient computing resources for accelerated computation, the system needs to continuously monitor the working status of each processing core in the processor in order to make accurate scheduling decisions. The system collects the load status of each processing core in the processor in real time through the kernel interface or dedicated monitoring tools, including but not limited to indicators such as CPU utilization, context switch count, and cache hit rate, to comprehensively reflect the core's workload. Simultaneously, it counts the number of currently active threads on each core to understand the core's concurrent task status.
[0108] Based on collected core load data and active thread counts, the system identifies currently idle processing cores—those with low load, few active threads, low resource utilization, and no high-priority tasks running. By monitoring processor core status in real time, the system accurately identifies idle cores or optimal non-idle cores and schedules the first thread to be accelerated to these cores for accelerated computation. This ensures that critical tasks receive sufficient computing resources under various load scenarios, achieving efficient execution and improving the overall performance and responsiveness of the vehicle's infotainment system.
[0109] Step 210: Perform accelerated computation on other threads that need accelerated computation and are associated with the first thread to be accelerated.
[0110] Specifically, in step 210, the associated threads marked in step 202 are accelerated (boosted). These associated threads are interdependent and work collaboratively; their execution progress directly affects each other's running status and the overall task completion. The tasks of associated threads are usually interdependent; the output of one thread may serve as the input of another thread, or they may jointly operate on shared data. When one associated thread executes slowly due to insufficient computing resources, it may cause other associated threads that depend on its output or shared resources to enter a waiting state, thus causing process blocking. This may lead to the entire process being paused or delayed, reducing the overall throughput of the system.
[0111] In summary, for threads to be accelerated, this embodiment can obtain higher priority resource allocation within a specific time period, reducing blocking and waiting time caused by resource contention, thereby accelerating execution and shortening task completion time. Since the accelerated threads of the first and second tasks are scheduled for accelerated computation in different time periods, the frequent competition for processor time within the same period is reduced, indirectly lowering unnecessary thread context switching overhead. Context switching not only consumes processor time but can also lead to performance losses such as cache misses. Through staggered scheduling, the processor can focus on executing the same task for a period of time, improving cache hit rate and further enhancing execution efficiency. In multi-tasking environments, especially for tasks with real-time requirements or Quality of Service (QoS) constraints, reasonable scheduling of accelerated threads can effectively avoid service quality degradation caused by resource contention. For example, in cloud services, data centers, or embedded systems, this scheduling strategy can ensure that critical business threads are given priority, maintaining service stability and user satisfaction. By identifying and staggering the accelerated computation periods of the accelerated threads in the first and second tasks, competition for computing resources can be effectively reduced, resource utilization and task execution efficiency can be improved, and context switching overhead can be reduced.
[0112] It should be noted that the embodiments of this disclosure may include multiple steps. For ease of description, these steps are numbered, but these numbers are not a limitation on the execution time slots or execution order between the steps; these steps can be implemented in any order, and the embodiments of this disclosure do not limit this.
[0113] Corresponding to the task scheduling method described above, the present invention also proposes a task scheduling apparatus. Since the apparatus embodiments of the present invention correspond to the method embodiments described above, details not disclosed in the apparatus embodiments can be referred to in the method embodiments described above, and will not be repeated here.
[0114] Figure 5 This is a schematic diagram of the structure of a task scheduling device provided in an embodiment of the present disclosure, as shown below. Figure 5 As shown, it includes:
[0115] The judgment unit 31 is used to determine whether there is a competition for computing resources when the first thread to be accelerated in the first task and the second thread to be accelerated in the second task are performing accelerated calculations respectively, wherein the first task and the second task are different tasks to be scheduled and processed.
[0116] The generation unit 32 is used to calculate the deadline for generating the first thread to be accelerated when there is a competition for computing resources between the first thread to be accelerated and the second thread to be accelerated.
[0117] The first computing unit 33 is used to allocate the processor's computing resources to the second task within the deadline, so as to accelerate the second thread to be accelerated based on the computing resources.
[0118] The second computing unit 34 is used to allocate computing resources to the first task when it detects that the remaining time of the deadline is less than or equal to the time threshold, so as to accelerate the computing of the first thread to be accelerated.
[0119] This disclosure provides a task scheduling apparatus that determines whether there is computational resource contention when a first thread to be accelerated in a first task and a second thread to be accelerated in a second task are performing accelerated computations, wherein the first task and the second task are different tasks to be scheduled. If computational resource contention exists, a deadline for the first thread to be accelerated is calculated and generated. Within the deadline, the processor's computational resources are allocated to the second task to accelerate the second thread based on the computational resources. When it is detected that the remaining time of the deadline is less than or equal to a time threshold, the computational resources are allocated to the first task to accelerate the first thread. Compared with related technologies, this disclosure, by identifying and scheduling the first thread to be accelerated in the first task and the second thread to be accelerated in the second task to perform accelerated computations at different times, can avoid the two threads competing for processor computational resources at the same time. Even in the case of multi-task concurrent execution, it can ensure that at a certain time, the important thread to be accelerated can obtain sufficient computational resources, avoiding performance bottlenecks caused by resource contention. This helps to improve the utilization of processor cores, make the system resource allocation more balanced, and reduce resource idleness.
[0120] Furthermore, in one possible implementation of this embodiment, such as Figure 6 As shown, the device further includes:
[0121] The first marking unit 35 is used to parse the threads to be run before the judgment unit determines whether there is a competition for computing resources between the first thread to be accelerated and the second thread to be accelerated, and to mark the threads to be run that need to be accelerated as threads to be accelerated, wherein the threads to be accelerated include the first thread to be accelerated and the second thread to be accelerated.
[0122] Furthermore, in one possible implementation of this embodiment, such as Figure 6 As shown, the generation unit 32 includes:
[0123] The acquisition module 321 is used to acquire the shortest processing time of the first task and the frame time of the first task, wherein the frame time is the operating frequency or sampling rate of a specific task or device.
[0124] The determining module 322 is used to determine the frame time after the second thread to be accelerated ends the acceleration calculation and the remaining time length can handle the first thread to be accelerated as the target frame time;
[0125] The calculation module 323 is used to subtract the shortest processing time from the end time of the target frame time to obtain the deadline.
[0126] Furthermore, in one possible implementation of this embodiment, such as Figure 6 As shown, the second computing unit 34 includes:
[0127] The queue-jumping module 341 is used to insert the first thread to be accelerated into the head of the processor's run queue linked list;
[0128] The acceleration module 342 is used to call the high-performance processing core in the processor to accelerate the calculation of the first thread to be accelerated.
[0129] Furthermore, in one possible implementation of this embodiment, the acceleration module 342 is further configured to:
[0130] Monitor the load and number of active threads of each processing core in the processor to obtain the processing cores in an idle state;
[0131] The first thread to be accelerated is input into a processing core that is idle and has high rated computing power for accelerated computation.
[0132] If there are no idle processing cores, then iterate through all processing cores, exclude a preset number of processing cores running high-priority tasks, and obtain a list of non-idle cores.
[0133] Based on real-time computing power information, the list of non-idle cores is sorted, and the first thread to be accelerated is input into the processing core ranked first for accelerated computing.
[0134] Furthermore, in one possible implementation of this embodiment, such as Figure 6 As shown, the device further includes:
[0135] The second marking unit 36 is used to mark the threads that have a relationship in the threads to be accelerated as associated threads, wherein the threads marked as associated threads have the same scheduling priority.
[0136] The third calculation unit 37 is used to perform accelerated calculation on other threads that need to be accelerated and are associated with the first thread to be accelerated.
[0137] It should be noted that the foregoing explanation of the method embodiments also applies to the apparatus of this embodiment, and the principle is the same, so it is not limited in this embodiment.
[0138] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0139] Figure 7 A schematic block diagram of an example electronic device 400 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0140] like Figure 7 As shown, device 400 includes a computing unit 401, which can perform various appropriate actions and processes based on a computer program stored in ROM (Read-Only Memory) 402 or a computer program loaded from storage unit 408 into RAM (Random Access Memory) 403. RAM 403 may also store various programs and data required for the operation of device 400. The computing unit 401, ROM 402, and RAM 403 are interconnected via bus 404. I / O (Input / Output) interface 405 is also connected to bus 404.
[0141] Multiple components in device 400 are connected to I / O interface 405, including: input unit 406, such as keyboard, mouse, etc.; output unit 407, such as various types of monitors, speakers, etc.; storage unit 408, such as disk, optical disk, etc.; and communication unit 409, such as network card, modem, wireless transceiver, etc. Communication unit 409 allows device 400 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0142] The computing unit 401 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, CPUs (Central Processing Units), GPUs (Graphics Processing Units), various special-purpose AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, DSPs (Digital Signal Processors), and any suitable processor, controller, microcontroller, etc. The computing unit 401 performs the various methods and processes described above, such as task scheduling methods. For example, in some embodiments, the task scheduling method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on device 400 via ROM 402 and / or communication unit 409. When the computer program is loaded into RAM 403 and executed by the computing unit 401, one or more steps of the methods described above may be performed. Alternatively, in other embodiments, computing unit 401 may be configured to perform the aforementioned task scheduling method by any other suitable means (e.g., by means of firmware).
[0143] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application-Specific Standard Products), SOCs (System-on-Chips), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various implementations may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0144] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0145] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, RAM, ROM, EPROM (Electrically Programmable Read-Only Memory) or flash memory, optical fiber, CD-ROM (Compact Disc Read-Only Memory), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0146] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0147] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include LANs (Local Area Networks), WANs (Wide Area Networks), the Internet, and blockchain networks.
[0148] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. A server can be a cloud server, also known as a cloud computing server or cloud host, a hosting product within the cloud computing service ecosystem, addressing the shortcomings of traditional physical hosts and VPS (Virtual Private Server, or simply "VPS") services, such as high management difficulty and weak business scalability. Servers can also be servers for distributed systems or servers incorporating blockchain technology.
[0149] It's important to note that artificial intelligence (AI) is the study of enabling computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, and planning). It encompasses both hardware and software technologies. AI hardware technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, and big data processing. AI software technologies primarily include computer vision, speech recognition, natural language processing, machine learning / deep learning, big data processing, and knowledge graph technologies.
[0150] The various numerical designations such as "first," "second," etc., used in this disclosure are merely for ease of description and are not intended to limit the scope of the embodiments of this disclosure, nor do they indicate a sequential order.
[0151] At least one of the features described in this disclosure can also be described as one or more, and multiple features can be two, three, four or more, and this disclosure does not impose any limitations. In the embodiments of this disclosure, for a technical feature, the technical features in that technical feature are distinguished by "first", "second", "third", "A", "B", "C" and "D", etc., and there is no sequential order or size order among the technical features described by "first", "second", "third", "A", "B", "C" and "D".
[0152] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0153] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A task scheduling method, characterized in that, include: Determine whether there is a competition for computing resources when the first thread to be accelerated in the first task and the second thread to be accelerated in the second task are performing accelerated calculations respectively, wherein the first task and the second task are different tasks to be scheduled and processed; If there is competition for computing resources, calculate the deadline for generating the first thread to be accelerated; Within the deadline, the processor's computing resources will be allocated to the second task so that the second thread to be accelerated can be accelerated based on the computing resources; When it is detected that the remaining time of the deadline is less than or equal to the time threshold, the computing resources are allocated to the first task to accelerate the computing of the first thread to be accelerated.
2. The method according to claim 1, characterized in that, Before determining whether there is computational resource contention when the first thread to be accelerated in the first task and the second thread to be accelerated in the second task perform accelerated computation, the method further includes: The threads to be run are parsed, and those that need accelerated computation are marked as threads to be accelerated, wherein the threads to be accelerated include the first thread to be accelerated and the second thread to be accelerated.
3. The method according to claim 1, characterized in that, The calculation of the deadline for generating the first thread to be accelerated includes: Obtain the shortest processing time of the first task and the frame time of the first task, wherein the frame time is the running frequency or sampling rate of the task or device; The frame time is determined to be the time after the second thread to be accelerated finishes its accelerated calculation and the remaining time is sufficient to process the frame time of the first thread to be accelerated. The deadline is obtained by subtracting the shortest processing time from the end time of the target frame time.
4. The method according to claim 1, characterized in that, The step of allocating the computing resources to the first task to accelerate the computing of the first thread to be accelerated includes: Insert the first thread to be accelerated into the head of the processor's run queue linked list; The processor core with the highest performance evaluation is invoked to accelerate the calculation of the first thread to be accelerated.
5. The method according to claim 4, characterized in that, The step of calling the high-performance processing core in the processor to accelerate the first thread to be accelerated includes: Monitor the load and number of active threads of each processing core in the processor to obtain the processing cores in an idle state; The first thread to be accelerated is input into a processing core that is idle and has high rated computing power for accelerated computation. If there are no idle processing cores, then iterate through all processing cores, exclude a preset number of processing cores running high-priority tasks, and obtain a list of non-idle cores. Based on real-time computing power information, the list of non-idle cores is sorted, and the first thread to be accelerated is input into the processing core ranked first for accelerated computing.
6. The method according to claim 1, characterized in that, The method further includes: Threads that are related among the threads to be accelerated are marked as related threads, wherein the scheduling priority of each thread marked as a related thread is the same. Other threads that require accelerated computation and are associated with the first thread to be accelerated will undergo accelerated computation.
7. A task scheduling apparatus, characterized in that, include: The judgment unit is used to determine whether there is a competition for computing resources when the first thread to be accelerated in the first task and the second thread to be accelerated in the second task are performing accelerated calculations respectively, wherein the first task and the second task are different tasks to be scheduled and processed. The generation unit is used to calculate the deadline for generating the first thread to be accelerated when there is a competition for computing resources between the first thread to be accelerated and the second thread to be accelerated. The first computing unit is configured to allocate the processor's computing resources to the second task within the deadline, so as to accelerate the second thread to be accelerated based on the computing resources. The second computing unit is used to allocate computing resources to the first task when it detects that the remaining time of the deadline is less than or equal to the time threshold, so as to accelerate the computing of the first thread to be accelerated.
8. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-6.
10. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method according to any one of claims 1-6.