Task scheduling method and electronic device
Patent Information
- Application Number
- CN202611007810.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-08
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2046-07-08
AI Technical Summary
[0004]本申请的目的在于,针对上述现有技术中的不足,提供一种任务调度方法及电子设备,以解决现有技术中任务调度难以兼顾实时性、安全性和资源利用率的实际需要的问题
本申请提供了一种任务调度方法及电子设备,扫描操作系统中当前帧周期的多个待执行任务,确定各待执行任务的任务类型及外设访问需求特征,并确定待执行任务之间的依赖关系,根据各待执行任务的任务类型以及外设访问需求特征,确定当前帧周期中各待执行任务的访问控制策略,包括条件访问策略、同步点控制策略、多缓冲策略、时间片锁定策略中的至少一种。根据各待执行任务的任务类型、外设访问需求特征以及待执行任务之间的依赖关系,确定当前帧周期的同步点规划信息,并根据当前帧周期中各待执行任务的访问控制策略、同步点规划信息以及待执行任务之间的依赖关系,在当前帧周期内执行各待执行任务。在任务执行过程中通过统一外设访问接口访问各外设,且同一外设的访问在同步点处序列化进行。实现任务调度与外设访问的高效协同,确保核心任务的实时性与周期性,消除时序漂移,并提升非核心任务的调度灵活性,进而提升资源利用率,并通过访问控制策略降低同步开销,确保共享外设的确定性与安全一致性。
Smart Images

Figure CN122526757B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a task scheduling method and an electronic device. Background Technology
[0002] In a multi-core embedded real-time operating system (RTOS), multiple processor cores often need to work together to complete tasks with high real-time requirements. These systems typically include peripherals shared by multiple cores, such as communication interfaces, sensors, or storage devices.
[0003] However, when multiple cores access these shared peripherals simultaneously, resource contention can easily occur, leading to task blocking, timing disruptions, and even data errors. Traditional solutions often optimize task scheduling, data transmission paths, or resource access individually, making it difficult to translate local optimizations into system-level gains. Furthermore, these local optimizations often contain irreconcilable contradictions, making it difficult to balance real-time performance, security, and resource utilization. Summary of the Invention
[0004] The purpose of this application is to provide a task scheduling method and electronic device to address the shortcomings of the prior art, thereby solving the problem that task scheduling in the prior art is difficult to balance the actual needs of real-time performance, security and resource utilization.
[0005] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows: In a first aspect, embodiments of this application provide a task scheduling method, the method comprising: Scan multiple tasks to be executed in the current frame period of the operating system, determine the task type and peripheral access requirement characteristics of each task to be executed, and determine the dependencies between the tasks to be executed; the task type includes core tasks and non-core tasks, and the peripheral access requirement characteristics include at least: peripheral access frequency and shared peripheral access identifier, the shared peripheral access identifier is used to characterize whether the task to be executed accesses the same peripheral as other tasks to be executed. Based on the task type and peripheral access requirements of each task to be executed, the access control policy for each task to be executed in the current frame period is determined; the access control policy includes at least one of conditional access policy, synchronization point control policy, multi-buffering policy, and time slice locking policy. Based on the task type, peripheral access requirements, and dependencies between the tasks to be executed, the synchronization point planning information for the current frame period is determined. The synchronization point planning information is used to indicate the timing of the distribution of synchronization points in the current frame period. Based on the access control policy of each task to be executed in the current frame period, the synchronization point planning information, and the dependencies between the tasks to be executed, each task to be executed is executed in the current frame period. During the execution of the task, each peripheral is accessed through a unified peripheral access interface, and the access to the same peripheral is serialized at the synchronization point.
[0006] As an optional implementation, before scanning multiple tasks to be executed in the current frame period of the operating system, the process includes: Upon detecting a frame cycle start event, receive multiple tasks to be executed for the current frame cycle submitted by the application layer.
[0007] As an optional implementation, the peripheral access requirements of each task to be executed are determined, including: Read and analyze the peripheral access requirements of each task to be executed, and extract the peripheral access requirement characteristics of each task to be executed.
[0008] As an optional implementation, determining the access control policy for each task to be executed in the current frame period based on the task type and peripheral access requirements of each task to be executed includes: If the task to be executed is a non-core task, then the access control policy for the task to be executed is determined to be the conditional access policy, so that the non-core task is executed within the operating system's idle time window.
[0009] As an optional implementation, determining the access control policy for each task to be executed in the current frame period based on the task type and peripheral access requirements of each task to be executed includes: If the task to be executed is a core task, the peripheral access frequency of the task to be executed is higher than the preset frequency, and the task to be executed and other tasks to be executed need to access the same peripheral, then the access control strategy of the task to be executed is determined to be a time-slice locking strategy, a multi-buffering strategy, and a synchronization point control strategy.
[0010] As an optional implementation, determining the synchronization point planning information for the current frame period based on the task type, peripheral access requirements, and dependencies between the tasks to be executed includes: Based on the task type, peripheral access requirements, and dependencies between the tasks to be executed, the distribution locations of synchronization points are determined, and the distribution locations of the synchronization points and the preset trigger conditions are used as the synchronization point planning information.
[0011] As an optional implementation, determining the distribution location of synchronization points based on the task type, peripheral access requirements, and dependencies between the tasks to be executed includes: Based on the task type, peripheral access requirements, and dependencies between the tasks to be executed, determine the task execution timing constraints for each task to be executed. The distribution locations of the synchronization points are determined based on the task execution timing constraints of each task to be executed.
[0012] As an optional implementation, the step of executing each task to be executed within the current frame period based on the access control policy of each task to be executed in the current frame period, the synchronization point planning information, and the dependencies between the tasks to be executed includes: The task execution path is determined based on the access control policies of each task to be executed in the current frame period and the dependencies between the tasks to be executed. Determine the mapping relationship between the task execution path and the distribution positions in the synchronization point planning information, and generate the control topology structure for the current frame period based on the mapping relationship; According to the control topology of the current frame period and the triggering conditions in the synchronization point planning information, each task to be executed is executed.
[0013] As an optional implementation, the method further includes: Monitor the running status of each task to be executed to obtain task execution monitoring data for the current frame period.
[0014] Secondly, embodiments of this application provide a task scheduling device, the device comprising: The first determining module is used to scan multiple tasks to be executed in the current frame period of the operating system, determine the task type and peripheral access requirement characteristics of each task to be executed, and determine the dependency relationship between the tasks to be executed; the task type includes core tasks and non-core tasks, and the peripheral access requirement characteristics include at least: peripheral access frequency and shared peripheral access identifier, the shared peripheral access identifier is used to characterize whether the task to be executed accesses the same peripheral with other tasks to be executed. The second determining module is used to determine the access control policy of each task to be executed in the current frame period based on the task type and peripheral access requirements of each task to be executed; the access control policy includes at least one of conditional access policy, synchronization point control policy, multi-buffering policy, and time slice locking policy. The third determining module is used to determine the synchronization point planning information of the current frame period based on the task type, peripheral access requirements and dependencies between the tasks to be executed. The synchronization point planning information is used to indicate the timing of the distribution of synchronization points in the current frame period. The execution module is used to execute each task to be executed in the current frame period according to the access control policy of each task to be executed in the current frame period, the synchronization point planning information, and the dependency relationship between the tasks to be executed. During the task execution, each peripheral is accessed through a unified peripheral access interface, and the access to the same peripheral is serialized at the synchronization point.
[0015] As an optional implementation, the device further includes: a receiving module, the receiving module being used for: Upon detecting a frame cycle start event, receive multiple tasks to be executed for the current frame cycle submitted by the application layer.
[0016] As an optional implementation, the first determining module is specifically used for: Read and analyze the peripheral access requirements of each task to be executed, and extract the peripheral access requirement characteristics of each task to be executed.
[0017] As an optional implementation, the second determining module is specifically used for: If the task to be executed is a non-core task, then the access control policy for the task to be executed is determined to be the conditional access policy, so that the non-core task is executed within the operating system's idle time window.
[0018] As an optional implementation, the second determining module is specifically used for: If the task to be executed is a core task, the peripheral access frequency of the task to be executed is higher than the preset frequency, and the task to be executed and other tasks to be executed need to access the same peripheral, then the access control strategy of the task to be executed is determined to be a time-slice locking strategy, a multi-buffering strategy, and a synchronization point control strategy.
[0019] As an optional implementation, the third determining module is specifically used for: Based on the task type, peripheral access requirements, and dependencies between the tasks to be executed, the distribution locations of synchronization points are determined, and the distribution locations of the synchronization points and the preset trigger conditions are used as the synchronization point planning information.
[0020] As an optional implementation, the third determining module is specifically used for: Based on the task type, peripheral access requirements, and dependencies between the tasks to be executed, determine the task execution timing constraints for each task to be executed. The distribution locations of the synchronization points are determined based on the task execution timing constraints of each task to be executed.
[0021] As an optional implementation, the execution module is specifically used for: The task execution path is determined based on the access control policies of each task to be executed in the current frame period and the dependencies between the tasks to be executed. Determine the mapping relationship between the task execution path and the distribution positions in the synchronization point planning information, and generate the control topology structure for the current frame period based on the mapping relationship; According to the control topology of the current frame period and the triggering conditions in the synchronization point planning information, each task to be executed is executed.
[0022] As an optional implementation, the device further includes: a monitoring module, the monitoring module being used for: Monitor the running status of each task to be executed to obtain task execution monitoring data for the current frame period.
[0023] Thirdly, embodiments of this application provide an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of the task scheduling method described in the first aspect above.
[0024] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the task scheduling method described in the first aspect above.
[0025] The beneficial effects of this application are: This application provides a task scheduling method and electronic device. The method scans multiple tasks to be executed in the current frame period of the operating system, determines the task type and peripheral access requirement characteristics of each task, and identifies the dependencies between the tasks. Based on the task type and peripheral access requirement characteristics, it determines the access control policy for each task in the current frame period, including at least one of conditional access policy, synchronization point control policy, multi-buffering policy, and time-slice locking policy. Based on the task type, peripheral access requirement characteristics, and dependencies between the tasks, it determines the synchronization point planning information for the current frame period. Then, based on the access control policy, synchronization point planning information, and dependencies between the tasks, it executes each task within the current frame period. During task execution, peripherals are accessed through a unified peripheral access interface, and access to the same peripheral is serialized at the synchronization point. This enables efficient coordination between task scheduling and peripheral access, ensuring the real-time and periodic nature of core tasks, eliminating timing drift, and improving the scheduling flexibility of non-core tasks, thereby increasing resource utilization. Furthermore, it reduces synchronization overhead through access control policies, ensuring the determinism and security consistency of shared peripherals. Attached Figure Description
[0026] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 Flowchart of the task scheduling method provided in the embodiments of this application Figure 1 ; Figure 2 Flowchart of the task scheduling method provided in the embodiments of this application Figure 2 ; Figure 3 Flowchart of the task scheduling method provided in the embodiments of this application Figure 3 ; Figure 4 A schematic diagram of the control topology for the current frame period provided in an embodiment of this application; Figure 5 A module structure diagram of the task scheduling device provided in the embodiments of this application; Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0028] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0029] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0030] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0031] In multi-core embedded RTOS, multiple processor cores often need to work together to complete tasks with high real-time requirements. These systems typically include peripherals shared by multiple cores, such as communication interfaces, sensors, or storage devices. However, when multiple cores access these shared peripherals simultaneously, resource contention can easily occur, leading to task blocking, timing irregularities, and even data errors. Traditional solutions often optimize task scheduling, data transmission paths, or resource access individually, making it difficult to translate local optimizations into system-level gains. Furthermore, these local optimizations often present irreconcilable contradictions, making it difficult to balance real-time performance, security, and resource utilization.
[0032] Based on the above-mentioned problems, this application provides a task scheduling method to improve the real-time performance, determinism, and resource utilization of task execution, while ensuring the security of peripheral devices.
[0033] Figure 1 Flowchart of the task scheduling method provided in the embodiments of this application Figure 1 The subject executing this method can be any electronic device with computing power. For example... Figure 1 As shown, the method includes: S101. Scan multiple tasks to be executed in the current frame period of the operating system, determine the task type and peripheral access requirements of each task to be executed, and determine the dependencies between the tasks to be executed.
[0034] The task types include core tasks and non-core tasks. The peripheral access requirements include at least the following characteristics: peripheral access frequency and shared peripheral access identifier. The shared peripheral access identifier is used to indicate whether the task to be executed accesses the same peripheral as other tasks to be executed.
[0035] Optionally, a multi-core embedded RTOS is installed on the electronic device. During the task preparation phase, the scheduler in the multi-core embedded RTOS scans all tasks to be executed in the current frame period, distinguishes each task to be executed into core tasks and non-core tasks, and extracts peripheral access requirement characteristics such as the peripheral access frequency of the task to be executed and the shared peripheral access identifier used to characterize whether it needs to access the same peripheral with other tasks to be executed. At the same time, the dependencies between tasks to be executed are identified.
[0036] Among them, core tasks are those with strict timing requirements and must be executed according to fixed time slices, while non-core tasks are those without timing requirements and can be executed at any time.
[0037] By identifying the task type, peripheral access requirements, and dependencies between tasks, a basis is provided for determining the access control strategy and synchronization point planning for the tasks, thus eliminating the blind spots in task scheduling and resource management.
[0038] S102. Determine the access control policy for each task to be executed in the current frame period based on the task type and peripheral access requirements of each task to be executed.
[0039] The access control policies include at least one of the following: conditional access policy, synchronization point control policy, multi-buffering policy, and time-slice locking policy.
[0040] Optionally, during the task preparation phase, the scheduler binds an appropriate access control policy to each task to be executed based on the task type and peripheral access requirements of each task to be executed. The appropriate access control policy for each task to be executed is at least one of conditional access policy, synchronization point control policy, multi-buffering policy, and time slice locking policy.
[0041] Specifically, the conditional access policy restricts non-core tasks to execute only within idle time windows and prohibits write operations or contentious access to peripherals, avoiding resource conflicts with core tasks. The synchronization point control policy forces multiple cores to serialize access to shared peripherals after synchronization point alignment; the time-slice locking policy allocates protected, fixed execution time slices to core tasks. The multi-buffering policy allows each core to process data in parallel within its local cache and commit data uniformly at synchronization points, reducing resource contention and improving the parallel efficiency of the operating system.
[0042] S103. Based on the task type, peripheral access requirements, and dependencies between tasks to be executed, determine the synchronization point planning information for the current frame period.
[0043] Among them, the synchronization point planning information is used to indicate the timing of the distribution of synchronization points in the current frame period.
[0044] Optionally, during the task preparation phase, the scheduler determines the synchronization point planning information for the current frame period based on the task type, peripheral access requirements, and dependencies between the tasks to be executed. This information indicates the timing of the synchronization points on the timeline of the current frame period.
[0045] Since the timing of synchronization points is determined by comprehensively considering the task type of each task to be executed, the characteristics of peripheral access requirements, and the dependencies between tasks to be executed, the synchronization time when multiple cores must complete alignment can be planned based on the time window for each core task to access the same peripheral and the sequential execution constraints between tasks to be executed.
[0046] By pre-setting mandatory alignment nodes (i.e., synchronization points) on the timeline, concurrent access requests to the same peripheral device are rearranged into sequential submissions at the synchronization points, eliminating the conditions for concurrent race conditions and deadlocks from the execution mechanism perspective. Since the synchronization logic is fixed to a specific time point during the task preparation phase, the operating system only needs to perform lightweight peripheral access authorization operations at the synchronization points during the task execution phase, without the need for complex dynamic conflict arbitration. This significantly reduces the synchronization overhead of shared peripheral device access and ensures strict determinism in access timing.
[0047] S104. Based on the access control policy, synchronization point planning information, and dependencies between tasks to be executed in the current frame period, execute each task to be executed within the current frame period.
[0048] During task execution, peripherals are accessed through a unified peripheral access interface, and access to the same peripheral is serialized at the synchronization point.
[0049] Optionally, during the task execution phase, the scheduler controls the start / stop and peripheral access permissions of each task to be executed according to the bound access control policy, and triggers the inter-core alignment and waiting mechanism when the synchronization point is reached. During task execution, all tasks initiate access to peripherals through a unified peripheral access interface, so that the application layer does not need to be aware of the differences in the underlying peripheral access mechanism to complete the access request to the peripheral.
[0050] For the same shared peripheral device, all task access operations are centrally serialized at the planned synchronization point to avoid concurrent conflicts and ensure the determinism and security consistency of peripheral device access.
[0051] In this embodiment, multiple tasks to be executed in the current frame period of the operating system are scanned to determine the task type and peripheral access requirements of each task, and the dependencies between tasks are determined. Based on the task type and peripheral access requirements of each task, an access control policy for each task in the current frame period is determined, including at least one of conditional access policy, synchronization point control policy, multi-buffering policy, and time slice locking policy. Synchronization point planning information for the current frame period is determined based on the task type, peripheral access requirements, and dependencies between tasks. Then, each task is executed within the current frame period according to the access control policy, synchronization point planning information, and dependencies between tasks. During task execution, peripherals are accessed through a unified peripheral access interface, and access to the same peripheral is serialized at the synchronization point. This enables efficient coordination between task scheduling and peripheral access, ensuring the real-time and periodic nature of core tasks, eliminating timing drift, and improving the scheduling flexibility of non-core tasks, thereby increasing resource utilization. Furthermore, it reduces synchronization overhead through access control policies, ensuring the determinism and security consistency of shared peripherals.
[0052] As an optional implementation, before scanning the multiple tasks to be executed in the current frame period of the operating system in step S101 above, the following steps are included: Upon detecting a frame cycle start event, receive multiple tasks to be executed for the current frame cycle submitted by the application layer.
[0053] Optionally, a global timer in the operating system sends a frame cycle start interrupt signal, generating a frame cycle start event to indicate the start of the current frame cycle. When the scheduler detects a frame cycle start event, it receives multiple tasks to be executed in the current frame cycle submitted by the application layer and initializes the scheduling context and execution environment of the current frame cycle.
[0054] In this embodiment, upon detecting a frame cycle start event, multiple tasks to be executed in the current frame cycle submitted by the application layer are received. The frame cycle start event triggers the scheduler to collect these multiple tasks.
[0055] As an optional implementation, the step S101 above, which determines the peripheral access requirement characteristics of each task to be executed, includes: Read and analyze the peripheral access requirements of each task to be executed, and extract the peripheral access requirement characteristics of each task to be executed.
[0056] Optionally, the scheduler reads the peripheral access requirements of each task to be executed, parses the peripheral access requirements of each task to be executed, and extracts features that describe the peripheral access operations of the task to be executed.
[0057] This feature includes at least peripheral access frequency and shared peripheral access identifier, and may also include peripheral type, peripheral access data granularity, etc. Specifically, peripheral access frequency is used to characterize the density of peripheral access by the task to be executed, providing a basis for determining whether to adopt a multi-buffering strategy. Shared peripheral access identifier marks the tasks to be executed that have potential resource contention risks, so that the scheduler can perform synchronization point control and serialized shared peripheral access management for tasks with potential resource contention risks.
[0058] In this embodiment, the peripheral access requirements of each task to be executed are read and analyzed, and the peripheral access requirement characteristics of each task to be executed are extracted. This provides a basis for judgment on the accurate matching of subsequent access control policies with the tasks to be executed.
[0059] As an optional implementation, step S102 above, which determines the access control policy for each task to be executed in the current frame period based on the task type and peripheral access requirement characteristics of each task to be executed, includes: If the task to be executed is a non-core task, then the access control policy for the task to be executed is determined to be a conditional access policy, so that the non-core task can be executed within the operating system's idle time window.
[0060] Optionally, the scheduler sets the access control policy for non-core tasks to a conditional access policy. Under the constraint of the conditional access policy, non-core tasks can only be executed within the idle time window of the operating system allocated to them by the scheduler, thereby improving the utilization of idle time.
[0061] Meanwhile, under the constraints of the conditional access policy, non-core tasks can only access independent or read-only resources during the idle time window, and cannot perform write operations on peripherals or any form of competitive access, thus avoiding resource conflicts and eliminating the need for locking.
[0062] In this embodiment, if the task to be executed is a non-core task, the access control policy for the task is determined to be a conditional access policy, so that the non-core task can be executed within the operating system's idle time window. The conditional access policy avoids resource contention between non-core and core tasks and improves idle time utilization.
[0063] As an optional implementation, step S102 above, which determines the access control policy for each task to be executed in the current frame period based on the task type and peripheral access requirement characteristics of each task to be executed, includes: If the task to be executed is a core task, the peripheral access frequency of the task to be executed is higher than the preset frequency, and the task to be executed and other tasks to be executed need to access the same peripheral, then the access control strategy for the task to be executed is determined to be a time-slice locking strategy, a multi-buffering strategy, and a synchronization point control strategy.
[0064] Optionally, for core tasks whose peripheral access frequency is higher than a preset frequency and which need to access the same peripheral as other pending tasks, the scheduler determines its access control strategy as a time-slice locking strategy, a multi-buffering strategy, and a synchronization point control strategy. These three strategies are uniformly bound to the core task by the scheduler and work together on the core task within the current frame period.
[0065] Specifically, the time-slice locking strategy is used to allocate a protected and fixed-duration execution time slice to the core task. By scheduling the core task through the fixed time slice, other tasks cannot preempt or interrupt the execution of the core task within the fixed time slice, ensuring the periodicity and determinism of the core task, and ensuring that the core task and non-core tasks do not interfere with each other.
[0066] Multi-buffering strategies are used to configure local dual-buffering / multi-buffering for this core task, decoupling core computation from shared peripheral access. This allows each core to process data in parallel within its local buffer, writing data to the peripheral only at synchronization points, reducing resource contention and improving the operating system's parallel efficiency. Specifically, each core performs data computation, update, or write operations in its local buffer without directly accessing the shared peripheral. After processing data in one buffer is complete, a buffer switch is performed, marking the completed buffer as pending commit and enabling another local buffer as the new write area. At a preset time (such as reaching a synchronization point), the completed buffer data from each core is written to the shared peripheral all at once to reduce concurrency conflicts caused by accessing the shared peripheral.
[0067] Synchronization point control policies are used to force the core task to align with other tasks accessing the same peripheral at a synchronization point before it can continue its peripheral access operation. This ensures that peripheral access meets deterministic and secure consistency requirements.
[0068] In this embodiment, if the task to be executed is a core task, the peripheral access frequency of the task to be executed is higher than a preset frequency, and the task to be executed needs to access the same peripheral as other tasks to be executed, then the access control strategy for the task to be executed is determined to be a time-slice locking strategy, a multi-buffering strategy, and a synchronization point control strategy. This ensures the timing determinism of the core task, the security and orderliness of peripheral access, reduces resource contention, and improves the parallel efficiency of the operating system.
[0069] As an optional implementation, step S103 above, which determines the synchronization point planning information for the current frame period based on the task type, peripheral access requirements, and dependencies between the tasks to be executed, includes: Based on the task type, peripheral access requirements, and dependencies between tasks to be executed, the distribution locations of synchronization points are determined, and the distribution locations of synchronization points and preset trigger conditions are used as synchronization point planning information.
[0070] Optionally, the scheduler determines the distribution of synchronization points on the timeline of the current frame period based on the task type, peripheral access requirements, dependencies between tasks, and task execution monitoring data from the previous frame period. The scheduler then uses the distribution of synchronization points on the timeline of the current frame period and pre-set trigger conditions as synchronization point planning information.
[0071] The task execution monitoring data from the previous frame period is used to provide historical reference data for the scheduler to plan synchronization points. The preset trigger condition can be that all participating cores reach the synchronization point.
[0072] In this embodiment, the distribution locations of synchronization points are determined based on the task type, peripheral access requirements, and dependencies between the tasks to be executed. These synchronization points, along with preset triggering conditions, are used as synchronization point planning information. This improves the accuracy of multi-core synchronization control.
[0073] Figure 2 Flowchart of the task scheduling method provided in the embodiments of this application Figure 2 ,like Figure 2 As shown, the above steps determine the distribution location of synchronization points based on the task type, peripheral access requirements, and dependencies between the tasks to be executed, including: S201. Determine the task execution timing constraints for each task based on its task type, peripheral access requirements, and dependencies.
[0074] Optionally, the scheduler determines the task execution timing constraints of each task based on its task type, peripheral access requirements, and dependencies between tasks.
[0075] Specifically, task execution timing constraints based on task type include core tasks executing in fixed time slices and non-core tasks executing within idle time windows between core task executions. Task execution timing constraints based on peripheral access requirements include constraining tasks carrying shared peripheral access identifiers to initiate peripheral access operations only after reaching a synchronization point. Task execution timing constraints based on dependencies between tasks include constraining the start time of later tasks to be later than the end time of earlier tasks among tasks with sequential dependencies.
[0076] S202. Determine the distribution location of synchronization points based on the task execution timing constraints of each task to be executed.
[0077] Optionally, the scheduler performs spatiotemporal overlay analysis on the task execution timing constraints of each task to be executed, identifies the time nodes when each core needs to be aligned with other cores on the task execution path, and uses these time nodes as the initial distribution positions of the synchronization points.
[0078] The scheduler fine-tunes the initial distribution of synchronization points based on the task execution monitoring data from the previous frame period, thus obtaining the distribution of synchronization points. The task execution monitoring data from the previous frame period can include the waiting time for each core to reach the synchronization point and the peripheral access latency of each task in the previous frame period.
[0079] In this embodiment, the execution timing constraints of each task to be executed are determined based on its task type, peripheral access requirements, and dependencies between the tasks. Then, the distribution locations of synchronization points are determined according to these constraints. This improves the accuracy and adaptability of synchronization point planning.
[0080] Figure 3 Flowchart of the task scheduling method provided in the embodiments of this application Figure 3 ,like Figure 3 As shown, step S104 above executes each task to be executed within the current frame period based on the access control policy, synchronization point planning information, and dependencies between the tasks to be executed, including: S301. Determine the task execution path based on the access control policies of each task to be executed in the current frame period and the dependencies between the tasks to be executed.
[0081] Optionally, the scheduler determines the task execution path for the current frame period based on the access control policies of each task to be executed in the current frame period and the dependencies between the tasks to be executed.
[0082] The task execution path of the current frame period includes stage markers and timing labels. The stages of the current frame period include the task preparation stage, the task execution stage, and the frame period end stage.
[0083] S302. Determine the mapping relationship between the task execution path and the distribution location in the synchronization point planning information, and generate the control topology structure for the current frame period based on the mapping relationship.
[0084] Optionally, the scheduler performs spatiotemporal matching between the task execution path and the distribution locations in the synchronization point planning information to establish a mapping relationship between the task execution path and the distribution locations in the synchronization point planning information. The task execution path, synchronization point planning information, and mapping relationship of the current frame period are integrated into the control topology structure of the current frame period.
[0085] Figure 4 This is a schematic diagram of the control topology structure for the current frame period provided in the embodiments of this application, as shown below. Figure 4 As shown, the current frame period is 50ms. At 0ms, the global timer sends a frame period start interrupt signal, indicating the start of the current frame period. During the task preparation phase (0ms-5ms), the scheduler performs task scanning and identification, policy selection, and synchronization point planning. The synchronization point is located at 40ms. During the 5ms-30ms period, the core task is in normal execution. When execution reaches 30ms, the core task needs to access shared peripherals, but because the synchronization point has not yet been reached, it does not have access to the shared peripherals. At this time, the scheduler, based on the conditional access policy, allows non-core tasks to enter the execution window under controlled conditions, filling the execution gaps of the core tasks and improving resource utilization.
[0086] At 40ms, the synchronization point is reached, and the core task gains access to the shared peripherals, allowing it to continue execution. During the 40ms-48ms period, core task execution continues. From 48ms to 50ms, the frame cycle ends; the operating system saves the task context for the current frame cycle, the scheduler clears temporary data for the current frame cycle, and waits for the interrupt signal to start the next frame cycle.
[0087] S303. Execute each task to be executed according to the control topology structure of the current frame period and the triggering conditions in the synchronization point planning information.
[0088] Optionally, during the task execution phase, the scheduler executes each task to be executed in the current frame period according to the control topology of the current frame period, and serializes access to shared peripherals when the triggering conditions in the synchronization point planning information are met.
[0089] It is worth noting that after entering the next frame cycle, if the tasks in the current frame cycle have not yet been completed, the operating system can continue to execute the remaining tasks of the current frame cycle based on the task context of the current frame cycle under the controlled scheduling mechanism. By executing the residual tasks across cycles, the continuity of tasks and data consistency are guaranteed.
[0090] In this embodiment, based on the access control policies of each task to be executed in the current frame period and the dependencies between the tasks, the task execution path is determined, and the mapping relationship between the task execution path and the distribution positions in the synchronization point planning information is determined. The control topology structure for the current frame period is generated based on the mapping relationship, and each task to be executed is executed according to the control topology structure and the triggering conditions in the synchronization point planning information. This achieves efficient coordination between task scheduling and peripheral access.
[0091] As an optional implementation, the method further includes: Monitor the running status of each task to be executed to obtain task execution monitoring data for the current frame period.
[0092] Optionally, during the task execution phase of the current frame period, the scheduler continuously monitors the running status of each task to be executed, the access latency of shared peripherals, conflicts, and congestion, and obtains task execution monitoring data for the current frame period.
[0093] The task execution monitoring data for the current frame period includes the execution progress of each task to be executed, time slice consumption, multi-core synchronization point wait time, and shared peripheral access latency. This data can serve as a historical reference for synchronization point planning, time slice allocation, and access control policy adjustments in subsequent frame periods.
[0094] In this embodiment, the running status of each task to be executed is monitored to obtain task execution monitoring data for the current frame period. The task execution monitoring data for the current frame period provides historical reference for synchronization point planning, time slice allocation, and access control policy adjustment in subsequent frame periods.
[0095] Based on the same inventive concept, this application also provides a task scheduling device corresponding to the task scheduling method. Since the principle of the device in this application is similar to the task scheduling method described above in this application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0096] Figure 5 A module structure diagram of the task scheduling device provided in the embodiments of this application is shown below. Figure 5 As shown, the device includes: The first determining module 501 is used to scan multiple tasks to be executed in the current frame period of the operating system, determine the task type and peripheral access requirement characteristics of each task to be executed, and determine the dependency relationship between the tasks to be executed; the task type includes core tasks and non-core tasks, and the peripheral access requirement characteristics include at least: peripheral access frequency and shared peripheral access identifier, the shared peripheral access identifier is used to characterize whether the task to be executed accesses the same peripheral with other tasks to be executed. The second determining module 502 is used to determine the access control policy of each task to be executed in the current frame period based on the task type and peripheral access requirements of each task to be executed; the access control policy includes at least one of conditional access policy, synchronization point control policy, multi-buffering policy, and time slice locking policy. The third determining module 503 is used to determine the synchronization point planning information of the current frame period based on the task type, peripheral access requirements and dependencies between the tasks to be executed. The synchronization point planning information is used to indicate the timing of the distribution of synchronization points in the current frame period. The execution module 504 is used to execute each task to be executed within the current frame period according to the access control policy, synchronization point planning information and the dependency relationship between the tasks to be executed. During the execution of the task, each peripheral device is accessed through a unified peripheral device access interface, and the access to the same peripheral device is serialized at the synchronization point.
[0097] As an optional implementation, the device further includes a receiving module 505, which is used for: Upon detecting a frame cycle start event, receive multiple tasks to be executed for the current frame cycle submitted by the application layer.
[0098] As an optional implementation, the first determining module 501 is specifically used for: Read and analyze the peripheral access requirements of each task to be executed, and extract the peripheral access requirement characteristics of each task to be executed.
[0099] As an optional implementation, the second determining module 502 is specifically used for: If the task to be executed is a non-core task, then the access control policy for the task to be executed is determined to be a conditional access policy, so that the non-core task can be executed within the operating system's idle time window.
[0100] As an optional implementation, the second determining module 502 is specifically used for: If the task to be executed is a core task, the peripheral access frequency of the task to be executed is higher than the preset frequency, and the task to be executed and other tasks to be executed need to access the same peripheral, then the access control strategy for the task to be executed is determined to be a time-slice locking strategy, a multi-buffering strategy, and a synchronization point control strategy.
[0101] As an optional implementation, the third determining module 503 is specifically used for: Based on the task type, peripheral access requirements, and dependencies between tasks to be executed, the distribution locations of synchronization points are determined, and the distribution locations of synchronization points and preset trigger conditions are used as synchronization point planning information.
[0102] As an optional implementation, the third determining module 503 is specifically used for: Based on the task type, peripheral access requirements, and dependencies between the tasks to be executed, determine the task execution timing constraints for each task to be executed. The distribution locations of synchronization points are determined based on the task execution timing constraints of each task to be executed.
[0103] As an optional implementation, execution module 504 is specifically used for: The task execution path is determined based on the access control policies of each task to be executed in the current frame period and the dependencies between the tasks to be executed. Determine the mapping relationship between the task execution path and the distribution location in the synchronization point planning information, and generate the control topology structure for the current frame period based on the mapping relationship; Execute each task to be executed according to the control topology structure of the current frame period and the triggering conditions in the synchronization point planning information.
[0104] As an optional implementation, the device further includes a monitoring module 506, which is used for: Monitor the running status of each task to be executed to obtain task execution monitoring data for the current frame period.
[0105] This application also provides an electronic device, such as... Figure 6 The diagram shown is a structural schematic of an electronic device provided in an embodiment of this application, including a processor 61, a memory 62, and a bus 63. The memory 62 stores machine-readable instructions executable by the processor 61. When the electronic device is running, the processor 61 communicates with the memory 62 via the bus 63, and the processor 61 executes the machine-readable instructions to perform the steps of the task scheduling method in the aforementioned embodiment.
[0106] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the task scheduling method described in the foregoing embodiments.
[0107] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces; the indirect coupling or communication connection of devices or modules can be electrical, mechanical, or other forms.
[0108] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.
[0109] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A task scheduling method, characterized in that, include: Scan multiple tasks to be executed in the current frame cycle of the operating system, determine the task type and peripheral access requirements of each task to be executed, and determine the dependencies between the tasks to be executed. The task types include core tasks and non-core tasks, and the peripheral access requirement characteristics include at least: peripheral access frequency and shared peripheral access identifier. The shared peripheral access identifier is used to characterize whether the task to be executed accesses the same peripheral as other tasks to be executed. Based on the task type and peripheral access requirements of each task to be executed, the access control policy for each task to be executed in the current frame period is determined; the access control policy includes at least one of conditional access policy, synchronization point control policy, multi-buffering policy, and time slice locking policy. Based on the task type, peripheral access requirements, and dependencies between the tasks to be executed, the synchronization point planning information for the current frame period is determined. The synchronization point planning information is used to indicate the timing of the distribution of synchronization points in the current frame period. Based on the access control policy of each task to be executed in the current frame period, the synchronization point planning information, and the dependencies between the tasks to be executed, each task to be executed is executed in the current frame period. During the execution of the task, each peripheral is accessed through a unified peripheral access interface, and the access to the same peripheral is serialized at the synchronization point.
2. The method according to claim 1, characterized in that, Before scanning multiple tasks to be executed in the current frame period of the operating system, the process includes: Upon detecting a frame cycle start event, receive multiple tasks to be executed for the current frame cycle submitted by the application layer.
3. The method according to claim 1, characterized in that, Determine the peripheral access requirements of each task to be executed, including: Read and analyze the peripheral access requirements of each task to be executed, and extract the peripheral access requirement characteristics of each task to be executed.
4. The method according to claim 1, characterized in that, The step of determining the access control policy for each task to be executed in the current frame period based on the task type and peripheral access requirements of each task to be executed includes: If the task to be executed is a non-core task, then the access control policy for the task to be executed is determined to be the conditional access policy, so that the non-core task is executed within the operating system's idle time window.
5. The method according to claim 1, characterized in that, The step of determining the access control policy for each task to be executed in the current frame period based on the task type and peripheral access requirements of each task to be executed includes: If the task to be executed is a core task, the peripheral access frequency of the task to be executed is higher than the preset frequency, and the task to be executed and other tasks to be executed need to access the same peripheral, then the access control strategy of the task to be executed is determined to be a time-slice locking strategy, a multi-buffering strategy, and a synchronization point control strategy.
6. The method according to claim 1, characterized in that, The step of determining the synchronization point planning information for the current frame period based on the task type, peripheral access requirements, and dependencies between the tasks to be executed includes: Based on the task type, peripheral access requirements, and dependencies between the tasks to be executed, the distribution locations of synchronization points are determined, and the distribution locations of the synchronization points and the preset trigger conditions are used as the synchronization point planning information.
7. The method according to claim 6, characterized in that, The process of determining the distribution location of synchronization points based on the task type, peripheral access requirements, and dependencies between tasks to be executed includes: Based on the task type, peripheral access requirements, and dependencies between the tasks to be executed, determine the task execution timing constraints for each task to be executed. The distribution locations of the synchronization points are determined based on the task execution timing constraints of each task to be executed.
8. The method according to claim 1, characterized in that, The step of executing each task to be executed within the current frame period based on the access control policy of each task to be executed in the current frame period, the synchronization point planning information, and the dependencies between the tasks to be executed includes: The task execution path is determined based on the access control policies of each task to be executed in the current frame period and the dependencies between the tasks to be executed. Determine the mapping relationship between the task execution path and the distribution positions in the synchronization point planning information, and generate the control topology structure for the current frame period based on the mapping relationship; Execute each task to be executed according to the control topology structure of the current frame period and the triggering conditions in the synchronization point planning information.
9. The method according to claim 1, characterized in that, The method further includes: Monitor the running status of each task to be executed to obtain task execution monitoring data for the current frame period.
10. An electronic device, characterized in that, include: The electronic device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of the task scheduling method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Time determinacy method for multi-core real-time system
CN110162399A
Systems, methods, and apparatuses for heterogeneous computing
IN202048051332A