Task scheduling method, device, equipment and readable storage medium without operating system
Through the task scheduling method without operating system, through the collaborative work of the interrupt service subroutine and the main program, configuring and polling the priority of the control task, the problem of insufficient reliability and real-time performance of task scheduling in the embedded control system is solved, and the realization of Efficient task scheduling and resource management.
Patent Information
- Application Number
- CN202111680990.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-12-31
AI Technical Summary
When existing embedded control systems process multi-tasks in parallel, the reliability of task scheduling is poor and cannot meet the response requirements of millisecond-level real-time events. In addition, when running on bare metal, it starts quickly but has strong real-time performance but is difficult to achieve.
Using a task scheduling method without an operating system, the enable flag bits and priorities of control tasks are traversed and configured through the interrupt service subroutine. Based on the main program, the ready tasks are polled and the execution order is determined to achieve hierarchical scheduling of tasks and avoid interactive data delays. and safety issues.
It improves the real-time and reliability of task scheduling, saves system resources, optimizes memory utilization, and ensures the real-time and reliability of important tasks.
Smart Images

Figure CN114296905B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of embedded control systems, and in particular to a task scheduling method, device, equipment and readable storage medium without an operating system. Background Art
[0002] Embedded control systems in vehicle control systems generally involve two platforms. One is to have its own operating system, such as VxWorks. The advantage of this approach is that it is easy for developers to manage multiple tasks, but due to the existence of the operating system, the startup time is longer than that of a bare metal. In addition, the operating system uses semaphores to schedule and manage tasks, which cannot meet the millisecond-level real-time event response requirements, and the real-time performance of task scheduling is poor. The other is to run bare metal without an operating system. The advantages of this approach are fast startup and strong real-time performance, but it is more difficult to implement when performing multi-task parallel processing, and the reliability of task scheduling is poor. Summary of the invention
[0003] The main purpose of the present invention is to provide a task scheduling method, device, equipment and readable storage medium without an operating system, aiming to improve the real-time performance of task scheduling while improving the reliability of task scheduling.
[0004] To achieve the above object, the present invention provides a task scheduling method without an operating system, comprising the following steps:
[0005] Based on the interrupt service subroutine, traverse each control task, configure an enable flag bit for the control task, obtain a ready control task, and configure a priority for the ready control task;
[0006] Based on the main program, polling each of the ready control tasks, and determining the execution order of the ready control tasks according to the priority of the ready control tasks;
[0007] According to the execution order, the execution tasks corresponding to the ready control tasks are executed in sequence.
[0008] Optionally, the step of sequentially executing the execution tasks corresponding to the ready control tasks according to the execution order includes:
[0009] Based on the main program, the ready control tasks are converted into execution tasks corresponding to the ready control tasks in sequence according to the execution order.
[0010] Based on the interrupt service subroutine, traverse each of the execution tasks, configure an enable flag bit for the execution task, obtain a ready-to-execute task, and configure a priority for the ready-to-execute task;
[0011] Based on the main program, each of the ready-to-execute tasks is polled, and the ready-to-execute tasks are executed in sequence according to their priorities.
[0012] Optionally, the step of traversing each of the execution tasks, configuring an enable flag for the execution task, obtaining a ready-to-execute task, and configuring a priority for the ready-to-execute task includes:
[0013] Traversing each of the execution tasks to obtain execution information of the execution tasks;
[0014] According to the execution information, an enable flag is configured for the execution task to obtain a ready-to-execute task;
[0015] According to the execution information, a priority is configured for the ready-to-execute task.
[0016] Optionally, the step of polling each of the ready-to-execute tasks and executing the ready-to-execute tasks in sequence according to the priority of the ready-to-execute tasks includes:
[0017] Polling each of the ready-to-execute tasks to determine a first polling cumulative number of the ready-to-execute tasks;
[0018] If the cumulative number of first polling of the ready-to-execute task is greater than a preset number threshold, the priority of the ready-to-execute task greater than the preset number threshold is increased, and the cumulative number of first polling of the ready-to-execute task greater than the preset number threshold is cleared;
[0019] The ready-to-execute tasks are executed in sequence according to their priorities.
[0020] Optionally, the step of polling each of the ready control tasks and determining the execution order of the ready control tasks according to the priority of the ready control tasks includes:
[0021] Polling each of the ready control tasks to determine a second polling cumulative number of each of the ready control tasks;
[0022] If the second polling cumulative number of the ready control task is greater than a preset number threshold, the priority of the ready control task greater than the preset number threshold is increased, and the second polling cumulative number of the ready control task greater than the preset number threshold is cleared;
[0023] The execution order of the ready control tasks is determined according to the priorities of the ready control tasks.
[0024] Optionally, the step of traversing each control task, configuring an enable flag bit for the control task, obtaining a ready control task, and configuring a priority for the ready control task includes:
[0025] Traversing each control task to obtain control information of each control task;
[0026] According to the control information, an enable flag is configured for the control task to obtain a ready control task, and a priority is configured for the ready control task.
[0027] Optionally, the step of configuring an enable flag bit for a control task according to the control information, obtaining a ready control task, and configuring a priority for the ready control task includes:
[0028] Determining control logic information and control function information corresponding to the control information;
[0029] According to the control logic information, an enable flag is configured for the control task to obtain a ready control task;
[0030] According to the control function information, a priority is configured for the ready control task.
[0031] In addition, to achieve the above purpose, the present invention also provides a task scheduling device without an operating system, comprising:
[0032] A configuration module, used for traversing each control task based on the interrupt service subroutine, configuring an enable flag bit for the control task, obtaining a ready control task, and configuring a priority for the ready control task;
[0033] A polling module, used for polling each of the ready control tasks based on a main program, and determining the execution order of the ready control tasks according to the priority of the ready control tasks;
[0034] An execution module is used to execute the execution tasks corresponding to the ready control tasks in sequence according to the execution order.
[0035] In addition, to achieve the above-mentioned purpose, the present invention also provides a task scheduling device without an operating system. The task scheduling device without an operating system includes a memory, a processor, and a task scheduling program stored in the memory and executable on the processor. When the task scheduling program is executed by the processor, the steps of the task scheduling method without an operating system as described above are implemented.
[0036] In addition, to achieve the above-mentioned purpose, the present invention also provides a readable storage medium, on which a task scheduling program is stored, and when the task scheduling program is executed by a processor, the steps of the task scheduling method without an operating system as described above are implemented.
[0037] The present invention saves system resources of the embedded system, because multiple tasks in the system need to have their own system resources, and when there are many tasks, the system resource consumption is large. The present invention accurately configures the priority of the control task according to the relevant information of each control task, so that each important control task can be allocated memory first, and the memory is released after completion, and then other control tasks with lower priority are executed, thereby improving the utilization rate of memory resources and further improving the reliability of task scheduling.
[0038] The present invention performs traversal of control tasks based on the universal timer in the main chip, and enables the control tasks, so there is no need to install an operating system, and the bare metal is used to implement the scheduling and management of tasks, thereby improving the real-time performance of task scheduling. At the same time, the present invention accurately configures the priority of the control tasks according to the relevant information of each control task, thereby preventing the safety problems caused by the delay of interactive data or premature interaction, thereby improving the reliability of task scheduling. That is, because the working capacity of the embedded system is limited, the present invention improves the reliability of task scheduling by giving priority to ensuring the real-time performance of some important tasks under limited capacity, thereby achieving the improvement of the reliability of task scheduling while improving the real-time performance of task scheduling. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a schematic diagram of the terminal\device structure of the hardware operating environment involved in the embodiment of the present invention;
[0040] Figure 2 It is a flowchart of the first embodiment of the task scheduling method without an operating system of the present invention;
[0041] Figure 3 This is a flow chart of step S300 in the second embodiment of the task scheduling method without an operating system of the present invention;
[0042] Figure 4 A schematic diagram of a device module of a task scheduling device without an operating system of the present invention.
[0043] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION
[0044] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0045] like Figure 1 As shown, Figure 1 It is a schematic diagram of the terminal structure of the hardware operating environment involved in the embodiment of the present invention.
[0046] The terminal in the embodiment of the present invention is a task scheduling device without an operating system.
[0047] like Figure 1 As shown, the terminal may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0048] Optionally, the terminal may also include a camera, an RF (Radio Frequency) circuit, a sensor, an audio circuit, a WiFi module, and the like. Among them, the sensors include light sensors, motion sensors, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display screen according to the brightness of the ambient light, and the proximity sensor may turn off the display screen and / or backlight when the terminal device is moved to the ear. Of course, the terminal device may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0049] Those skilled in the art will understand that Figure 1 The terminal structure shown in the figure does not constitute a limitation on the terminal, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0050] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a task scheduling program.
[0051] exist Figure 1 In the terminal shown, the network interface 1004 is mainly used to connect to the backend server and perform data communication with the backend server; the user interface 1003 is mainly used to connect to the client (user end) and perform data communication with the client; and the processor 1001 can be used to call the task scheduling program stored in the memory 1005 and perform the following operations:
[0052] Based on the interrupt service subroutine, traverse each control task, configure an enable flag bit for the control task, obtain a ready control task, and configure a priority for the ready control task;
[0053] Based on the main program, polling each of the ready control tasks, and determining the execution order of the ready control tasks according to the priority of the ready control tasks;
[0054] According to the execution order, the execution tasks corresponding to the ready control tasks are executed in sequence.
[0055] Please refer to Figure 2 The present invention provides a task scheduling method without an operating system. In a first embodiment of the task scheduling method without an operating system, the task scheduling method without an operating system includes the following steps:
[0056] Step S100, based on the interrupt service subroutine, traverse each control task, configure an enable flag bit for the control task, obtain a ready control task, and configure a priority for the ready control task;
[0057] Among them, the interrupt service subroutine is a subroutine of the general timer in the main chip. This embodiment adopts an embedded control system without an operating system, which is applied to the field of vehicle control systems. The embedded control system without an operating system has the advantages of fast startup and strong real-time task scheduling, but because it is difficult to implement when performing multi-task parallel processing, the reliability of task scheduling is poor. Therefore, this embodiment improves the embedded control system without an operating system. In order to improve the reliability of task scheduling during multi-task parallel processing and avoid conflicts between multiple control tasks on the same execution task operation, this embodiment traverses each control task based on the interrupt service subroutine, configures an enable flag for the control task, obtains a ready control task, and configures a priority for the ready control task, so that different priorities can be set according to different ready control tasks for hierarchical scheduling to meet the processing requirements of multiple types of tasks.
[0058] Those skilled in the art can understand that, in the interrupt service subroutine of the timer, the control tasks are traversed, and enabling operations are performed according to the relevant information of the control tasks. After traversing all subtasks, the main program is returned.
[0059] In a possible implementation manner, the steps of traversing each control task, configuring an enable flag bit for the control task, obtaining a ready control task, and configuring a priority for the ready control task include:
[0060] Step A10, traverse each control task to obtain control information of each control task;
[0061] In this embodiment, the vehicle control tasks may include brake pedal control, accelerator pedal control, steering wheel control, vehicle air conditioning temperature control, and window control. Among them, the control information of the brake pedal control may be the deceleration information corresponding to the brake pedal opening. The control information of the accelerator pedal control may be the acceleration information corresponding to the accelerator pedal opening. The control information of the vehicle air conditioning temperature control may be the air conditioning temperature information. The control information of the window control may be the window height information.
[0062] Step A20: According to the control information, an enable flag is configured for the control task to obtain a ready control task, and a priority is configured for the ready control task.
[0063] Specifically, the step of configuring an enable flag bit for a control task according to the control information, obtaining a ready control task, and configuring a priority for the ready control task includes:
[0064] Step B10, determining control logic information and control function information corresponding to the control information;
[0065] In this embodiment, the task scheduling method without an operating system is applied to the field of vehicle control. In one embodiment, if the control information is the deceleration information corresponding to the brake pedal opening, it can be determined that the control function information is brake control, and the control logic information is specific deceleration information, for example, the deceleration information is -5m / s. If the control information is the acceleration information corresponding to the accelerator pedal opening, it can be determined that the control function information is acceleration control, and the control logic information is specific acceleration information, for example, the acceleration information is 5m / s. If the control information is air-conditioning temperature information, it can be determined that the control function information is air-conditioning temperature control, and the control logic information is specific air-conditioning temperature information, for example, the air-conditioning temperature information is 23°C. If the control information is window height information, it can be determined that the control function information is window height control, and the control logic information is specific window height information, for example, the window height information is 23°C.
[0066] Step B20, configuring an enable flag bit for the control task according to the control logic information to obtain a ready control task;
[0067] It is understandable that when a change in control logic information is detected, the control task corresponding to the control logic information needs to be configured with an enable flag, so that the control task corresponding to the control logic information is ready. For example, if the current deceleration information changes, the brake pedal control configuration enables the flag. If the current acceleration information changes, the accelerator pedal control configuration enables the flag. If the current air conditioning temperature information changes, the vehicle air conditioning temperature control configuration enables the flag. If the current window height information changes, the window height control configuration enables the flag.
[0068] Step B30: configuring a priority for the ready control task according to the control function information.
[0069] It should be noted that the importance of the control function can be determined according to the control function information, so as to configure the priority for the ready control task. For example, in order to avoid collisions and prevent safety accidents, the importance of brake control is very high. The importance of acceleration control is second, because it involves the driving control of the vehicle, which is also relatively important. Then the air conditioning temperature control and the window height control are less important than the acceleration control. It can be understood that the importance of the control function information can be set by technicians in this field according to actual needs.
[0070] This embodiment determines the control logic information and control function information corresponding to the control information, configures an enable flag for the control task according to the control logic information, obtains a ready control task, and configures a priority for the ready control task according to the control function information, thereby configuring the most suitable priority for the control task according to the relevant information of the control task, thereby preventing security issues caused by delayed or premature interaction of interactive data, and further improving the reliability of task scheduling.
[0071] Step S200, based on the main program, polling each of the ready control tasks, and determining the execution order of the ready control tasks according to the priority of the ready control tasks;
[0072] It can be understood that the higher the priority of the ready control task is, the higher the execution order is, and the lower the priority of the ready control task is, the lower the execution order is.
[0073] In an implementable manner, the step of polling each of the ready control tasks and determining the execution order of the ready control tasks according to the priority of the ready control tasks includes:
[0074] Step C10, polling each of the ready control tasks to determine a second polling cumulative number of each of the ready control tasks;
[0075] It should be noted that each time the readiness control task is polled, the cumulative number of second polling of the readiness control task is accumulated by 1. For example, if the readiness control task A is polled three times, the cumulative number of second polling is 3; if the readiness control task A is polled four times, the cumulative number of second polling is 4.
[0076] Step C20, if the second polling cumulative number of the ready control task is greater than the preset number threshold, the priority of the ready control task greater than the preset number threshold is increased, and the second polling cumulative number of the ready control task greater than the preset number threshold is cleared;
[0077] Among them, since there may be a situation where the ready control task with a higher priority level continuously enters the polling queue, it is possible that the ready control task cannot be responded for a long time, thereby causing the control task to be blocked, affecting the user's normal control or use of the various functional components of the vehicle. Therefore, in this embodiment, if the cumulative number of second polling of the ready control task is greater than the preset number threshold, the priority of the ready control task greater than the preset number threshold is increased, thereby adjusting the priority level of the blocked control task to a higher level, so that the blocked control task can be executed first, ensuring the user's normal control or use of the various functional components of the vehicle. The preset number threshold can be set by those skilled in the art according to actual conditions to better detect whether the ready control task cannot be responded for a long time due to being squeezed out by other ready control tasks, and this embodiment does not make specific limitations. In one embodiment, the preset number threshold is 3 times. In another embodiment, the preset number threshold is 4 times.
[0078] Step C30: determining the execution order of the ready control tasks according to the priorities of the ready control tasks.
[0079] This embodiment updates the priority of the control task by adjusting the priority of the ready control task that is greater than the preset number threshold if the cumulative number of second polling times of the ready control task is greater than the preset number threshold, thereby realizing dynamic raising and lowering of the priority of the control task, ensuring that low-priority control tasks can also be executed normally, and thereby improving the reliability of task scheduling.
[0080] Step S300: executing the execution tasks corresponding to the ready control tasks in sequence according to the execution order.
[0081] It should be noted that the present embodiment divides the tasks into control tasks and execution tasks, and each ready control task has a corresponding execution task. For example, when the ready control task is brake pedal control, the execution task corresponding to the ready control task may be brake operation, when the ready control task is accelerator pedal control, the execution task corresponding to the ready control task may be driver operation, when the ready control task is steering wheel control, the execution task corresponding to the ready control task may be steering gear operation, when the ready control task is vehicle air conditioning temperature, the execution task corresponding to the ready control task may be air conditioning compressor operation, when the ready control task is steering wheel control, the execution task corresponding to the ready control task may be steering gear operation, etc.
[0082] In addition, in order to help understand the present application, a specific embodiment is listed. In this specific embodiment, there are 4 ready control tasks, which are respectively recorded as A, B, C and D. An execution task E. Among them, A, B, C and D all perform related controls on E. The lowest priority of D is set to 1, B and C have the same priority and are set to 2, and the highest priority of A is set to 3. After A enables the configuration of E, even if the tasks of B, C and D are ready, they will be skipped due to the problem of low configuration priority. Only after A disables the configuration of E, can the tasks of B, C and D enable the configuration of E. That is, when there are multiple control sources for the same execution task, or when multiple control tasks meet the enabling conditions and are in the ready state, the specific execution order is determined according to their priority levels.
[0083] This embodiment saves system resources of the embedded system, because multiple tasks in the system need to have their own system resources, and when there are many tasks, the system resource consumption is large. This embodiment accurately configures the priority of the control task according to the relevant information of each control task, so that each important control task can be allocated memory first, and the memory is released after completion, and then other control tasks with lower priority can be executed, thereby improving the utilization rate of memory resources and thus improving the reliability of task scheduling.
[0084] This embodiment traverses the control tasks based on the universal timer in the main chip, and enables the control tasks, so there is no need to install an operating system, and the bare metal is used to implement the scheduling and management of tasks, thereby improving the real-time performance of task scheduling. At the same time, this embodiment accurately configures the priority of the control tasks according to the relevant information of each control task, thereby preventing the security problems caused by the delay of interactive data or premature interaction, thereby improving the reliability of task scheduling. That is, because the working capacity of the embedded system is limited, this embodiment improves the reliability of task scheduling by giving priority to the real-time performance of some important tasks under limited capacity, thereby achieving the improvement of the reliability of task scheduling while improving the real-time performance of task scheduling.
[0085] Further, based on the first embodiment of the present invention, a second embodiment of the task scheduling method without an operating system of the present invention is proposed. Figure 3 In this embodiment, in step S300 of the above embodiment, the steps of sequentially executing the execution tasks corresponding to the ready control tasks according to the execution order include:
[0086] Step S310: Based on the main program and according to the execution order, the ready control tasks are converted into execution tasks corresponding to the ready control tasks in sequence.
[0087] Step S320, based on the interrupt service subroutine, traverse each of the execution tasks, configure an enable flag bit for the execution task, obtain a ready-to-execute task, and configure a priority for the ready-to-execute task;
[0088] Step S330: based on the main program, poll each of the ready-to-execute tasks, and execute the ready-to-execute tasks in sequence according to their priorities.
[0089] This embodiment divides the functions to be implemented by the embedded software into control tasks and execution tasks according to the relationship between the controller and the controlled, and schedules the execution tasks and control tasks separately to avoid conflicts when multiple control tasks operate on the same execution task, thereby improving the reliability of task scheduling. At the same time, it avoids the bloated and complex code itself, thereby improving the real-time performance of task scheduling.
[0090] The embedded control system of this embodiment is based on bare metal operation, has a better startup time than the operating system, and has strong real-time performance. At the same time, by traversing the relevant information of each execution task, it accurately configures the priority of the execution task, sets different priorities according to different execution tasks, and realizes hierarchical scheduling to meet the processing needs of multiple types of execution tasks, so that each important execution task can be allocated memory first, and the memory is released after completion, and then other execution tasks with lower priorities can be executed again, so as to maximize the utilization of system resources and thereby improve the reliability of task scheduling.
[0091] In a possible implementation, the steps of traversing each of the execution tasks, configuring an enable flag for the execution task, obtaining a ready-to-execute task, and configuring a priority for the ready-to-execute task include:
[0092] Step D10, traversing each of the execution tasks to obtain the execution information of the execution tasks;
[0093] In the present embodiment, it should be noted that each execution task has corresponding execution information. In one embodiment, when the execution task is brake operation, the execution information corresponding to the execution task is specific operation information of the brake, such as the braking torque of the brake. When the execution task is driver operation, the execution information corresponding to the execution task is specific operation information of the driver, such as the driving torque of the driver. When the execution task is steering gear operation, the execution information corresponding to the execution task is specific operation information of the steering gear, such as the steering torque of the steering gear. When the execution task is air-conditioning compressor operation, the execution information corresponding to the execution task is specific operation information of the air-conditioning compressor, such as the operating power of the air-conditioning compressor.
[0094] Step D20, configuring an enable flag for the execution task according to the execution information, and obtaining a ready-to-execute task;
[0095] It is understandable that when a change in execution information is detected, the execution task corresponding to the execution information needs to be configured with an enable flag to make the execution task corresponding to the execution information ready. For example, if the braking torque of the brake changes, the brake operation is configured with an enable flag.
[0096] Step D30: configuring a priority for the ready-to-execute task according to the execution information.
[0097] It should be noted that the importance of the execution task can be determined based on the execution information, so as to configure the priority for the ready-to-execute task. For example, in order to avoid collisions and prevent safety accidents, the importance of brake operation is very high. The importance of drive operation and steering operation is second, because the driving control of the vehicle is also relatively important. Then the air conditioning temperature control is less important than the drive operation or the steering. It can be understood that the importance of the execution task can be set by those skilled in the art according to actual needs.
[0098] This embodiment traverses each of the execution tasks to obtain the execution information of the execution task; configures an enable flag for the execution task according to the execution information to obtain a ready execution task; and configures a priority for the ready execution task according to the execution information, thereby accurately configuring the priority for the execution task according to the relevant information of the execution task, thereby preventing security issues caused by delayed or premature interaction of interactive data, thereby improving the reliability of task scheduling.
[0099] In an practicable manner, the step of polling each of the ready-to-execute tasks and sequentially executing the ready-to-execute tasks according to their priorities includes:
[0100] Step E10, polling each of the ready-to-execute tasks to determine a first cumulative polling number of the ready-to-execute tasks;
[0101] It should be noted that each time a ready-to-execute task is polled, the cumulative number of first polling of the ready-to-execute task is accumulated by 1. For example, if the ready-to-execute task C is polled twice, the cumulative number of first polling is 2, and if the ready-to-execute task D is polled three times, the cumulative number of first polling is 3.
[0102] Step E20, if the cumulative number of first polling of the ready-to-execute task is greater than a preset number threshold, the priority of the ready-to-execute task greater than the preset number threshold is increased, and the cumulative number of first polling of the ready-to-execute task greater than the preset number threshold is cleared;
[0103] Among them, since there may be continuously higher priority ready-to-execute tasks entering the polling queue, there is a situation where the ready-to-execute task cannot be responded for a long time, which in turn causes the execution of the task to be blocked, affecting the user's normal control or use of the various functional components of the vehicle. Therefore, in this embodiment, if the cumulative number of the first polling of the ready-to-execute task is greater than the preset number threshold, the priority of the ready-to-execute task greater than the preset number threshold is increased, thereby adjusting the priority level of the blocked execution task to a higher level, so that the blocked execution task can be executed first, ensuring the user's normal control or use of the various functional components of the vehicle. The preset number threshold can be set by those skilled in the art according to actual conditions to better detect whether the ready-to-execute task has not been responded for a long time, and this embodiment does not make specific limitations. In one embodiment, the preset number threshold is 3 times. In another embodiment, the preset number threshold is 4 times.
[0104] Step E30: Execute the ready-to-execute tasks in sequence according to their priorities.
[0105] This embodiment updates the priority of the execution task by adjusting the priority of the ready execution task that is greater than the preset number threshold if the cumulative number of first polling times of the ready execution task is greater than the preset number threshold, thereby realizing dynamic raising and lowering of the priority of the execution task, ensuring that low-priority execution tasks can also be executed normally, and thereby improving the reliability of task scheduling.
[0106] In addition, refer to Figure 4 The embodiment of the present invention further provides a task scheduling device without an operating system, comprising:
[0107] Configuration module S1, used for traversing each control task based on the interrupt service subroutine, configuring an enable flag bit for the control task, obtaining a ready control task, and configuring a priority for the ready control task;
[0108] A polling module S2, used for polling each of the ready control tasks based on the main program, and determining the execution order of the ready control tasks according to the priority of the ready control tasks;
[0109] The execution module S3 is used to execute the execution tasks corresponding to the ready control tasks in sequence according to the execution order.
[0110] Optionally, the execution module S3 is further configured to:
[0111] Based on the main program, the ready control tasks are converted into execution tasks corresponding to the ready control tasks in sequence according to the execution order.
[0112] Based on the interrupt service subroutine, traverse each of the execution tasks, configure an enable flag bit for the execution task, obtain a ready-to-execute task, and configure a priority for the ready-to-execute task;
[0113] Based on the main program, each of the ready-to-execute tasks is polled, and the ready-to-execute tasks are executed in sequence according to their priorities.
[0114] Optionally, the execution module S3 is further configured to:
[0115] Traversing each of the execution tasks to obtain execution information of the execution tasks;
[0116] According to the execution information, an enable flag is configured for the execution task to obtain a ready-to-execute task;
[0117] According to the execution information, a priority is configured for the ready-to-execute task.
[0118] Optionally, the execution module S3 is further configured to:
[0119] Polling each of the ready-to-execute tasks to determine a first polling cumulative number of the ready-to-execute tasks;
[0120] If the cumulative number of first polling of the ready-to-execute task is greater than a preset number threshold, the priority of the ready-to-execute task greater than the preset number threshold is increased, and the cumulative number of first polling of the ready-to-execute task greater than the preset number threshold is cleared;
[0121] The ready-to-execute tasks are executed in sequence according to their priorities.
[0122] Optionally, the polling module S2 is further configured to:
[0123] Polling each of the ready control tasks to determine a second polling cumulative number of each of the ready control tasks;
[0124] If the second polling cumulative number of the ready control task is greater than a preset number threshold, the priority of the ready control task greater than the preset number threshold is increased, and the second polling cumulative number of the ready control task greater than the preset number threshold is cleared;
[0125] The execution order of the ready control tasks is determined according to the priorities of the ready control tasks.
[0126] Optionally, the configuration module S1 is further configured to:
[0127] Traversing each control task to obtain control information of each control task;
[0128] According to the control information, an enable flag is configured for the control task to obtain a ready control task, and a priority is configured for the ready control task.
[0129] Optionally, the configuration module S1 is further configured to:
[0130] Determining control logic information and control function information corresponding to the control information;
[0131] According to the control logic information, an enable flag is configured for the control task to obtain a ready control task;
[0132] According to the control function information, a priority is configured for the ready control task.
[0133] The steps implemented by each functional module of the task scheduling device without an operating system may refer to the various embodiments of the task scheduling method without an operating system of the present invention, and will not be described in detail here.
[0134] In addition, the present invention also provides a task scheduling device without an operating system, and the task scheduling device without an operating system includes: a memory, a processor, and a task scheduling program stored in the memory; the processor is used to execute the task scheduling program to implement the steps of each embodiment of the above-mentioned task scheduling method without an operating system.
[0135] The present invention also provides a readable storage medium, which stores one or more programs. The one or more programs can also be executed by one or more processors to implement the steps of each embodiment of the above-mentioned task scheduling method without an operating system.
[0136] The specific implementation of the readable storage medium of the present invention is basically the same as the above-mentioned embodiments of the task scheduling method without an operating system, and will not be described in detail here.
[0137] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0138] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0139] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0140] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A task scheduling method without an operating system, characterized in that: The task scheduling method without an operating system comprises the following steps: Based on the interrupt service subroutine, traverse each control task, configure an enable flag bit for the control task, obtain a ready control task, and configure a priority for the ready control task; Based on the main program, polling each of the ready control tasks, and determining the execution order of the ready control tasks according to the priority of the ready control tasks; According to the execution order, sequentially execute the execution tasks corresponding to the ready control tasks; The step of sequentially executing the execution tasks corresponding to the ready control tasks according to the execution order includes: Based on the main program, according to the execution order, sequentially converting the ready control tasks into execution tasks corresponding to the ready control tasks; Based on the interrupt service subroutine, traverse each of the execution tasks, configure an enable flag bit for the execution task, obtain a ready-to-execute task, and configure a priority for the ready-to-execute task; Based on the main program, polling each of the ready-to-execute tasks, and executing the ready-to-execute tasks in sequence according to the priority of the ready-to-execute tasks; The control task and the execution task are divided according to the functions to be realized by the embedded software and the relationship between the controller and the controlled.
2. The task scheduling method without an operating system as claimed in claim 1, characterized in that: The steps of traversing each of the execution tasks, configuring an enable flag for the execution task, obtaining a ready-to-execute task, and configuring a priority for the ready-to-execute task include: Traversing each of the execution tasks to obtain execution information of the execution tasks; According to the execution information, an enable flag is configured for the execution task to obtain a ready-to-execute task; According to the execution information, a priority is configured for the ready-to-execute task.
3. The task scheduling method without an operating system as claimed in claim 1, characterized in that: The step of polling each of the ready-to-execute tasks and executing the ready-to-execute tasks in sequence according to the priority of the ready-to-execute tasks comprises: Polling each of the ready-to-execute tasks to determine a first polling cumulative number of the ready-to-execute tasks; If the cumulative number of first polling of the ready-to-execute task is greater than a preset number threshold, the priority of the ready-to-execute task greater than the preset number threshold is increased, and the cumulative number of first polling of the ready-to-execute task greater than the preset number threshold is cleared; The ready-to-execute tasks are executed in sequence according to their priorities.
4. The task scheduling method without an operating system as claimed in claim 1, characterized in that: The step of polling each of the ready control tasks and determining the execution order of the ready control tasks according to the priority of the ready control tasks comprises: Polling each of the ready control tasks to determine a second polling cumulative number of each of the ready control tasks; If the second polling cumulative number of the ready control task is greater than a preset number threshold, the priority of the ready control task greater than the preset number threshold is increased, and the second polling cumulative number of the ready control task greater than the preset number threshold is cleared; The execution order of the ready control tasks is determined according to the priorities of the ready control tasks.
5. The task scheduling method without an operating system as claimed in claim 1, characterized in that: The steps of traversing each control task, configuring an enable flag bit for the control task, obtaining a ready control task, and configuring a priority for the ready control task include: Traversing each control task to obtain control information of each control task; According to the control information, an enable flag is configured for the control task to obtain a ready control task, and a priority is configured for the ready control task.
6. The task scheduling method without an operating system as claimed in claim 5, characterized in that: The step of configuring an enable flag bit for the control task according to the control information, obtaining a ready control task, and configuring a priority for the ready control task comprises: Determining control logic information and control function information corresponding to the control information; According to the control logic information, an enable flag is configured for the control task to obtain a ready control task; According to the control function information, a priority is configured for the ready control task.
7. A task scheduling device without an operating system, characterized in that: The task scheduling device without an operating system comprises: A configuration module, used for traversing each control task based on the interrupt service subroutine, configuring an enable flag bit for the control task, obtaining a ready control task, and configuring a priority for the ready control task; A polling module, used for polling each of the ready control tasks based on a main program, and determining the execution order of the ready control tasks according to the priority of the ready control tasks; An execution module, used for sequentially executing the execution tasks corresponding to the ready control tasks according to the execution order; The step of sequentially executing the execution tasks corresponding to the ready control tasks according to the execution order includes: Based on the main program, according to the execution order, sequentially converting the ready control tasks into execution tasks corresponding to the ready control tasks; Based on the interrupt service subroutine, traverse each of the execution tasks, configure an enable flag bit for the execution task, obtain a ready-to-execute task, and configure a priority for the ready-to-execute task; Based on the main program, polling each of the ready-to-execute tasks, and executing the ready-to-execute tasks in sequence according to the priority of the ready-to-execute tasks; The control task and the execution task are divided according to the functions to be realized by the embedded software and the relationship between the controller and the controlled.
8. A task scheduling device without an operating system, characterized in that: The task scheduling device without an operating system comprises: a memory, a processor, and a task scheduling program stored in the memory and executable on the processor. When the task scheduling program is executed by the processor, the steps of the task scheduling method without an operating system as described in any one of claims 1 to 6 are implemented.
9. A readable storage medium, characterized in that: The readable storage medium stores a task scheduling program, and when the task scheduling program is executed by a processor, the steps of the task scheduling method without an operating system are implemented as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Job scheduler, job scheduling method
CN101271296A
Multitask control method based on vehicle electrical control system
CN104536345A
