Time-sharing scheduling method and device for equipment tasks, electronic equipment and program product

By obtaining thread configuration information and operating cycle management, and combining the clock frequency to adapt to the device structure, the problem of unreliable task response of self-organized drone equipment under high computing power tasks is solved, and the operation reliability and stability of the equipment are improved.

CN120540798APending Publication Date: 2025-08-26SHENZHEN JIUTIAN ZHANYI TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510573147.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-30
Publication Date
2025-08-26

AI Technical Summary

Technical Problem

Under the demand for high computing power tasks such as navigation, existing self-organized drone equipment sacrifices the computing frequency, resulting in unreliable task response time and affecting the operation reliability of electronic equipment.

Method used

By obtaining thread configuration information, determining the running cycle of each thread, and awakening and running the thread at the startup time, adapting the clock frequency to the electronic device structure and working state, using condition variables to wait for the lock state to be updated, ensuring that the task execution frequency is consistent with the device structure, and recording abnormal thread data for analysis.

Benefits of technology

While multi-task execution is achieved, the operation reliability of electronic devices is improved, the task response time uncertainty is avoided, and the stability and reliability of the device are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120540798A_ABST
    Figure CN120540798A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of computers, and provides a time-sharing scheduling method and device for equipment tasks, electronic equipment and a program product. The time-sharing scheduling method for the equipment tasks comprises the steps that thread configuration information is obtained, the thread configuration information comprises clock frequencies of multiple threads, each thread in the multiple threads is used for executing the corresponding equipment task, and the clock frequencies are at least associated with structure information of electronic equipment; according to the thread configuration information, determining an operation cycle of each thread in the plurality of threads; and waking up and running the corresponding thread at the starting time of the running cycle of each thread. According to the embodiment of the invention, while multi-task execution is realized, the task execution frequency is matched with the structure of the electronic equipment, and the operation reliability of the electronic equipment is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and in particular relates to a time-sharing scheduling method, apparatus, electronic equipment, and program product for device tasks. Background Art

[0002] For devices such as self-assembled drones, they often expand on the microcontroller hardware used in open source projects to achieve multi-threaded control. Microcontrollers often rely on real-time operating systems (RTOS) to achieve multitasking. However, in the case of tasks that require high computing power, such as navigation, the microcontroller will sacrifice a certain amount of computing frequency. The central processing unit (CPU) can fully utilize the floating-point performance and speed of high-computing hardware. Therefore, designing a control system on the CPU that is compatible with the multi-tasking characteristics and computing performance of the time-sharing system has become a new breakthrough in the drone industry. The current time-sharing system requires complex scheduling algorithms and resource management mechanisms. It allocates CPU time slices through a time-slice round-robin scheduling algorithm. The response time is uncertain, resulting in unreliable task response time, which in turn affects the operational reliability of electronic equipment. Summary of the Invention

[0003] The embodiments of the present application provide a time-sharing scheduling method, apparatus, electronic device, and program product for device tasks, which can adapt the task execution frequency to the electronic device structure while achieving multi-tasking execution, thereby improving the operational reliability of the electronic device.

[0004] A first aspect of an embodiment of the present application provides a time-sharing scheduling method for device tasks, including: obtaining thread configuration information, the thread configuration information including the clock frequencies of multiple threads, each of the multiple threads being used to execute a corresponding device task, and the clock frequencies being at least associated with structural information of the electronic device; determining an operating cycle of each of the multiple threads based on the thread configuration information; and waking up and running the corresponding thread at the start time of the operating cycle of each thread.

[0005] In some embodiments of the first aspect, after waking up and running the corresponding thread at the start time of each thread's operating cycle, the time-sharing scheduling method of the device task also includes: if the thread completes code execution within the corresponding operating cycle, controlling the corresponding thread to enter a sleep state and wait for the next operating cycle to arrive.

[0006] In some implementations of the first aspect, if the thread does not complete code execution within the corresponding execution cycle, the time-sharing scheduling method for device tasks further includes: recording thread data of the abnormal thread; and performing abnormality analysis on the thread data.

[0007] In some implementations of the first aspect, the performing abnormality analysis on the thread data includes: generating a waveform of the thread data; and performing abnormality classification based on the smoothness of the waveform.

[0008] In some embodiments of the first aspect, in the process of waking up and running the corresponding thread at the start time of each thread's running cycle, the running process of the target thread includes: determining the target data required by the device task corresponding to the target thread; monitoring the mutex lock state of the target data; if the mutex lock state is a blocked state, waiting for the mutex lock state to be updated to an idle state; when the mutex lock state is an idle state, performing read and write operations on the target data to execute the device task corresponding to the target thread according to the target data.

[0009] In some implementations of the first aspect, the clock frequency is also associated with a current working state of the electronic device.

[0010] In some implementations of the first aspect, the thread configuration information further includes a logical processor identifier corresponding to each of the multiple threads, and running the corresponding thread includes: allocating the thread to run on a logical processor associated with the corresponding logical processor identifier.

[0011] A second aspect of an embodiment of the present application provides a time-sharing scheduling device for device tasks, including: a configuration acquisition unit, used to obtain thread configuration information, the thread configuration information including the clock frequency of multiple threads, each of the multiple threads is used to execute a corresponding device task, and the clock frequency is at least associated with the structural information of the electronic device; a cycle determination unit, used to determine the operating cycle of each thread in the multiple threads according to the thread configuration information; a thread running unit, used to wake up and run the corresponding thread at the start time of the operating cycle of each thread.

[0012] A third aspect of an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned time-sharing scheduling method for device tasks when executing the computer program.

[0013] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the time-sharing scheduling method of the above-mentioned device tasks are implemented.

[0014] A fifth aspect of the embodiments of the present application provides a computer program product, which, when the computer program is run, enables the above-mentioned time-sharing scheduling method of device tasks to be executed.

[0015] In an embodiment of the present application, thread configuration information is obtained, and the operating cycle of each thread in a plurality of threads is determined according to the thread configuration information, and the corresponding thread is awakened and run at the start time of the operating cycle of each thread. Since the thread configuration information includes the clock frequencies of a plurality of threads, each of the plurality of threads is used to execute a corresponding device task, and the clock frequency is at least related to the structural information of the electronic device, it is possible to achieve multi-tasking execution while making the task execution frequency compatible with the electronic device structure, thereby improving the operating reliability of the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0017] Figure 1 This is a schematic diagram of an implementation flow of a time-sharing scheduling method for device tasks provided in an embodiment of the present application;

[0018] Figure 2 This is a schematic diagram of the architecture of the drone provided in the embodiment of the present application;

[0019] Figure 3 This is a schematic diagram of the structure of a time-sharing scheduling device for equipment tasks provided in an embodiment of the present application;

[0020] Figure 4 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0021] In order to make the purpose, technical solutions and advantages of this application more clear, the present application is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without making any creative work are protected by this application.

[0022] For devices like self-assembled drones, multi-threaded control is often achieved by expanding upon the microcontroller hardware used in open source projects. Microcontrollers often rely on real-time operating systems to achieve multitasking. However, for tasks requiring high computing power, such as navigation, the microcontroller sacrifices a certain degree of computing frequency. CPUs, on the other hand, can fully utilize the floating-point performance and speed of high-computing hardware. Therefore, designing control systems on the CPU that are compatible with the multitasking characteristics and computing performance of time-sharing systems has become a new breakthrough for the drone industry. Current time-sharing systems require complex scheduling algorithms and resource management mechanisms. They allocate CPU time slices through a round-robin scheduling algorithm, resulting in uncertain response times and unreliable task response times, which in turn affects the operational reliability of electronic equipment.

[0023] In view of this, the present application proposes a time-sharing scheduling method for device tasks, which can adapt the task execution process to the electronic device structure while achieving multi-task execution, thereby improving the operational reliability of the electronic device.

[0024] In order to illustrate the technical solution of the present application, specific embodiments are provided below.

[0025] Figure 1 This section illustrates a flowchart for implementing a time-sharing scheduling method for device tasks, as provided in an embodiment of the present application. This method can be applied to electronic devices. These electronic devices can be intelligent devices with autonomous mobility, such as drones, robots, and self-driving cars. Specifically, drones can refer to self-organizing drones capable of executing flight operations based on control commands.

[0026] Specifically, the time-sharing scheduling method for the device tasks may include the following steps S101 to S103.

[0027] Step S101: Obtain thread configuration information.

[0028] The thread configuration information may be used to manage the running process of the thread. In an embodiment of the present application, the thread configuration information may include the clock frequencies of multiple threads.

[0029] Specifically, each of the multiple threads can be used to execute a corresponding device task.

[0030] Taking the electronic device as a drone as an example, the above-mentioned multiple threads may include but are not limited to a gyroscope thread, a barometer thread, a GPS (Global Positioning System) and compass thread, an optical flow meter and a TOF (Time of Flight) thread, which can be used to achieve stable flight and navigation of the drone. Taking the electronic device as an autonomous vehicle as an example, the above-mentioned multiple threads may include but are not limited to multiple sensor (such as GPS, lidar, etc.) threads, which can be used to achieve autonomous navigation, obstacle avoidance and path planning of the vehicle. Taking the electronic device as a robot as an example, the above-mentioned multiple threads may include multiple sensor threads and data fusion threads, which can be used to achieve precise positioning and path planning of the robot.

[0031] The clock frequency of each thread is at least related to the structural information of the electronic device. The structural information is used to characterize the overall architecture of the electronic device and the conditions of the internal components, including but not limited to: rack size information, motor model information. Specifically, for different rack sizes, the clock frequency of the gyroscope thread can be set differently, so that the larger the rack size, the higher the clock frequency, in order to cope with the situation of large inertia and more vibration interference caused by the increase in size.

[0032] Step S102: determining the running cycle of each thread among the multiple threads according to the thread configuration information.

[0033] Specifically, based on the clock frequency of each thread, the time required for each thread to complete a complete operation can be determined, resulting in the operation cycle of each thread. For example, if the gyroscope and data fusion thread runs at a frequency of 1000 Hz, then its execution time is 1 ms, that is, the operation cycle of the gyroscope and data fusion thread is 1 ms.

[0034] Step S103: at the start time of the running cycle of each thread, wake up and run the corresponding thread.

[0035] In an embodiment of the present application, based on the running cycle of each thread, each thread can be controlled to wake up and run at the start time of the corresponding running cycle.

[0036] Specifically, you can use timestamps and sleep functions to control the thread's execution frequency. After starting a thread, it first enters a sleep state to ensure stable operation. The conditional variable notifyWait is used to wait for lockFlag to be set to true before waking up the thread and allowing it to run. While each thread is running, you can execute code to implement the corresponding device task.

[0037] In an embodiment of the present application, thread configuration information is obtained, and the operating cycle of each thread in a plurality of threads is determined according to the thread configuration information, and the corresponding thread is awakened and run at the start time of the operating cycle of each thread. Since the thread configuration information includes the clock frequencies of a plurality of threads, each of the plurality of threads is used to execute a corresponding device task, and the clock frequency is at least related to the structural information of the electronic device, it is possible to achieve multi-tasking execution while making the task execution frequency compatible with the electronic device structure, thereby improving the operating reliability of the electronic device.

[0038] In some embodiments of the present application, the thread configuration information may further include a logical processor identifier corresponding to each of the multiple threads. The above-mentioned running the corresponding thread may include: allocating the thread to run on a logical processor associated with the corresponding logical processor identifier.

[0039] Specifically, a constructor can be used to initialize threads, specifying a logical processor ID (CPU ID) and clock frequency for each thread. Based on the clock frequency, when the start time of each thread's run cycle arrives, the thread can be awakened and assigned to the logical processor associated with the corresponding logical processor ID to run.

[0040] Among them, the logical processor identifier corresponding to each thread can be set according to actual conditions. In some embodiments of the present application, the logical processors can be allocated according to the clock frequency of each thread. Specifically, the higher the clock frequency, the higher the number of times the thread runs in the same time, and the more resources it needs to occupy. Allocating logical processors based on the clock frequency of each thread can balance the resource usage between different logical processors. For example, since the gyroscope thread needs to run at a high frequency, a separate logical processor identifier can be allocated to the gyroscope thread, so that the logical processor associated with the logical processor identifier is only used to run the gyroscope thread. Alternatively, the logical processor identifier allocated to the gyroscope thread is allocated to other threads with lower clock frequencies, so that the logical processor associated with the logical processor identifier can only be used to run other threads running at a low frequency while running the gyroscope thread.

[0041] In some embodiments of the present application, the clock frequency may also be associated with the current working state of the electronic device.

[0042] The operating state represents the operating state of an electronic device. For example, for a drone, operating states include, but are not limited to, takeoff, steady flight, variable-speed flight, landing, and stopped. Given that the key data required for electronic devices may vary in different operating states, setting the clock frequency based on the electronic device's operating state allows the operating frequency of each device task to adapt to the operating state.

[0043] As an example, during takeoff, the drone relies on sensors capable of rapid dynamic response and dealing with sudden disturbances, and relies on gyroscopes and barometers to establish its initial state. Therefore, the clock frequencies of the gyroscope and barometer threads can be set to the first clock frequency, while the clock frequencies of other sensor threads can be set to the second clock frequency. The first clock frequency is greater than the second clock frequency, allowing the drone to obtain gyroscope and barometer data in real time and achieve takeoff. During stable flight, the sensors focus on multi-source fusion, ensuring navigation accuracy, and environmental interaction. At this time, the GPS and compass threads and visual sensor threads can be set to the third clock frequency, while the clock frequencies of other sensor threads can be set to the fourth clock frequency. The third clock frequency is greater than the fourth clock frequency, allowing the drone to obtain GPS and visual sensor data in real time and maintain stable flight and navigation.

[0044] Differentiated clock frequency settings based on structural information and working status can improve the timing stability of each thread's operation, thereby improving the reliability of device operation.

[0045] In some embodiments of the present application, at the start time of each thread's running cycle, after waking up and running the corresponding thread, the time-sharing scheduling method of the device task also includes: if the thread completes code execution within the corresponding running cycle, controlling the corresponding thread to enter a sleep state and wait for the next running cycle to arrive.

[0046] Specifically, you can get the current timestamp through GetTimeStamp, calculate the time difference TimeDT, and call threadMain to execute the main logic code of the device task. According to the calculated time difference and the clock frequency targetClock, control the sleep time of the thread to achieve accurate task scheduling. If the thread completes the code execution within the corresponding running cycle, the corresponding thread can be controlled to enter the sleep state and wait for the next running cycle to arrive. For example, if the clock frequency of the thread is 1000Hz, and the thread finishes running the code in advance within 1ms, the thread can be controlled to enter the sleep state until the 1ms of the current running cycle ends, enter the next running cycle, and then wake up again, thereby ensuring that the running time of each thread is strictly in accordance with the set clock frequency.

[0047] In other embodiments of the present application, if a thread fails to complete code execution within a corresponding execution cycle, the time-sharing scheduling method for device tasks further includes: recording thread data of the abnormal thread; and performing abnormality analysis on the thread data.

[0048] An abnormal thread is one that fails to complete its code execution within its corresponding execution cycle. For example, if a thread's clock frequency is 1000Hz and the thread's execution time exceeds 1ms, TimeOut_MAX can be used to record the maximum execution time of the thread and its thread data. This data can then be saved in the black box's historical data for troubleshooting.

[0049] Specifically, performing abnormality analysis on thread data may include: generating a waveform of the thread data; and classifying abnormalities according to the smoothness of the waveform.

[0050] Specifically, the thread data can be written into the BlackBox.BBL file, and the waveform can be viewed using open source software, and anomalies can be classified based on the smoothness of the waveform.

[0051] For example, the thread above is a magnetometer thread, and its thread data is the angle data read by the magnetometer. If the smoothness of the angle data waveform is below the smoothness threshold, indicating that it is no longer smooth and exhibits an irregular sawtooth waveform, it can be determined that the anomaly is caused by a short circuit in the printed circuit board (PCB) chip or local magnetic field interference. If the smoothness of the angle data waveform is greater than or equal to the smoothness threshold, it indicates that the anomaly is caused by a mechanical structure or code bug.

[0052] At the start time of each thread's running cycle, in the process of waking up and running the corresponding thread, the running process of the target thread may include: determining the target data required by the device task corresponding to the target thread; monitoring the mutex lock state of the target data; if the mutex lock state is in a blocked state, waiting for the mutex lock state to be updated to an idle state; when the mutex lock state is in an idle state, performing read and write operations on the target data to execute the device task corresponding to the target thread according to the target data.

[0053] The target data is the thread that is awakened and needs to be run.

[0054] For the target thread, the target data that its device task needs to read and write can be determined. In the embodiments of the present application, after a thread acquires the mutex lock of the target data, the thread can safely access the target data. During the access period of the thread, other threads will not be able to acquire the mutex lock, and the mutex lock state will be blocked, thereby avoiding the contention problem that occurs when multiple threads access the same data at the same time.

[0055] Before performing read or write operations on the target data, the target thread needs to monitor the mutex lock status of the target data. If the mutex lock status is blocked, it must wait for other threads to release the mutex lock, so that the mutex lock status is updated to idle. Then, the target data can be read or written, and the device task corresponding to the target thread can be executed based on the target data. If the mutex lock status is idle, the target data can be read or written directly, and the device task corresponding to the target thread can be executed based on the target data. This ensures the consistency and correctness of the target data.

[0056] It should be noted that the target data mentioned above can be the data of any thread. The data of each thread can be shared with each other, and each thread can access each other's data. When accessing data, atomic operations and signals can be used to ensure data inconsistency caused by race conditions. When an exception occurs during data access, an interrupt signal can be generated. The interrupt signal can be used to interrupt the currently executing code and resume execution after the exception is handled. Among them, the exception during data access can refer to the macro-defined value being modified by other threads when a specific thread is running. For example, the specific thread mentioned above can refer to the gyroscope thread. The interrupt signal can be used to ensure that the parameters used for posture solution are not modified by other threads during the operation of the gyroscope thread, thereby ensuring the reliability of the posture and navigation control information output by the gyroscope.

[0057] For ease of understanding, Figure 2 The schematic diagram of the architecture of the drone provided in this application is shown. The drone is equipped with a separate core. This separate core can be a central processing unit (CPU), which is responsible for receiving, processing, and coordinating thread data from different sensor threads to ensure that the drone can safely and accurately perform flight missions. The different sensor threads may include, but are not limited to, running a gyroscope thread, a barometer thread, a GPS and compass thread, an optical flow meter and time of flight (TOF) thread, a remote control data decompression thread, a security and data display thread, and other sensor threads. When executing code, the GPS and compass thread receives signals from the global positioning system and converts them into the drone's precise geographic location. The barometer thread can be used to calculate the drone's flight altitude by measuring atmospheric pressure. The remote control data decompression thread can be used to interpret control commands sent by the remote control. The thread data processed by each sensor thread can be stored in memory, read by the gyroscope thread, and integrated with attitude information such as acceleration and angular velocity read by the gyroscope thread through the accelerometer to complete attitude and navigation calculations, which are then shared in memory.

[0058] Users can set up shared memory mapping relationships through user applications. Based on the mapping relationships, each thread can read and write target data from the shared memory. At the same time, other applications can read data from the shared memory for processing or output based on the mapping relationships.

[0059] The CPU also saves thread data in the black box's historical data for analysis and troubleshooting when needed. The safety protection and data display threads monitor the drone's operating status, lock the propellers when flight abnormalities occur, and provide real-time flight data to the operator. Furthermore, the CPU can add threads to implement other functions as needed, such as reading the drone's voltage.

[0060] The embodiments of this application not only enable the simultaneous execution of multiple tasks, but also utilize a modular design, designing threads for different device tasks. This allows for easy expansion and customization, facilitating the selection of required components and software packages based on project requirements, and supporting the development of a wide range of applications, such as the Internet of Things, graphical user interfaces (GUIs), and network protocol stacks. Clock-based management of each thread prevents cross-influence between device tasks, preventing delayed response times and the resulting anomalies in electronic equipment during flight.

[0061] It should be noted that, for the sake of simplicity of description, the aforementioned method embodiments are all expressed as a series of action combinations. However, those skilled in the art should be aware that this application is not limited to the described order of actions, because according to this application, certain steps can be performed in other orders.

[0062] like Figure 3 FIG2 is a schematic structural diagram of a time-sharing scheduling apparatus 300 for device tasks provided in an embodiment of the present application. The time-sharing scheduling apparatus 300 for device tasks is configured on an electronic device.

[0063] Specifically, the time-sharing scheduling device 300 for device tasks may include:

[0064] A configuration acquisition unit 301 is configured to acquire thread configuration information, wherein the thread configuration information includes clock frequencies of multiple threads, each of the multiple threads being configured to execute a corresponding device task, and the clock frequencies being at least associated with structural information of the electronic device;

[0065] a cycle determining unit 302, configured to determine an operating cycle of each of the plurality of threads according to the thread configuration information;

[0066] The thread running unit 303 is used to wake up and run the corresponding thread at the start time of the running cycle of each thread.

[0067] In some embodiments of the present application, the thread running unit 303 can be used to: at the start time of the running cycle of each thread, after waking up and running the corresponding thread, if the thread completes the code running within the corresponding running cycle, control the corresponding thread to enter a sleep state and wait for the next running cycle to arrive.

[0068] In some embodiments of the present application, the thread execution unit 303 may be configured to: record thread data of an abnormal thread if the thread fails to complete code execution within the corresponding execution cycle; and perform abnormality analysis on the thread data.

[0069] In some embodiments of the present application, the thread execution unit 303 may be configured to: generate a waveform of the thread data; and perform abnormality classification according to the smoothness of the waveform.

[0070] In some embodiments of the present application, the thread running unit 303 can be used to: determine the target data required by the device task corresponding to the target thread in the process of waking up and running the corresponding thread at the start time of each thread's running cycle; monitor the mutex lock state of the target data; if the mutex lock state is in a blocked state, wait for the mutex lock state to be updated to an idle state; when the mutex lock state is in an idle state, perform read and write operations on the target data to execute the device task corresponding to the target thread according to the target data.

[0071] In some embodiments of the present application, the clock frequency is also associated with the current working state of the electronic device.

[0072] In some embodiments of the present application, the thread configuration information further includes a logical processor identifier corresponding to each of the multiple threads, and the thread execution unit 303 may be configured to: assign the thread to a logical processor associated with the corresponding logical processor identifier for execution.

[0073] It should be noted that for the convenience and simplicity of description, the specific working process of the time-sharing scheduling device 300 of the above equipment tasks can be referred to Figures 1 to 2 The corresponding process of the method will not be described in detail here.

[0074] like Figure 4 , which is a schematic diagram of an electronic device provided in an embodiment of the present application. Specifically, the electronic device 4 may include: a processor 40, a memory 41, and a computer program 42 stored in the memory 41 and executable on the processor 40, such as a time-sharing scheduling program for device tasks. When the processor 40 executes the computer program 42, the steps of the above-mentioned time-sharing scheduling method embodiment of each device task are implemented, such as Figure 1Alternatively, when the processor 40 executes the computer program 42, the functions of the modules / units in the above-mentioned device embodiments are realized, for example, Figure 3 The functions of the configuration acquisition unit 301 , the cycle determination unit 302 and the thread execution unit 303 are shown.

[0075] The computer program may be divided into one or more modules / units, which are stored in the memory 41 and executed by the processor 40 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device.

[0076] For example, the computer program can be divided into: a configuration acquisition unit, a cycle determination unit, and a thread execution unit. The specific functions of each unit are as follows: the configuration acquisition unit is used to obtain thread configuration information, wherein the thread configuration information includes the clock frequency of multiple threads, each of the multiple threads is used to execute a corresponding device task, and the clock frequency is at least related to the structural information of the electronic device; the cycle determination unit is used to determine the execution cycle of each thread in the multiple threads based on the thread configuration information; and the thread execution unit is used to wake up and execute the corresponding thread at the start time of each thread's execution cycle.

[0077] The electronic device may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will understand that Figure 4 These are merely examples of electronic devices and do not constitute a limitation of the electronic device. The electronic device may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.

[0078] The processor 40 may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.

[0079] The memory 41 may be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device. The memory 41 may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Furthermore, the memory 41 may include both an internal storage unit of the electronic device and an external storage device. The memory 41 is used to store the computer program and other programs and data required by the electronic device. The memory 41 may also be used to temporarily store data that has been output or is about to be output.

[0080] It should be noted that, for the convenience and brevity of description, the structure of the above electronic device can also refer to the specific description of the structure in the method embodiment, which will not be repeated here.

[0081] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0082] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.

[0083] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0084] In the embodiments provided in the present application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0085] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0086] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0087] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0088] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.

Claims

1. A time-sharing scheduling method for equipment tasks, characterized in that: include: Obtaining thread configuration information, the thread configuration information including clock frequencies of multiple threads, each of the multiple threads being used to execute a corresponding device task, the clock frequencies being at least associated with structural information of the electronic device; Determining an operating cycle of each of the plurality of threads according to the thread configuration information; At the start time of each thread's running cycle, wake up and run the corresponding thread.

2. The time-sharing scheduling method for device tasks according to claim 1, characterized in that: After waking up and running the corresponding thread at the start time of the running cycle of each thread, the time-sharing scheduling method of the device task further includes: If the thread completes the code execution within the corresponding operation cycle, the corresponding thread is controlled to enter a sleep state and wait for the next operation cycle to arrive.

3. The time-sharing scheduling method for device tasks according to claim 2, characterized in that: If the thread does not complete code execution within the corresponding execution cycle, the time-sharing scheduling method for the device task further includes: Record thread data of abnormal threads; An exception analysis is performed on the thread data.

4. The time-sharing scheduling method for device tasks according to claim 3, wherein: The performing abnormality analysis on the thread data includes: generating a waveform of the thread data; Anomalies are classified based on the smoothness of the waveform.

5. The time-sharing scheduling method for device tasks according to any one of claims 1 to 4, characterized in that: In the process of waking up and running the corresponding thread at the start time of the running cycle of each thread, the running process of the target thread includes: Determine target data required by the device task corresponding to the target thread; Monitoring the mutex state of the target data; If the mutex lock state is in a blocked state, waiting for the mutex lock state to be updated to an idle state; When the mutex lock state is an idle state, a read and write operation is performed on the target data to execute a device task corresponding to the target thread according to the target data.

6. The time-sharing scheduling method for device tasks according to any one of claims 1 to 4, characterized in that: The clock frequency is also related to the current working state of the electronic device.

7. The time-sharing scheduling method for device tasks according to any one of claims 1 to 4, characterized in that: The thread configuration information also includes a logical processor identifier corresponding to each of the multiple threads, and the running of the corresponding thread includes: Assign the thread to run on the logical processor associated with the corresponding logical processor ID.

8. A time-sharing scheduling device for equipment tasks, characterized in that: include: a configuration acquiring unit, configured to acquire thread configuration information, the thread configuration information including clock frequencies of a plurality of threads, each of the plurality of threads being respectively configured to execute a corresponding device task, the clock frequencies being at least associated with structural information of the electronic device; a cycle determining unit, configured to determine an operating cycle of each of the plurality of threads according to the thread configuration information; The thread running unit is used to wake up and run the corresponding thread at the start time of each thread's running cycle.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the time-sharing scheduling method for device tasks as claimed in any one of claims 1 to 7 are implemented.

10. A computer program product, characterized in that The invention comprises a computer program, which enables the time-sharing scheduling method of the device task as claimed in any one of claims 1 to 7 to be executed when the computer program is executed.