Task scheduling method and device and motor controller
By using message queues for task scheduling in the motor controller, the problem of low kernel resource utilization is solved, more efficient resource utilization and lower resource utilization are achieved, and the performance of the motor controller is enhanced.
Patent Information
- Application Number
- CN202510136305.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-07
- Publication Date
- 2025-06-10
AI Technical Summary
The core resource utilization rate of the motor controller is low, resulting in unreasonable resource allocation and excessive loading of some cores.
The message queue is used for task scheduling. By configuring the main core in the motor controller to receive tasks, store them in the message queue, parsing and sending the parsing results, the redundant calculation process of the real-time operating system is avoided.
It improves the core resource utilization rate of the motor controller, saves resource usage, maximizes the use of core resources, and enhances the capabilities of the motor controller.
Smart Images

Figure CN120123055A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of vehicles, and particularly relates to a task scheduling method, apparatus, and motor controller. Background Art
[0002] The motor controller is an important part of the electrical system of new energy vehicles. Since multi-core controllers can process tasks in parallel and have higher computing power, multi-core controllers are mostly used in the motor controllers of vehicles. The multiple cores in the multi-core controller are interconnected through various high-speed buses and can share on-chip resources. For motor control with high performance and high control requirements in complex scenarios (such as the main drive motor control scenario), by designing a reasonable program architecture and resource allocation strategy, all computing power resources and hardware resources can be effectively utilized to ensure the real-time performance and accuracy of control tasks.
[0003] In order to be able to use all the resources of the multi-core controller, a real-time operating system is introduced in the related art, and task scheduling is performed on the multi-core controller by means of preemptive priority, time slice round-robin, etc. However, the operating system itself consumes processor computing resources, and if the resource allocation is unreasonable, there will be a problem that the load rate of some cores is too high, and the utilization rate of the core resources of the motor controller is low. Summary of the Invention
[0004] The embodiments of the present application provide a task scheduling method, apparatus, and motor controller, which can solve the problem of low utilization rate of core resources of the motor controller.
[0005] In a first aspect, the embodiments of the present application provide a task scheduling method, which is applied to a first core. The first core is the core configured as the main core in a motor controller with multiple cores in a vehicle, and a message queue for storing tasks is configured in the first core; the task scheduling method includes:
[0006] Receiving a first task sent by a task sender, where the task sender includes a second core other than the first core among the multiple cores or a vehicle electronic control unit;
[0007] Storing the first task in the message queue;
[0008] Parsing the first task in the message queue to obtain a parsing result corresponding to the first task;
[0009] Sending the parsing result to the corresponding task receiver.
[0010] In a second aspect, the embodiments of the present application provide a task scheduling apparatus, which is applied to a first core. The first core is the core configured as the main core in a motor controller with multiple cores in a vehicle, and a message queue for storing tasks is configured in the first core; the task scheduling apparatus includes:
[0011] A receiving module, configured to receive a first task sent by a task sender, where the task sender includes a second core other than the first core among multiple cores or a vehicle electronic control unit;
[0012] A storage module, configured to store the first task in a message queue;
[0013] An analysis module, configured to analyze the first task in the message queue to obtain an analysis result corresponding to the first task;
[0014] A sending module, configured to send the analysis result to a corresponding task receiver.
[0015] In a third aspect, an embodiment of the present application provides a motor controller, where the motor controller includes: a processor and a memory storing computer program instructions; the processor has multiple cores; when a first core configured as a main core in the motor controller executes the computer program instructions, the steps of the task scheduling method provided by the embodiment of the present application are implemented.
[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the steps of the task scheduling method provided by the embodiment of the present application are implemented.
[0017] In a fifth aspect, an embodiment of the present application provides a computer program product, where the computer program product includes computer program instructions, and when the computer program instructions are executed by a processor, the steps of the task scheduling method provided by the embodiment of the present application are implemented.
[0018] In a sixth aspect, an embodiment of the present application provides a vehicle, including the motor controller provided by the embodiment of the present application.
[0019] In the embodiment of the present application, the first core configured as the main core in the motor controller of the vehicle receives the first task sent by the task sender, stores the first task in a message queue pre-configured in the first core for storing tasks; analyzes the first task in the message queue to obtain an analysis result corresponding to the first task; and sends the analysis result to a corresponding task receiver. In this way, by configuring the main core in the motor controller and using messages for task scheduling, compared with using a real-time operating system for task scheduling, a large amount of redundant calculation processes can be saved, the resource occupancy during task scheduling is less, the kernel resources of the motor controller can be utilized to the maximum extent, the utilization rate of the kernel resources of the motor controller is improved, and the ability of the motor controller can be exerted to a greater extent. Description of the Drawings
[0020] To more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the accompanying drawings required for the embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0021] Figure 1 is a schematic flowchart of the task scheduling method provided by the embodiments of the present application;
[0022] Figure 2 is a structural diagram of the message queue provided by the embodiments of the present application;
[0023] Figure 3 is a schematic diagram of the process of scheduling tasks provided by the embodiments of the present application;
[0024] Figure 4 is a schematic structural diagram of the task scheduling device provided by the embodiments of the present application;
[0025] Figure 5 is a schematic structural diagram of the motor controller provided by the embodiments of the present application. Detailed Embodiments
[0026] The following will describe in detail the features and exemplary embodiments of various aspects of the present application. To make the purpose, technical solutions and advantages of the present application clearer, the following further describes the present application in detail with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than limiting the present application. For those skilled in the art, the present application can be implemented without some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by showing examples of the present application.
[0027] It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover a non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, the elements defined by the statement "including..." do not exclude the existence of additional identical elements in the process, method, article or device including the said elements.
[0028] The following describes in detail the task scheduling method, device and motor controller provided by the embodiments of the present application with reference to the accompanying drawings, specific embodiments and their application scenarios.
[0029] The task scheduling method and device provided by the embodiments of the present application can be applied to a first core, where the first core is the core configured as the main core in a motor controller with multiple cores in a vehicle, and a message queue for storing tasks is configured in the first core.
[0030] Figure 1 It is a schematic flowchart of the task scheduling method provided by the embodiments of the present application. As Figure 1 shown, the task scheduling method may include:
[0031] Step 101: Receive a first task sent by a task sender, where the task sender includes a second core other than the first core among multiple cores or a vehicle electronic control unit;
[0032] In some possible implementations of the embodiments of the present application, the first core may receive tasks from a vehicle electronic control unit and may also receive tasks from a second core other than the first core among multiple cores. The vehicle electronic control unit includes, but is not limited to, an electronic control unit (ECU) and a vehicle control unit (VCU).
[0033] In some possible implementations of the embodiments of the present application, the second core in the embodiments of the present application can only communicate with the first core and cannot communicate with the vehicle electronic control unit, and the second cores cannot communicate with each other either.
[0034] Step 102: Store the first task in the message queue;
[0035] In some possible implementations of the embodiments of the present application, each time a task is received, the task can be stored in a message queue pre-configured in the first core for storing tasks;
[0036] In some possible implementations of the embodiments of the present application, tasks from different sources can be stored in different message queues. Based on this, the message queue in the embodiments of the present application may include a first message queue and a second message queue, where the first message queue is for tasks sent by the second core, and the second message queue is for tasks sent by the vehicle electronic control unit. Among them, the first message queue can be called a transmit buffer, and the second message queue can be called a receive buffer.
[0037] When the task sender includes the second core and the task receiver includes the vehicle electronic control unit, step 102 may include: storing the first task in the first message queue.
[0038] When the first core receives a task that needs to be executed by the vehicle electronic control unit sent by the second core, it stores the task in the message sending queue.
[0039] When the task sender includes the vehicle electronic control unit and the task receiver includes the second core, step 102 may include: storing the first task in the second message queue.
[0040] When the first core receives a task that needs to be executed by the second core sent by the vehicle electronic control unit, it stores the task in the message receiving queue.
[0041] In some possible implementations of the embodiments of the present application, the length of the message queue, that is, the number of stored tasks, can be configured.
[0042] In some possible implementations of the embodiments of the present application, the message queue may include multiple data blocks; before step 102, the task scheduling method provided by the embodiments of the present application may further include: calling the task receiving interrupt service to find the first data block that is currently unused and does not store data among the multiple data blocks included in the message queue; correspondingly, step 102 may include: storing the first task in the first data block.
[0043] In some possible implementations of the embodiments of the present application, the message queue can be divided into multiple data blocks (BLOCKs), each BLOCK includes two parts: BLOCK status and BLOCK data. The BLOCK status is used to store the status of the BLOCK. The BLOCK status includes the idle (Idle) state, the busy (Busy) state, and the in-use (Using) state; when the BLOCK status of a certain BLOCK is the Idle state, it means that the BLOCK is not used; when the BLOCK status of a certain BLOCK is the Busy state, it means that the BLOCK is only allowed to be read and written by the task receiving interrupt service, and is prohibited from being read and written by other services except the task receiving interrupt service; when the BLOCK status of a certain BLOCK is the Using state, it means that writing data to the BLOCK is prohibited. The BLOCK data is used to store the task identifier (ID) and the task data.
[0044] Suppose the message queue includes n data blocks, and the structure of the message queue is as Figure 2 shown, Figure 2 which is the structure diagram of the message queue provided by the embodiments of the present application.
[0045] In some possible implementations of the embodiments of the present application, when a task is received, a task interrupt is triggered, the task receiving interrupt service is called, a data block with the status of Idle and no stored data is found among the multiple BLOCKs included in the message queue, and the received task is stored in the found data block.
[0046] In some possible implementations of the embodiments of the present application, before step 102, the task scheduling method provided by the embodiments of the present application may further include: modifying the status of the first data block to a busy status, where the busy status is used to prohibit other services except the task receiving interrupt service from reading and writing the first data block.
[0047] In some possible implementations of the embodiments of the present application, the status of the first data block may be configured to the Busy status. When the status of the first data block is the Busy status, the first data block is only allowed to be read and written by the task receiving interrupt service, and other services except the task receiving interrupt service are prohibited from reading and writing it.
[0048] In the embodiments of the present application, by prohibiting other services except the task receiving interrupt service from reading and writing the first data block, it is possible to avoid other services except the task receiving interrupt service from writing data to the first data block, affecting the accuracy of the task data.
[0049] In some possible implementations of the embodiments of the present application, after step 102, the task scheduling method provided by the embodiments of the present application may further include: modifying the status of the first data block to an in-use status, where the in-use status is used to prohibit writing data to the first data block.
[0050] In some possible implementations of the embodiments of the present application, the status of the first data block may be configured to the Using status. When the status of the first data block is the Using status, writing data to the first data block is prohibited.
[0051] Step 103: Parse the first task in the message queue to obtain the parsing result corresponding to the first task;
[0052] The embodiments of the present application do not limit the manner of parsing tasks in the message queue, and any available manner can be applied to the embodiments of the present application.
[0053] In some possible implementations of the embodiments of the present application, when parsing the tasks in the message queue, the tasks in the message queue may be parsed according to the principle of first in first out of the queue.
[0054] In some possible implementations of the embodiments of the present application, the parsing results in the embodiments of the present application include but are not limited to: the task sender, the task receiver, the task corresponding execution instruction, and the task parameters required when the task is executed, etc.
[0055] Step 104: Send the parsing result to the corresponding task receiver.
[0056] After the first core parses the tasks in the message queue according to the first-in, first-out principle, the parsing results of each task in the message queue can be obtained. After parsing each task and obtaining a parsing result, the parsing result is sent to the corresponding task receiver. After receiving the parsing result sent by the first core, the task receiver executes the corresponding task.
[0057] In the embodiment of the present application, the first core configured as the main core in the motor controller with multiple cores in the vehicle receives the first task sent by the task sender, stores the first task in the message queue pre-configured in the first core for storing tasks; parses the first task in the message queue to obtain the parsing result corresponding to the first task; and sends the parsing result to the corresponding task receiver. In this way, by configuring the main core in the motor controller and using messages for task scheduling, compared with using a real-time operating system for task scheduling, a large amount of redundant calculation processes can be saved, the resource occupancy during task scheduling is less, the core resources of the motor controller can be utilized to the maximum extent, the core resource utilization rate of the motor controller is improved, and the ability of the motor controller can be exerted more.
[0058] In some possible implementations of the embodiment of the present application, after step 104, the task scheduling method provided by the embodiment of the present application may further include: modifying the state of the first data block to the idle state and clearing the data in the first data block.
[0059] In some possible implementations of the embodiment of the present application, when the first core finishes parsing the first data block and sends the obtained parsing result to the corresponding task receiver, the state of the first data block can be configured to the Idle state to allow rewriting data into the data block.
[0060] In the embodiment of the present application, by clearing the data in the first data block, the occupancy of resources can be saved.
[0061] Exemplarily, the motor controller has three cores, namely CPU0, CPU1, and CPU2. Among them, CPU0 is configured as the main core, which is mainly responsible for receiving and processing Controller Area Network (CAN) messages for tasks sent by the vehicle electronic control unit to cores other than the main core among the three cores, and performing task distribution and scheduling according to instructions; CPU0 is mainly responsible for state monitoring related functions, that is, analog-to-digital converter (ADC) signal acquisition at each sampling monitoring point, digital signal acquisition at each fault detection point, excitation signal output of the resolver, software watchdog monitoring, and feeding the external watchdog, etc.; CPU2 is mainly responsible for the motor control part, as well as the output signal and resolution of the resolver. CPU1 communicates with CPU0, CPU2 communicates with CPU0, and there is no communication between CPU1 and CPU2. The behaviors of CPU1 and CPU2 are all scheduled and controlled by CPU0.
[0062] Receive Buffer and Transmit Buffer are configured in CPU0, and both Receive Buffer and Transmit Buffer are divided into n BLOCKs.
[0063] When CPU0 receives a CAN message carrying a task indicating that CPU1 reports a fault from the vehicle electronic control unit, it searches for a BLOCK with an Idle status and no stored data among the n BLOCKs in the Receive Buffer, configures the status of this BLOCK to the Busy status, stores the task indicating that CPU1 reports a fault in the found BLOCK, and after storing the task indicating that CPU1 reports a fault in the found BLOCK, configures the status of this BLOCK to the Using status; when CPU0 receives a CAN message carrying a task indicating controlling the motor to run at a certain speed from the vehicle electronic control unit, it searches for a BLOCK with an Idle status among the n BLOCKs in the Receive Buffer, configures the status of this BLOCK to the Busy status, stores the task indicating controlling the motor to run at a certain speed in the found BLOCK, and after storing the task indicating controlling the motor to run at a certain speed in the found BLOCK, configures the status of this BLOCK to the Using status.
[0064] CPU0 parses and processes the data in the BLOCKs in the Using state in the Receive Buffer in the order of first in, first out of the queue. First, CPU0 parses the task that instructs CPU1 to report a fault, and sends the instruction corresponding to the parsing result to CPU1. The module related to fault recording in CPU1 (for example, the diagnostic service) makes corresponding processing actions, and then reports the fault information of the motor controller. After CPU0 finishes processing the task that instructs CPU1 to report a fault, it configures the status of the BLOCK storing the task that instructs CPU1 to report a fault to the Idle state and releases the resources, that is, clears the data in the BLOCK. Then, CPU0 parses the task that instructs to control the motor to run at a certain speed, and sends the instruction corresponding to the parsing result to CPU2. CPU2 reads the physical quantities related to motor control, and calls the motor control algorithm to output signals such as Pulse-Width Modulation (PWM) to the motor drive part to control the motor. After CPU0 finishes processing the task that instructs to control the motor to run at a certain speed, it configures the status of the BLOCK storing the task that instructs to control the motor to run at a certain speed to the Idle state and releases the resources.
[0065] When CPU1 or CPU2 needs to send data to the vehicle electronic control unit, it first searches for BLOCKs with the status of Idle in n BLOCKs in the Transmit Buffer, configures the status of the found BLOCK to the Busy state, stores the data that needs to be sent to the vehicle electronic control unit in the found BLOCK. After storing the data that needs to be sent to the vehicle electronic control unit in the found BLOCK, it configures the status of the BLOCK to the Using state; after CPU0 finishes sending the data in the BLOCK to the vehicle electronic control unit, it configures the status of the BLOCK to the Idle state and releases the resources.
[0066] Exemplarily, when the CPU2 needs to send the torque value currently output by the motor to the vehicle electronic control unit, the CPU0 searches for a BLOCK with the status of Idle in n BLOCKs of the Transmit Buffer, configures the status of this BLOCK to the Busy status, stores the task of sending the torque value currently output by the motor to the vehicle electronic control unit in the found BLOCK, and after the task of sending the torque value currently output by the motor to the vehicle electronic control unit is stored in the found BLOCK, configures the status of this BLOCK to the Using status. The CPU0 parses and processes the data in the BLOCKs with the Using status in the Transmit Buffer in the order of first in first out of the queue. After the CPU0 finishes sending the torque value currently output by the motor in this BLOCK to the vehicle electronic control unit, it configures the status of this BLOCK to the Idle status and releases the resources.
[0067] The process of the above scheduling task is as Figure 3 shown Figure 3 and is a schematic diagram of the process of the scheduling task provided by the embodiment of the present application.
[0068] Corresponding to the above task scheduling method, the embodiment of the present application further provides a task scheduling device. The task scheduling device is applied to the first kernel, and the first kernel is the kernel configured as the main kernel in the motor controller with multiple kernels in the vehicle. A message queue for storing tasks is configured in the first kernel. As Figure 4 shown. Figure 4 is a schematic structural diagram of the task scheduling device provided by the embodiment of the present application. The task scheduling device 400 may include:
[0069] A receiving module 401, configured to receive a first task sent by a task sender, where the task sender includes a second kernel other than the first kernel among multiple kernels or a vehicle electronic control unit;
[0070] A storage module 402, configured to store the first task in the message queue;
[0071] An analysis module 403, configured to analyze the first task in the message queue to obtain an analysis result corresponding to the first task;
[0072] A sending module 404, configured to send the analysis result to a corresponding task receiver.
[0073] In an embodiment of the present application, in a motor controller of a vehicle having multiple cores, a first core configured as a main core receives a first task sent by a task sender, stores the first task in a message queue pre-configured in the first core for storing tasks; parses the first task in the message queue to obtain a parsing result corresponding to the first task; and sends the parsing result to a corresponding task receiver. In this way, by configuring the main core in the motor controller and using messages for task scheduling, compared with using a real-time operating system for task scheduling, a large amount of redundant calculation processes can be saved, the resource occupancy during task scheduling is less, the core resources of the motor controller can be utilized to the maximum extent, the core resource utilization rate of the motor controller is improved, and the ability of the motor controller can be exerted to a greater extent.
[0074] In some possible implementations of the embodiment of the present application, the task scheduling device 400 provided in the embodiment of the present application may further include:
[0075] A search module, configured to call a task receiving interrupt service to search for a first data block that is currently unused and stores no data among a plurality of data blocks included in the message queue;
[0076] Correspondingly, the storage module 402 may specifically be configured to:
[0077] Store the first task in the first data block.
[0078] In some possible implementations of the embodiment of the present application, the task scheduling device 400 provided in the embodiment of the present application may further include:
[0079] A first prohibition module, configured to modify the state of the first data block to a busy state before storing the first task in the first data block, where the busy state is used to prohibit other services except the task receiving interrupt service from reading and writing the first data block.
[0080] In the embodiment of the present application, by prohibiting other services except the task receiving interrupt service from reading and writing the first data block, it is possible to prevent other services except the task receiving interrupt service from writing data to the first data block and affecting the accuracy of task data.
[0081] In some possible implementations of the embodiment of the present application, the task scheduling device 400 provided in the embodiment of the present application may further include:
[0082] A second prohibition module, configured to modify the state of the first data block to an in-use state after storing the first task in the first data block, where the in-use state is used to prohibit writing data to the first data block.
[0083] In some possible implementations of the embodiment of the present application, the task scheduling device 400 provided in the embodiment of the present application may further include:
[0084] A clearing module, configured to change the state of the first data block to an idle state and clear the data in the first data block after sending the parsing result to the corresponding task receiver.
[0085] In the embodiments of the present application, by clearing the data in the first data block, resource occupation can be saved.
[0086] In some possible implementations of the embodiments of the present application, the message queue includes a first message queue and a second message queue. The first message queue is used to store tasks sent by the second kernel, and the second message queue is used to store tasks sent by the vehicle electronic control unit.
[0087] In some possible implementations of the embodiments of the present application, the task sender includes the second kernel, and the task receiver includes the vehicle electronic control unit;
[0088] Correspondingly, the storage module 402 is specifically configured to:
[0089] Store the first task in the first message queue.
[0090] In some possible implementations of the embodiments of the present application, the task sender includes the vehicle electronic control unit, and the task receiver includes the second kernel;
[0091] Correspondingly, the storage module 402 is specifically configured to:
[0092] Store the first task in the second message queue.
[0093] Figure 5 It is a schematic structural diagram of a motor controller provided by the embodiments of the present application.
[0094] The motor controller may include a processor 501 and a memory 502 storing computer program instructions. The processor 501 has multiple cores.
[0095] Specifically, the above-mentioned processor 501 may include a Central Processing Unit (CPU), or an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.
[0096] The memory 502 may include a mass storage for data or instructions. By way of example and not limitation, the memory 502 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 502 may include removable or non-removable (or fixed) media. Where appropriate, the memory 502 may be internal or external to the motor controller. In some particular embodiments, the memory 502 is a non-volatile solid-state memory.
[0097] In some particular embodiments, the memory may include a read-only memory (ROM), a random access memory (RAM), a disk storage media device, an optical storage media device, a flash memory device, an electrical, optical, or other physical / tangible memory storage device. Thus, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the task scheduling method according to the present application.
[0098] The first core configured as the main core among the multiple cores of the motor controller reads and executes the computer program instructions stored in the memory 502 to implement the steps of the task scheduling method provided by the embodiments of the present application.
[0099] In one example, the motor controller may further include a communication interface 503 and a bus 510. Among them, as Figure 5 shown, the processor 501, the memory 502, and the communication interface 503 are connected through the bus 510 and complete communication with each other.
[0100] The communication interface 503 is mainly used to implement communication between the various modules, devices, units, and / or devices in the embodiments of the present application.
[0101] The bus 510 includes hardware, software, or both, and couples the components of the motor controller to each other. By way of example and not limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro channel architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video electronics standards association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, the bus 510 may include one or more buses. Although the embodiments of the present application describe and illustrate specific buses, the present application contemplates any suitable bus or interconnect.
[0102] The motor controller can execute the task scheduling method provided by the embodiments of the present application, thereby achieving the corresponding technical effects of the task scheduling method provided by the embodiments of the present application.
[0103] In addition, in combination with the task scheduling method in the above embodiments, the embodiments of the present application also provide a computer-readable storage medium to implement. Computer program instructions are stored on the computer-readable storage medium; when the computer program instructions are executed by a processor, the steps of the task scheduling method provided by the embodiments of the present application are implemented. Examples of computer-readable storage media include non-transitory computer-readable media, such as ROM, RAM, magnetic disks, or optical discs.
[0104] The embodiments of the present application provide a computer program product, which includes computer program instructions. When the computer program instructions are executed by a processor, the steps of the task scheduling method provided by the embodiments of the present application are implemented, and the same technical effects can be achieved. To avoid repetition, it will not be elaborated here.
[0105] An embodiment of the present application further provides a vehicle, including the motor controller provided by the embodiment of the present application.
[0106] It should be clear that the present application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order between steps after understanding the spirit of the present application.
[0107] The functional blocks shown in the above block diagrams can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a functional card, and so on. When implemented in software, the elements of the present application are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium or transmitted via a data signal carried in a carrier wave on a transmission medium or a communication link. A "machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable read-only memory (EROM), floppy disks, compact disc read-only memory (CD-ROM), optical discs, hard disks, fiber optic media, radio frequency (RF) links, and so on. The code segment can be downloaded via a computer network such as the Internet, an intranet, and so on.
[0108] It should also be noted that the exemplary embodiments mentioned in the present application describe some methods or systems based on a series of steps or devices. However, the present application is not limited to the order of the above steps. That is, the steps can be executed in the order mentioned in the embodiments, can be different from the order in the embodiments, or several steps can be executed simultaneously.
[0109] As described above with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each block in the flowchart and / or block diagram, and the combination of blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the functions / actions specified in one or more blocks of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It should also be understood that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can also be implemented by dedicated hardware that performs the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0110] As described above, the foregoing is only a specific implementation manner of the present application. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, modules, and units described above can refer to the corresponding processes in the foregoing method embodiments, and will not be repeated herein. It should be understood that the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or substitutions within the technical scope disclosed in the present application, and these modifications or substitutions should all be covered by the protection scope of the present application.
Claims
1. A task scheduling method, characterized in that: The method is applied to a first core, the first core being a core configured as a main core in a motor controller having multiple cores in a vehicle, the first core being configured with a message queue for storing tasks; the method comprising: receiving a first task sent by a task sender, wherein the task sender includes a second core other than the first core among the multiple cores or a vehicle electronic control unit; Storing the first task in the message queue; Parsing the first task in the message queue to obtain a parsing result corresponding to the first task; The analysis result is sent to the corresponding task recipient.
2. The method according to claim 1, characterized in that The message queue includes a plurality of data blocks; Before storing the first task in the message queue, the method further includes: Calling a task to receive an interrupt service, searching for a first data block that is not currently used and does not store data in the plurality of data blocks; The storing the first task in the message queue includes: The first task is stored in the first data block.
3. The method according to claim 2, characterized in that Before storing the first task in the first data block, the method further includes: The state of the first data block is modified to a busy state, wherein the busy state is used to prohibit other services except the task receiving interrupt service from reading and writing the first data block.
4. The method according to claim 2, characterized in that: After storing the first task in the first data block, the method further includes: The state of the first data block is modified to an in-use state, wherein the in-use state is used to prohibit writing data into the first data block.
5. The method according to claim 2, characterized in that: After sending the analysis result to the corresponding task recipient, the method further includes: The state of the first data block is changed to an idle state, and the data in the first data block is cleared.
6. The method according to claim 1, characterized in that The message queue includes a first message queue and a second message queue, the first message queue is used to store tasks sent by the second core, and the second message queue is used to store tasks sent by the vehicle electronic control unit.
7. The method according to claim 6, characterized in that The task sender includes the second kernel, and the task receiver includes the vehicle electronic control unit; The storing the first task in the message queue comprises: The first task is stored in the first message queue.
8. The method according to claim 6, characterized in that The task sender includes the vehicle electronic control unit, and the task receiver includes the second kernel; The storing the first task in the message queue comprises: The first task is stored in the second message queue.
9. A task scheduling device, characterized in that: The device is applied to a first core, the first core is a core configured as a main core in a motor controller having multiple cores in a vehicle, and a message queue for storing tasks is configured in the first core; the device includes: A receiving module, configured to receive a first task sent by a task sender, wherein the task sender includes a second core other than the first core among the multiple cores or a vehicle electronic control unit; A storage module, used for storing the first task in the message queue; A parsing module, used for parsing the first task in the message queue to obtain a parsing result corresponding to the first task; The sending module is used to send the analysis result to the corresponding task recipient.
10. A motor controller, characterized in that: The motor controller includes: a processor and a memory storing computer program instructions; the processor has multiple cores; The first core configured as the main core among the multiple cores reads and executes the computer program instructions to implement the steps of the task scheduling method according to any one of claims 1 to 8.