A method and device for obtaining image files

By sorting and linking N tasks in the embedded device, and generating optimized mirror files, the problem of long startup time of the embedded device is solved and faster system startup is achieved.

CN112711427BActive Publication Date: 2025-03-25HUAWEI TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN201911018528.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-10-24
Publication Date
2025-03-25
Estimated Expiration
2039-10-24

AI Technical Summary

Technical Problem

When the existing embedded devices start up, the image file loading speed is slower, resulting in a longer system startup time and affecting the user experience.

Method used

By determining the execution and loading time of N tasks in the program source code, sorting the execution time from long to short or time from large to small, and generating a mirror file to optimize the startup time of the embedded device.

Benefits of technology

This method can shorten the startup time of the embedded device, and improve the system's fast startup capability by loading and executing tasks in parallel.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112711427B_ABST
    Figure CN112711427B_ABST
Patent Text Reader

Abstract

The present application discloses a method for obtaining an image file, comprising: determining a first value of each of N tasks in a program source code, the first value being a first duration required to execute each of the N tasks, or the first value being a ratio of the first duration to the second duration, the second duration being the duration required to load each of the N tasks, and N being a positive integer. Sorting the N tasks from large to small according to the first value. Linking the sorted N tasks to obtain an image file. Through the technical solution provided by the present application, after downloading the image file, the embedded device sequentially loads and executes the N tasks, thereby shortening the startup time of the embedded device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a method for obtaining an image file. Background Art

[0002] Embedded devices include host machines and target machines. The host machines and target machines are developed based on different system architectures. The host machine is responsible for development and compilation, that is, the development and compilation device. The target machine runs the compiled program downloaded from the host machine. The target machine is also called an embedded device.

[0003] In embedded devices, the system startup speed is an important measurement indicator, especially for consumer embedded devices such as driving recorders, cameras and smart print servers, the system startup time directly affects the user experience.

[0004] Usually, the macro kernel is used as the preferred kernel architecture for embedded devices, so the kernel program code and application code of the embedded device will be packaged together for development and debugging. The two codes will be compiled and linked into a whole image file, and then the image file will be deployed to the embedded device. The embedded device will load the image file after powering on. Therefore, the loading speed of the image file is closely related to the startup speed of the embedded device. Therefore, how to achieve fast loading of the image file and optimize the startup time of the embedded device is an urgent problem to be solved. Summary of the invention

[0005] The embodiment of the present application provides a method for obtaining an image file, which shortens the startup time of an embedded device.

[0006] To achieve the above objectives, the present application provides the following technical solutions:

[0007] The first aspect of the present application provides a method for obtaining an image file, which may include: determining a first value of each of N tasks in a program source code, where a task is a set of codes for completing certain functions, and each task may contain several functions. The first value is the first duration required to execute each of the N tasks, or the first value is the ratio of the first duration to the second duration, and the second duration is the duration required to load each of the N tasks, and N is a positive integer. The N tasks are sorted from large to small according to the first value. The sorted N tasks are linked to obtain an image file. It can be seen from the first aspect that by sorting the N tasks from long to short according to the execution time, or sorting them from large to small according to the time ratio, and linking the sorted N tasks to generate an image file, the embedded device can first load the task with a longer execution time after downloading the image file, so that the next task can be loaded during the execution of the previous task, or the embedded device can first load the task with a short loading time and a long task execution time after downloading the image file, so that the total time required to complete the N tasks can be guaranteed to be the shortest, thereby shortening the startup time of the embedded device.

[0008] Optionally, in combination with the first aspect, in a first possible implementation, a function dependency of each of the N tasks is obtained, where the function dependency of each task is a call relationship between functions included in each of the N tasks. Linking the sorted N tasks to obtain an image file includes: linking the functions included in each of the sorted N tasks according to the function dependency of each of the N tasks to obtain an image file.

[0009] Optionally, in combination with the first possible implementation of the first aspect above, in a second possible implementation, obtaining the functional dependency of each of the N tasks may include: obtaining syntax tree information of all tasks in the program source code, and all tasks may include N tasks. The functional dependencies of all tasks are obtained based on the syntax tree information, and the functional dependencies of all tasks are the calling relationships between the functions that all tasks may include. The functional dependencies of each of the N tasks are determined based on the annotations in the program source code and the functional dependencies of all tasks, and the annotations are pre-set and used to identify the functions of the tasks, and the functions of the N tasks are pre-specified. It can be seen from the second possible implementation of the first aspect that the functional dependencies of each task can be obtained through the syntax tree information and the annotations in the program source code, thereby increasing the diversity of the solutions.

[0010] Optionally, in combination with the first aspect or the first aspect or the second possible implementation of the first aspect, in a third possible implementation, the method may further include: dividing the program source code, the divided program source code may include program source code corresponding to N tasks and program source code corresponding to M tasks, the N tasks correspond to the key business of the embedded device, and the M tasks correspond to the remaining business in the embedded device except the key business. It can be seen from the second possible implementation of the first aspect that the N tasks are key tasks. In the embedded startup scenario, the key tasks are loaded and executed first, which shortens the startup time of the embedded device.

[0011] Optionally, in combination with the first aspect or the first to the third possible implementations of the first aspect, in a fourth possible implementation, determining the first value of each of the N tasks in the program source code may include: determining the starting position and the ending position of each of the N tasks according to the functional dependency of each of the N tasks, the starting position including the first timestamp, and the ending position including the second timestamp. Running each of the N tasks, and determining the first value according to the difference between the first timestamp and the second timestamp.

[0012] The second aspect of the present application provides a method for starting an embedded device, which may include: loading N tasks in a system image file and running the N tasks, the N tasks are linked from large to small according to a first numerical value, the first numerical value is the first duration required to execute each of the N tasks, or the first numerical value is the ratio of the first duration to the second duration, the second duration is the duration required to load each task, and N is a positive integer. It can be seen from the second aspect that through the solution provided by the present application, in the process of starting the embedded device, not only can the key tasks be loaded and executed first, but the time required to load the key tasks can also be further shortened. This solution sorts the key tasks, links the N tasks according to the sorting, to generate an image file, and can load the next task while running the previous key task, implements the parallel maximization of the loading and execution operations of different tasks, and ensures the rapid startup of the embedded device.

[0013] Optionally, in combination with the second aspect, in a first possible implementation manner, the method may further include: after running N tasks, loading one or more tasks that may be included in the image file other than the N tasks in the image file.

[0014] The third aspect of the present application provides a device for obtaining an image file, which may include: a memory for storing computer-readable instructions; and may also include a processor coupled to the memory, executing the computer-readable instructions in the memory to perform the following operations: determining a first value of each of N tasks in a program source code, the first value being a first duration required to execute each of the N tasks, or the first value being a ratio of the first duration to a second duration, the second duration being the duration required to load each of the N tasks, and N being a positive integer; sorting the N tasks from large to small according to the first value; and linking the sorted N tasks to obtain the image file.

[0015] Optionally, in combination with the third aspect above, in a first possible implementation method, the processor is further used to: obtain the function dependency of each of the N tasks, the function dependency of each task being the calling relationship between the functions that can be included in each of the N tasks; and link the functions that can be included in each of the sorted N tasks according to the function dependency of each of the N tasks to obtain the image file.

[0016] Optionally, in combination with the first possible implementation method of the third aspect above, in a second possible implementation method, the processor is specifically used to: obtain syntax tree information of all tasks in the program source code, where all tasks may include N tasks; obtain functional dependencies of all tasks based on the syntax tree information, where the functional dependencies of all tasks are calling relationships between functions that can be included in all tasks; determine the functional dependencies of each of the N tasks based on the annotations in the program source code and the functional dependencies of all tasks, where the annotations are pre-set and used to identify the functions of the tasks, and the functions of the N tasks are pre-specified.

[0017] Optionally, in combination with the above-mentioned third aspect or the first or the second possible implementation of the third aspect, in a third possible implementation, the processor is also used to: divide the program source code, and the divided program source code may include program source code corresponding to N tasks and program source code corresponding to M tasks, the N tasks correspond to the key business of the embedded device, and the M tasks correspond to the remaining business in the embedded device except the key business.

[0018] Optionally, in combination with the above-mentioned third aspect or the first to third possible implementations of the third aspect, in a fourth possible implementation, the processor is specifically used to: determine the starting position and the ending position of each of the N tasks based on the functional dependency of each of the N tasks, the starting position may include a first timestamp, and the ending position may include a second timestamp; run each of the N tasks, and determine the first numerical value based on the difference between the first timestamp and the second timestamp.

[0019] The fourth aspect of the present application provides an embedded device, which may include: a memory for storing computer-readable instructions; and may also include a processor coupled to the memory, executing the computer-readable instructions in the memory to perform the following operations: loading N tasks in a system image file and running the N tasks, the N tasks being linked from large to small according to a first numerical value, the first numerical value being a first duration required to execute each of the N tasks, or the first numerical value being a ratio of the first duration to the second duration, the second duration being the duration required to load each task, and N being a positive integer.

[0020] Optionally, in combination with the fourth aspect, in a first possible implementation manner, the processor is further configured to:

[0021] After running N tasks, one or more tasks that may be included in the image file other than the N tasks in the image file are loaded.

[0022] According to a fifth aspect of the present application, there is provided an image file acquisition device, which may include: a storage unit for storing computer-readable instructions; and may also include a processing unit for executing the computer-readable instructions in the storage unit to perform the following operations: determining a first value of each of N tasks in a program source code, wherein the first value is a first duration required to execute each of the N tasks, or the first value is a ratio of the first duration to a second duration, wherein the second duration is a duration required to load each of the N tasks, and N is a positive integer; sorting the N tasks from large to small according to the first value; and linking the sorted N tasks to obtain the image file.

[0023] Optionally, in combination with the fifth aspect above, in a first possible implementation method, the processing unit is further used to: obtain the function dependency of each of the N tasks, the function dependency of each task being the calling relationship between the functions that can be included in each of the N tasks; and link the functions that can be included in each of the sorted N tasks according to the function dependency of each of the N tasks to obtain the image file.

[0024] Optionally, in combination with the first possible implementation method of the fifth aspect above, in a second possible implementation method, the processing unit is specifically used to: obtain syntax tree information of all tasks in the program source code, where all tasks may include N tasks; obtain functional dependencies of all tasks based on the syntax tree information, where the functional dependencies of all tasks are calling relationships between functions that can be included in all tasks; determine the functional dependencies of each of the N tasks based on the annotations in the program source code and the functional dependencies of all tasks, where the annotations are pre-set and used to identify the functions of the tasks, and the functions of the N tasks are pre-specified.

[0025] Optionally, in combination with the above-mentioned fifth aspect or the first or the second possible implementation of the fifth aspect, in a third possible implementation, the processing unit is also used to: divide the program source code, and the divided program source code may include program source code corresponding to N tasks and program source code corresponding to M tasks, the N tasks correspond to the key business of the embedded device, and the M tasks correspond to the remaining business in the embedded device except the key business.

[0026] Optionally, in combination with the above-mentioned fifth aspect or the first to fifth aspects of the third possible implementation, in a fourth possible implementation, the processing unit is specifically used to: determine the starting position and the ending position of each of the N tasks according to the functional dependency relationship of each of the N tasks, the starting position may include a first timestamp, and the ending position may include a second timestamp; run each of the N tasks, and determine the first numerical value according to the difference between the first timestamp and the second timestamp.

[0027] The sixth aspect of the present application provides an embedded device, which may include: a storage unit (or memory) for storing computer-readable instructions; and may also include a processing unit (or processor) for executing the computer-readable instructions in the storage unit to perform the following operations: load N tasks in the system image file and run the N tasks, the N tasks are linked from large to small according to a first numerical value, the first numerical value is a first duration required to execute each of the N tasks, or the first numerical value is a ratio of the first duration to the second duration, the second duration is the duration required to load each task, and N is a positive integer.

[0028] Optionally, in combination with the sixth aspect, in a first possible implementation manner, the processing unit is further configured to:

[0029] After running N tasks, one or more tasks that may be included in the image file other than the N tasks in the image file are loaded.

[0030] In a seventh aspect, the present application provides a computer-readable storage medium, which stores instructions. When the computer-readable storage medium is run on a computer, the computer can execute the method for obtaining an image file of the first aspect or any possible implementation of the first aspect.

[0031] In an eighth aspect, the present application provides a computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium, and when the instructions are executed on a computer, the computer can execute the method for starting an embedded device according to the second aspect or any possible implementation of the second aspect. The computer may include one or more processing units.

[0032] A ninth aspect of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method for obtaining an image file of the first aspect or any possible implementation of the first aspect.

[0033] The tenth aspect of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method for starting an embedded device according to the second aspect or any possible implementation of the second aspect.

[0034] Among them, the technical effects brought about by any implementation method in the third aspect, the fifth aspect, the seventh aspect, and the ninth aspect can refer to the technical effects brought about by different implementation methods in the first aspect, and will not be repeated here.

[0035] Among them, the technical effects brought about by any implementation method in the fourth, sixth, eighth and tenth aspects can refer to the technical effects brought about by different implementation methods in the second aspect, and will not be repeated here.

[0036] The present application provides a method for obtaining an image file, by sorting N tasks from long to short according to the execution time required, or sorting them from large to small according to the time ratio, so that after the N tasks are linked to obtain the image file, the embedded device can first load the task with a longer execution time after downloading the image file, so that the next task can be loaded during the execution of the previous task, or the embedded device can first load the task with a short loading time and a long execution time after downloading the image file, so that the total time required to complete the execution of the N tasks can be guaranteed to be the shortest, thereby shortening the startup time of the embedded device. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 A schematic diagram of an embedded device provided in an embodiment of the present application;

[0038] Figure 2 A schematic diagram of the startup time of an embedded device;

[0039] Figure 3 It is a schematic diagram of the startup time in the fast startup technology based on the snapshot method;

[0040] Figure 4 It is a schematic diagram of the startup time in the fast startup scheme based on the scattered loading method;

[0041] Figure 5 A schematic diagram of a process for obtaining an image file provided in an embodiment of the present application;

[0042] Figure 6 A flowchart of another method for obtaining an image file provided in an embodiment of the present application;

[0043] Figure 7 A schematic diagram of a method for starting an embedded device provided in an embodiment of the present application;

[0044] Figure 8 Schematic diagram of the scenario provided for this application;

[0045] Fig. 9 A schematic diagram of the hardware structure of the device for obtaining the image file provided in the embodiment of the present application;

[0046] Fig.10 A schematic diagram of the structure of a device for obtaining an image file provided in an embodiment of the present application;

[0047] Fig.11 A schematic diagram of the structure of a device for obtaining an image file provided in an embodiment of the present application;

[0048] Fig.12 A schematic diagram of the hardware structure of an embedded device provided in an embodiment of the present application;

[0049] Fig.13 A schematic diagram of the structure of an embedded device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] The following describes the embodiments of the present application in conjunction with the accompanying drawings. Obviously, the described embodiments are only embodiments of a part of the present application, rather than all embodiments. It is known to those skilled in the art that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0051] The embodiment of the present application provides a method for obtaining an image file, a method for starting an embedded device, and an embedded device. The technical solution provided by the present application adjusts the positions of different tasks in the image file according to the task execution time from long to short or according to the task time ratio from large to small. When the current task is being executed, the next one or more tasks can be loaded to realize the fast startup of the embedded device, which are described in detail below.

[0052] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described here can be implemented in an order other than that illustrated or described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or devices. The naming or numbering of steps in this application does not mean that the steps in the method flow must be executed in the time / logical sequence indicated by the naming or numbering. The process steps that have been named or numbered can change the execution order according to the technical purpose to be achieved, as long as the same or similar technical effects can be achieved. The division of modules in this application is a logical division. There may be other division methods when it is implemented in actual applications. For example, multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some ports, and the indirect coupling or communication connection between modules can be electrical or other similar forms, which are not limited in this application. In addition, the modules or submodules described as separate components may or may not be physically separated, may or may not be physical modules, or may be distributed in multiple circuit modules, and some or all of the modules may be selected according to actual needs to achieve the purpose of the present application.

[0053] Figure 1 A schematic diagram of an embedded device provided in an embodiment of the present application, such as Figure 1 As shown, the embedded device includes a development and compilation device and an embedded device, wherein the development and compilation device is a host, and the embedded device is a target machine. The present application is used to realize the fast startup of the embedded device. The target machine, that is, the embedded device can be a driving recorder, an intelligent printing server, a camera, an intelligent video camera, etc. Correspondingly, the host is responsible for developing and compiling the system programs of the driving recorder, the intelligent printing server, the camera, the intelligent video camera, etc.

[0054] Generally, embedded devices use a macro kernel as their preferred kernel architecture. The macro kernel is an operating system kernel architecture. The characteristic of this architecture is that the entire kernel program is a single binary executable file, and the code can only run in the kernel state supervision mode. Corresponding to the macro kernel is the micro kernel architecture. The micro kernel separates the kernel and system services, making the kernel modular. Different modules communicate using inter-process communication (IPC), and its performance is far inferior to the macro kernel. Since the macro kernel is used as the kernel architecture, the kernel program code and application code of the embedded system will be packaged together for development and debugging. These two codes will be compiled and linked into a whole binary image file, and then this binary file will be deployed to the embedded device. When measuring the startup time of such embedded devices, the interval from the time the embedded device is powered on to the time when a certain specified key task is completed is often used as the startup time of the device. Different embedded devices usually have different set key tasks. For example, the key business of a driving recorder may be the camera business and the wireless connection business. Then the time from the moment the driving recorder is powered on to the completion of the camera business and the wireless connection business is the start-up time of the driving recorder. For another example, for a smart camera, the key task may be the image display task. Then the start-up time of the smart camera is the time from the power-on moment to the moment when the image display task is completed. The task mentioned in this application refers to a set of code blocks that complete a certain function, including at least one complete function code block. As shown in Figure 2, it is a schematic diagram of the startup time of an embedded device. The startup time of an embedded device may include: the time required for system power-on, the time required for image loading, the time required for system initialization, and the time required for key task execution. The loading referred to in this application refers to the transfer of program code from other storage media to memory. When the loader loads the program code into the memory, the address, offset and other information of the program code are first updated to the process control block. When the processor accesses these addresses, a page fault interrupt will be triggered, and only then will the program code be actually copied to the memory.

[0055] In order to improve the startup time of embedded devices, there are two ways, one is a fast startup solution based on the snapshot method, and the other is a fast startup solution based on the distributed loading method. The following introduces these two solutions.

[0056] Snapshot is a data copy technology that is triggered based on a time point or a certain point in the program execution. There is no limit to the size of the copied data. It can be a single task or the entire memory data. The quick startup solution based on the snapshot method first packages, compiles, and links the kernel program code and application code of the embedded system into a complete binary executable image file, and then burns the image file to the embedded device. When the embedded device is started for the first time, after executing the specified task (the specified task can be regarded as a critical task), the snapshot operation of the entire system is started, and the snapshot is saved to the specified location in the storage medium. Figure 3 As shown in FIG. 1 , it is a schematic diagram of the startup time in the fast startup technology based on the snapshot method, such as Figure 3 As shown, when the embedded device is powered on again, the system snapshot (instead of the original image) is first loaded into the memory, and then the snapshot recovery operation is started, mainly restoring the system status information, memory information, etc. When the snapshot recovery operation is successful, the embedded device can continue to execute the program code from the location where the snapshot is saved, thereby achieving the purpose of quickly starting the embedded device.

[0057] In the quick startup solution based on the snapshot method, the snapshot image requires additional storage space, which increases the cost of the embedded device. For embedded devices with limited storage space, the snapshot method is not applicable.

[0058] Scatter loading is to divide the application into two relatively independent parts. When loading, the first part of the code can be loaded first, and then the second part of the code. The fast startup solution based on the scattered loading method divides the entire system program code into two parts. The program code of the entire system includes all kernel program codes and all application codes: the first part is the code from powering on the embedded device to executing key tasks, and the second part is the subsequent other task codes. Dividing the first part of the code into relatively independent parts is the core step of the scattered loading method. The scattered loading method requires developers to trim and filter the program code related to the first part, and then place the first part of the code in the specified segment of the image by modifying the link script file, and finally divide the entire image into two relatively independent parts: the fast startup part and the non-fast startup part. Such as Figure 4 As shown in Figure 1, it is a schematic diagram of the startup time in the fast startup scheme based on the scattered loading method. Figure 4 As shown, when the embedded device is powered on, the quick start part in the image file is loaded first, that is, the first part mentioned above. After the quick start part is loaded, the quick start part code is executed. After the quick start part code is executed, the non-quick start part in the image file is loaded again. After the non-quick start part is loaded, the code of the non-quick start part is executed.

[0059] The fast startup technology based on the distributed loading method requires developers to separate the fast startup code from the program code of the entire system. Developers first create a relatively independent project from the startup of the embedded device to the execution of key tasks, and then compare this project with the complete project, and then delete the code in the original complete project that is not related to the fast startup part, and only keep the necessary code or files, and then verify whether the tailored code can ensure the correct execution of key tasks through compilation and burning. In this process, developers need to invest a lot of energy to locate and repair the errors that occur. The execution process is complicated, especially for the development of complex embedded devices. Developers may not be able to complete the above-mentioned tailoring, debugging and other tasks.

[0060] In order to solve the above problems, the present application provides a method for obtaining an image file. Compared with the quick startup solution based on the snapshot method, the solution provided by the present application can not only achieve the purpose of quickly starting the embedded device, but also does not require additional storage space. Compared with the quick startup solution based on the distributed loading method, the solution provided by the present application does not require developers to separate the quick startup part code from the program code of the entire system, and does not require developers to invest a lot of energy in locating and repairing the errors that occur, thereby simplifying the development process.

[0061] like Figure 5 The figure is a flow chart of a method for obtaining an image file provided in an embodiment of the present application.

[0062] like Figure 5 As shown, a method for obtaining an image file may include the following steps:

[0063] 501. Determine a first value of each of N tasks in a program source code.

[0064] N is a positive integer, a task is a set of codes to complete certain functions, and each task may contain several functions. The program source code includes all kernel program source codes and all application source codes. The program source code includes multiple tasks, but due to the embedded device based on the macro kernel architecture, the kernel program source code and the application source code may be distributed at any position in the image file, so the code included in each task, or the function included in each task may be distributed at any position in the image file. The first value is the first time required to execute each of the N tasks, or the first value is the ratio of the first time to the second time, and the second time is the time required to load each task. In the following, the time required to execute a task is referred to as the execution time, and the time required to load a task is referred to as the loading time.

[0065] For each of the N tasks, the loading time and execution time of the task can be obtained. In this solution, the ratio of the execution time to the loading time can be called the time ratio. The first value can be the execution time or the time ratio. The host can obtain the execution time and the loading time in a variety of ways. For example, two ways of obtaining the execution time are given below:

[0066] In a specific implementation, the functional dependency of each of the N tasks in the program source code is obtained. The starting position and the ending position of each task code can be determined according to the functional dependency of each task. The starting position includes a first timestamp, and the ending position includes a second timestamp. After running each task, the difference between the first timestamp and the second timestamp can be determined. According to actual needs, the task can be run multiple times to obtain the difference between multiple first timestamps and second timestamps. The average value of the difference between the multiple first timestamps and the second timestamp can be regarded as the time required for the execution of a task. The functional dependency of a task is the mutual calling relationship between multiple functions included in the task. This solution can analyze the functional dependency of each of the N tasks through compiler analysis technology, that is, analyze the dependency between multiple functions included in each of the N tasks. In other words, by analyzing the functional dependency of each of the N tasks in the program source code with the help of compiler analysis technology, the minimum code set required for each task function is divided. For example, assuming that N is 3, the N tasks are the first task, the second task and the third task, wherein the first task (task1) includes functions (func) 1-1, func1-2, func1-3, and func1-4; the second task (task2) includes func2-1, func2-2, func2-3, and func2-4; the third task (task3) includes func3-1, func3-2, func3-3, and func3-4. The multiple functions included in task1, task2, and task3 may be distributed at any position in the image file. By analyzing the program source code through compilation technology, the host can obtain the function dependencies of task1, task2, and task3 respectively. For example, through compiler analysis technology, the following set of function dependencies in units of tasks is obtained:

[0067] {First task: func1-1, func1-2, func1-3, func1-4}

[0068] {Second task: func2-1, func2-2, func2-3, func2-4}

[0069] {Third task: func3-1, func3-2, func3-3, func3-4}

[0070] Compilation technology is the technology of translating program codes written in high-level computer languages ​​into binary machine language codes that can be run by computers. The methods of obtaining the functional dependencies of tasks through compilation technology in the prior art and the methods of obtaining the functional dependencies of tasks through other means can be adopted in this application.

[0071] It should be noted that in this application, the "host" is sometimes referred to as the "development and compilation device of the embedded device" or the "image file acquisition device". When the difference between the three is not specifically emphasized, technicians in this field should understand that the three have the same meaning.

[0072] The time required to load a task is similar to the method for obtaining the time required to execute a task, that is, multiple differences between the first timestamp and the second timestamp can be obtained by loading the task multiple times, and the average value of the differences between the multiple first timestamps and the second timestamp can be regarded as the time required to load and execute a task.

[0073] In addition to obtaining the time required to execute a task through testing as mentioned above, in a specific implementation, the execution time and loading time can also be calculated. For example, the functions included in each task can be determined based on the dependency of each of the N tasks determined by the host. The sum of the execution time required for all functions included in each task is the execution time, and the sum of the loading time required for all functions included in each task is the loading time.

[0074] 502. Sort the N tasks in descending order according to the first value.

[0075] When the first value is the execution time, the host can sort the N tasks from long to short according to the execution time. For example, N is 3, and the N tasks are task1, task2, and task3. Assume that the host determines that T1 is greater than T2 and T3, and T2 is greater than T3 according to the execution time, where T1 represents the execution time of task1, T2 represents the execution time of task2, and T3 represents the execution time of task3. Because T1>T2>T3, the order of the N tasks is task1 first, task2 second, and task3 last.

[0076] When the first value is the time ratio, the host can sort the N tasks from large to small according to the time ratio. For example, N is 3, the N tasks are task1, task2 and task3, T1 represents the execution time of task1, T2 represents the execution time of task2, T3 represents the execution time of task3, t1 represents the loading time of task1, t2 represents the loading time of task2, and t3 represents the loading time of task3. Assuming that the host determines that T1 / t1 is greater than T2 / t2 and T3 / t3, and T3 / t3 is greater than T2 / t2, because T1 / t1>T3 / t3>T2 / t2, the order of the N tasks is task1 first, task3 second, and task2 last.

[0077] 503. Link the sorted N tasks to obtain the image file.

[0078] The function dependency of each task in the N tasks is obtained, where the function dependency of each task is the calling relationship between the functions included in each task in the N tasks, and the functions included in each task in the sorted N tasks are linked according to the function dependency of each task in the N tasks to obtain the image file.

[0079] The function dependency is determined, that is, the functions included in each task are determined. The configuration file composed of the functions included in each task is called a link script file. These link script files are used in the linking process. According to the sorting rules of the N tasks determined in steps 501 and 502, the functions included in each of the N tasks are linked to the image file according to this sorting rule to generate an image file.

[0080] pass Figure 5 It can be seen from the corresponding embodiments that by sorting N tasks from long to short according to execution time, or sorting them from large to small according to time ratio, and linking the N tasks according to the sorting of the N tasks to generate an image file, the embedded device can first load the task with a longer execution time after downloading the image file, so that the next task can be loaded during the execution of the previous task, or the embedded device can first load the task with a short loading time after downloading the image file, so that the total time required to complete the loading of the N tasks can be guaranteed to be the shortest, thereby shortening the time required to load the image file.

[0081] Depend on Figure 5 It can be seen from the corresponding embodiment that it is necessary to obtain the functional dependency of each of the N tasks in the program source code, sort the N tasks from large to small according to the first numerical value, and link the N tasks according to the sorting to generate an image file. The following explains how to select N tasks in the program source code.

[0082] like Figure 6 The figure is a flow chart of a method for obtaining an image file provided in an embodiment of the present application.

[0083] like Figure 6 As shown, a method for obtaining an image file may include the following steps:

[0084] 601. Divide the program source code, where the divided program source code includes program source code corresponding to N tasks and program source code corresponding to M tasks.

[0085] N tasks correspond to the key services of the embedded device, and M tasks correspond to the remaining services in the embedded device except the key services. For example, when the target machine is a driving recorder, its key services may be video recording services and wireless connection services. The program source code may also include other tasks, such as Bluetooth services and camera services. Bluetooth services and camera services are the remaining tasks except the key tasks. In this solution, it is possible to determine which tasks among the multiple tasks included in the program source code are key tasks, namely the N tasks mentioned above, according to the needs of the actual application.

[0086] 602. Obtain the functional dependency of each of N tasks in the program source code, where N is a positive integer.

[0087] The host analyzes the program source code through compilation technology to obtain the functional dependencies of all tasks in the program source code. Specifically, the syntax tree information of all tasks in the program source code can be obtained through compilation technology, and the functional dependencies of all tasks in the program source code can be obtained according to the syntax tree information of all tasks in the program source code.

[0088] In addition, there may be multiple ways to obtain the functional dependencies of N tasks from the functional dependencies of all tasks. For example, the functional dependencies of N tasks can be obtained according to the annotations in the program source code, or the functions of the N tasks can be obtained according to the running results of the program source code, thereby obtaining the functional dependencies of the N tasks. The following are respectively explained:

[0089] In a specific implementation, if the developer annotates the program source code when writing the program source code, the annotation is used to identify the function of the task, and multiple tasks in the program source code can be distinguished by the annotation. In this method, by extracting the annotation corresponding to the program source code, the function corresponding to each of the multiple tasks included in the program source code is obtained, and by predetermining the function of the key task, each key task can be divided from the program source code according to the annotation, and the functional dependency of each of the N tasks can be obtained according to the annotation and the functional dependency.

[0090] In a specific implementation, the N tasks can also be obtained according to the running results of the program source code. If the developer does not mark the program source code when writing the program source code, the function corresponding to each of the multiple tasks included in the program source code can also be obtained through the running results of the program source code. By predetermining the functions and input conditions of the key tasks, the program source code is run, and each key task can be divided from the program source code according to the running results obtained under the input conditions, that is, the N tasks are obtained, and the functional dependency relationship of each of the N tasks can be obtained according to the running results and the functional dependency relationship of all tasks.

[0091] 603. Determine a first value.

[0092] 604. Sort the N tasks in descending order according to the first value.

[0093] 605. Link the sorted N tasks to obtain the image file.

[0094] Steps 603 to 605 can refer to Figure 5 Steps 502 to 504 in the corresponding embodiment are understood and will not be repeated here.

[0095] After the host compiles and links, the image file can be downloaded from the host to the Flash chip of the target machine. When the target machine starts running, the image file will be loaded from the Flash chip to the memory of the embedded device, that is, the target machine. Figure 7 This chapter introduces the loading process of the target machine startup.

[0096] like Figure 7 The figure is a schematic flow chart of a startup method of an embedded device provided in an embodiment of the present application.

[0097] like Figure 7 As shown, a method for starting an embedded device may include the following steps:

[0098] 701. Load N tasks in the system image file.

[0099] The embedded device loads N tasks in the system image file through the system boot program. Specifically, the system boot program can be modified so that the system boot program first loads the N tasks in the system image file when loading the image file. The N tasks are linked from large to small according to the first value, the first value is the first time required to execute each of the N tasks, or the first value is the ratio of the first time to the second time, the second time is the time required to load each task, and N is a positive integer. For details about N tasks and image files, please refer to Figure 5 and Figure 6The corresponding embodiments can be understood and will not be repeated here.

[0100] 702. Run N tasks.

[0101] When the embedded device supports parallel loading and execution of different tasks, the first task is loaded and then executed. While the first task is running, the next task can be loaded. The next task may be the second task, for example. The first task and the second task may be any two adjacent linked tasks among the N tasks.

[0102] In a specific implementation manner, the method may further include: after running the N tasks, loading one or more tasks included in the image file other than the N tasks in the image file.

[0103] Through the solution provided by the present application, during the startup of the embedded device, not only can the key tasks be loaded and executed first, but the time required to load the key tasks can also be further shortened. This solution sorts the key tasks and links the N tasks after sorting to generate an image file. The next task can be loaded while the previous key task is running, and the loading and execution operations of different tasks are maximized in parallel, ensuring the rapid startup of the embedded device.

[0104] Combine the following Figure 8 The scenario diagram provided by the present application as shown illustrates the solution provided by the embodiment of the present application: the program source code includes all kernel program source codes and all application program source codes. The program source code includes multiple tasks. Assume that the program source code includes multiple tasks, of which four tasks are critical tasks, namely, Task 1, Task 2, Task 3, and Task 4. However, due to the embedded device based on the macro kernel architecture, the kernel program source code and the application program source code may be distributed at any position in the image file. Therefore, the code included in each task, or the function included in each task, may be distributed at any position in the image file, such as Figure 8 In the original image shown in a, block 1 represents the code or function included in task 1, block 2 represents the code included in task 2, block 3 represents the code included in task 3, and block 4 represents the code included in task 4. However, it should be noted that different tasks may share the same code, for example, any block in block 1 may be the same code as any block in block 4. Assuming that this solution Figure 5 and Figure 6 The method described in the corresponding embodiment determines that task 1, task 2, task 3, and task 4 are linked in sequence, and the image file obtained by this solution is Figure 8The modified image file shown in b in the figure. After the host compiles and links, the image file can be downloaded from the host to the Flash chip of the target machine. When the target machine starts running, the image file will be loaded from the Flash chip to the memory of the embedded device, that is, the target machine. When the target machine, that is, the embedded device, is powered on, it will first load Task 1, Task 2, Task 3 and Task 4, as shown in the figure. Figure 8 As shown in c in , when task 1 is loaded, it runs. While task 1 is running, task 2 can be loaded. Since task 1 takes the longest time to execute, subsequent tasks may have been loaded while task 1 is executing. Figure 8 As shown in c, when Task 1 is completed, Task 2 has been loaded and Task 3 has also been partially loaded, ensuring that after Task 1 is completed, subsequent tasks can be loaded and executed as soon as possible, avoiding the situation where Task 1 has been completed but Task 2 has not started loading, or it takes a long time for Task 2 to load. If sorting is performed according to the time ratio, the total time required to load the tasks can be guaranteed to be the shortest. This solution achieves the purpose of quickly starting the embedded device by shortening the loading time of the image file. After running Task 1, Task 2, Task 3 and Task 4, one or more tasks included in the image file other than N tasks can also be loaded according to business needs.

[0105] It is understandable that the above-mentioned developed and compiled devices and embedded devices include hardware structures and / or software modules corresponding to the execution of each function in order to realize the above-mentioned functions. Those skilled in the art should easily realize that, in combination with the modules and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware 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 to be beyond the scope of this application.

[0106] Describing from the hardware structure, Figures 5 to 7 The image file acquisition device and the embedded device can be implemented by one physical device, or by multiple physical devices, or by a logical function module in one physical device, and the embodiment of the present application does not make any specific limitation on this.

[0107] For example, the image file acquisition device can be Fig. 9 This is achieved by the communication equipment in the system. Fig. 9 The hardware structure diagram of the image file acquisition device provided in the embodiment of the present application is shown, which includes: a communication interface 901 and a processor 902 , and may also include a memory 903 .

[0108] The communication interface 901 may use any transceiver or other device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc.

[0109] The processor 902 includes, but is not limited to, one or more of a central processing unit (CPU), a network processor (NP), an application-specific integrated circuit (ASIC), or a programmable logic device (PLD). The above-mentioned PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. The processor 902 is responsible for the communication line 904 and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. The memory 903 can be used to store data used by the processor 902 when performing operations.

[0110] The memory 903 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, an optical disc storage (including a compressed optical disc, a laser disc, an optical disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processor 902 via a communication line 904. The memory 903 may also be integrated with the processor 902. If the memory 903 and the processor 902 are independent devices, the memory 903 and the processor 902 are connected, for example, the memory 903 and the processor 902 can communicate via a communication line. The communication interface 901 and the processor 902 may communicate via a communication line, or the communication interface 901 may be directly connected to the processor 902 .

[0111] The communication line 904 may include any number of interconnected buses and bridges, and the communication line 904 links together various circuits including one or more processors 902 represented by the processor 902 and a memory represented by the memory 903. The communication line 904 may also link together various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are all well known in the art and therefore will not be further described in this application.

[0112] In a specific embodiment, the image file acquisition device may include: a memory for storing computer-readable instructions; and may also include a processor coupled to the memory, executing the computer-readable instructions in the memory to perform the following operations: determining a first value of each of N tasks in a program source code, the first value being a first duration required to execute each of the N tasks, or the first value being a ratio of the first duration to a second duration, the second duration being a duration required to load each of the N tasks, and N being a positive integer; sorting the N tasks from large to small according to the first value; and linking the sorted N tasks to obtain the image file.

[0113] In a specific implementation, the processor is further used to: obtain the function dependency of each of the N tasks, where the function dependency of each task is the calling relationship between the functions that can be included in each of the N tasks; and link the functions that can be included in each of the sorted N tasks according to the function dependency of each of the N tasks to obtain the image file.

[0114] In a specific implementation, the processor is specifically used to: obtain syntax tree information of all tasks in the program source code, where all tasks may include N tasks; obtain functional dependencies of all tasks based on the syntax tree information, where the functional dependencies of all tasks are calling relationships between functions that may be included in all tasks; determine the functional dependencies of each of the N tasks based on the annotations in the program source code and the functional dependencies of all tasks, where the annotations are pre-set and used to identify the functions of the tasks, and the functions of the N tasks are pre-specified.

[0115] In a specific implementation, the processor is also used to: divide the program source code, and the divided program source code may include program source code corresponding to N tasks and program source code corresponding to M tasks, the N tasks correspond to the key business of the embedded device, and the M tasks correspond to the remaining business in the embedded device except the key business.

[0116] In a specific embodiment, the processor is specifically used to: determine the starting position and the ending position of each of the N tasks based on the functional dependency of each of the N tasks, the starting position may include a first timestamp, and the ending position may include a second timestamp; run each of the N tasks, and determine a first value based on the difference between the first timestamp and the second timestamp.

[0117] The embodiment of the present application can divide the functional units of the image file acquisition device according to the above method example. For example, each functional unit can be divided corresponding to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of units in the embodiment of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation.

[0118] For example, when each functional unit is divided in an integrated manner, Fig.10 A structural schematic diagram of a device for acquiring an image file is shown.

[0119] like Fig.10 As shown, the image file acquisition device provided in the embodiment of the present application includes:

[0120] The storage unit 1001 is used to store computer-readable instructions. It can also include a processing unit 1002 coupled to the storage unit 1001, which executes the computer-readable instructions in the storage unit 1001 to perform the following operations: obtain the functional dependency of each of the N tasks in the program source code, where N is a positive integer. Determine a first numerical value, where the first numerical value is the first duration required to execute each of the N tasks, or the first numerical value is the ratio of the first duration to the second duration, where the second duration is the duration required to load each task. Sort the N tasks from large to small according to the first numerical value. Link the N tasks according to the functional dependency and the sorting to generate an image file.

[0121] In a specific implementation, the processing unit 1002 is specifically used to: obtain syntax tree information of all tasks of the program source code. Obtain functional dependencies of all tasks in the program source code based on the syntax tree information of all tasks. Determine the functional dependencies of each of the N tasks based on the annotations in the program source code and the functional dependencies of all tasks, the annotations are pre-set and used to identify the functions of the tasks, and the functions of the N tasks are pre-defined.

[0122] In a specific implementation, the processing unit 1002 is also used to: divide the program source code, and the divided program source code may include program source code corresponding to N tasks and program source code corresponding to M tasks, the N tasks correspond to the key business of the embedded device, and the M tasks correspond to the remaining business in the embedded device except the key business.

[0123] In a specific implementation, the processing unit 1002 is specifically configured to: determine the starting position and the ending position of each of the N tasks according to the functional dependency of each of the N tasks, where the starting position may include a first timestamp and the ending position may include a second timestamp; run each of the N tasks, and determine the first value according to the difference between the first timestamp and the second timestamp.

[0124] For example, each functional unit is divided according to each function. Fig.11 A structural schematic diagram of a device for acquiring an image file is shown.

[0125] like Fig.11 As shown, the image file acquisition device provided in the embodiment of the present application includes:

[0126] The compilation and analysis module 1101 is used to obtain the functional dependency of each of N tasks in the program source code, where N is a positive integer.

[0127] The task sorting analysis module 1102 is used to determine a first value, where the first value is a first duration required to execute each of the N tasks, or the first value is a ratio of the first duration to a second duration, where the second duration is a duration required to load each task, and sort the N tasks from large to small according to the first value.

[0128] The task linking module 1103 is used to link the functions included in each of the sorted N tasks according to the function dependency relationship of each of the N tasks to generate an image file.

[0129] In a specific implementation, the compilation analysis module 1101 includes a syntax tree analysis unit 11011 and a function dependency analysis unit 11012. The syntax tree analysis unit 11011 is used to obtain syntax tree information of all tasks in the program source code of the image file. The function dependency analysis unit 11012 is used to obtain the function dependency of all tasks in the program source code according to the syntax tree information of all tasks, and determine the function dependency of each of the N tasks according to the annotations in the program source code and the function dependency of all tasks, the annotations are pre-set and used to identify the function of the task, and the functions of the N tasks are pre-specified.

[0130] In a specific implementation, the task sorting analysis module 1102 includes a calculation unit 11021 and a sorting unit 11022. The calculation unit 11021 is used to determine the starting position and the ending position of each of the N tasks according to the functional dependency of each of the N tasks. The starting position may include a first timestamp, and the ending position may include a second timestamp. Each of the N tasks is run, and a first value is determined according to the difference between the first timestamp and the second timestamp. The sorting unit 11022 is used to sort the N tasks from large to small according to the first value.

[0131] In addition, embedded devices can Fig.12 This is achieved by the communication equipment in the system. Fig.12 The hardware structure diagram of the embedded device provided in the embodiment of the present application is shown, which includes: a communication interface 1201 and a processor 1202 , and may also include a memory 1203 .

[0132] The communication interface 1201 may use any transceiver or other device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc.

[0133] The processor 1202 includes, but is not limited to, one or more of a central processing unit (CPU), a network processor (NP), an application-specific integrated circuit (ASIC), or a programmable logic device (PLD). The above-mentioned PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. The processor 1202 is responsible for the communication line 1204 and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. The memory 1203 can be used to store data used by the processor 1202 when performing operations.

[0134] The memory 1203 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processor 1202 via a communication line 1204. The memory 1203 may also be integrated with the processor 1202. If the memory 1203 and the processor 1202 are independent devices, the memory 1203 and the processor 1202 are connected, for example, the memory 1203 and the processor 1202 can communicate through a communication line. The communication interface 1201 and the processor 1202 can communicate through a communication line, and the communication interface 1201 can also be directly connected to the processor 1202.

[0135] The communication line 1204 may include any number of interconnected buses and bridges, and the communication line 1204 links together various circuits including one or more processors 1202 represented by the processor 1202 and a memory represented by the memory 1203. The communication line 1204 may also link together various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are all well known in the art and therefore will not be further described in this application.

[0136] In a specific implementation, the embedded device may include: a memory for storing computer-readable instructions. It may also include a processor coupled to the memory, executing the computer-readable instructions in the memory to perform the following operations: loading N tasks in the system image file and running the N tasks, the N tasks are linked from large to small according to a first value, the first value is a first duration required to execute each of the N tasks, or the first value is a ratio of the first duration to the second duration, the second duration is the duration required to load each task, and N is a positive integer.

[0137] In a specific implementation, the processor is further configured to: after running the N tasks, load one or more tasks that may be included in the image file other than the N tasks in the image file.

[0138] The embodiment of the present application can divide the functional units of the embedded device according to the above method example. For example, each functional unit can be divided according to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of units in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0139] For example, when each functional unit is divided in an integrated manner, Fig.13 A structural schematic diagram of an embedded device is shown.

[0140] like Fig.13 As shown, the embedded device provided by the embodiment of the present application includes: a storage unit 1301 for storing computer-readable instructions. It can also include a processing unit 1302 coupled to the storage unit 1301, which executes the computer-readable instructions in the storage unit 1301 to perform the following operations: load N tasks in the system image file and run the N tasks, the N tasks are linked from large to small according to a first value, the first value is the first duration required to execute each of the N tasks, or the first value is the ratio of the first duration to the second duration, the second duration is the duration required to load each task, and N is a positive integer.

[0141] In a specific implementation, the processing unit 1302 is further configured to: after running N tasks, load one or more tasks that may be included in the image file other than the N tasks in the image file.

[0142] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0143] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0144] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the relevant hardware through a program, and the program can be stored in a computer-readable storage medium, which can include: ROM, RAM, disk or CD, etc.

[0145] The above is a detailed introduction to the image file method, embedded device startup method, image file acquisition device and embedded device provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technicians in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for obtaining an image file, characterized in that: include: Determine a first value of each of N tasks in the program source code, wherein the N tasks are tasks in a startup process of the embedded device, the first value is a first duration required to execute each of the N tasks, or the first value is a ratio of the first duration to a second duration, the second duration is a duration required to load each of the N tasks, and N is a positive integer; sorting the N tasks from large to small according to the first value; The N sorted tasks are linked to obtain an image file, so that the embedded device executes the N sorted tasks after downloading the image file, and while the previous task is being executed, the embedded device loads the next task, or the task whose loading time is shorter than the execution time is loaded by the embedded device first.

2. The method for obtaining an image file according to claim 1, characterized in that: The method further comprises: Acquire a function dependency relationship of each of the N tasks, where the function dependency relationship of each task is a call relationship between functions included in each of the N tasks; The linking of the sorted N tasks to obtain the image file includes: According to the functional dependency relationship of each of the N tasks, the functions included in each of the sorted N tasks are linked to obtain an image file.

3. The method according to claim 2, characterized in that The obtaining of the functional dependency of each of the N tasks includes: Obtaining syntax tree information of all tasks in the program source code, wherein the all tasks include the N tasks; Acquire the functional dependency relationship of all the tasks according to the syntax tree information, where the functional dependency relationship of all the tasks is the calling relationship between the functions included in all the tasks; The functional dependency of each of the N tasks is determined according to the annotations in the program source code and the functional dependency of all the tasks, wherein the annotations are preset and used to identify the functions of the tasks, and the functions of the N tasks are predetermined.

4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: The program source code is divided, wherein the divided program source code includes program source code corresponding to the N tasks and program source code corresponding to M tasks, wherein the N tasks correspond to key businesses of the embedded device, and the M tasks correspond to other businesses in the embedded device except the key businesses.

5. The method according to any one of claims 1 to 4, characterized in that: The step of determining a first value of each of N tasks in the program source code includes: Determine a starting position and an ending position of each of the N tasks according to a functional dependency relationship of each of the N tasks, wherein the starting position includes a first timestamp and the ending position includes a second timestamp; Run each of the N tasks, and determine the first value according to a difference between the first timestamp and the second timestamp.

6. A method for starting an embedded device, characterized in that: include: Load N tasks in a system image file and run the N tasks, wherein the N tasks are tasks in a startup process of an embedded device, and the N tasks are linked from large to small according to a first value, wherein the first value is a first duration required to execute each of the N tasks, or the first value is a ratio of the first duration to a second duration, and the second duration is a duration required to load each of the N tasks, wherein N is a positive integer, and the next task is loaded while the previous task is being executed, or a task whose loading time is shorter than its execution time is loaded first.

7. The startup method according to claim 6, characterized in that: Also includes: After the N tasks are run, one or more tasks included in the image file other than the N tasks are loaded.

8. A device for obtaining an image file, characterized in that: include: a memory for storing computer readable instructions; Also included is a processor coupled to the memory, executing computer readable instructions in the memory to perform the following operations: Determine a first value of each of N tasks in the program source code, wherein the N tasks are tasks in a startup process of the embedded device, the first value is a first duration required to execute each of the N tasks, or the first value is a ratio of the first duration to a second duration, the second duration is a duration required to load each of the N tasks, and N is a positive integer; sorting the N tasks from large to small according to the first value; The N sorted tasks are linked to obtain an image file, so that the embedded device executes the N sorted tasks after downloading the image file, and while the previous task is being executed, the embedded device loads the next task, or the task whose loading time is shorter than the execution time is loaded by the embedded device first.

9. The device according to claim 8, characterized in that The processor is further configured to: Acquire a function dependency relationship of each of the N tasks, where the function dependency relationship of each task is a call relationship between functions included in each of the N tasks; According to the functional dependency relationship of each of the N tasks, the functions included in each of the sorted N tasks are linked to obtain an image file.

10. The device according to claim 9, characterized in that The processor is specifically used for: Obtaining syntax tree information of all tasks in the program source code, wherein the all tasks include the N tasks; Acquire the functional dependency relationship of all the tasks according to the syntax tree information, where the functional dependency relationship of all the tasks is the calling relationship between the functions included in all the tasks; The functional dependency of each of the N tasks is determined according to the annotations in the program source code and the functional dependency of all the tasks, wherein the annotations are preset and used to identify the functions of the tasks, and the functions of the N tasks are predetermined.

11. The device according to any one of claims 8 to 10, characterized in that The processor is further configured to: The program source code is divided, wherein the divided program source code includes program source code corresponding to the N tasks and program source code corresponding to M tasks, wherein the N tasks correspond to key businesses of the embedded device, and the M tasks correspond to remaining businesses in the embedded device except the key businesses.

12. The device according to any one of claims 8 to 11, characterized in that The processor is specifically used for: Determine a starting position and an ending position of each of the N tasks according to a functional dependency relationship of each of the N tasks, wherein the starting position includes a first timestamp and the ending position includes a second timestamp; Run each of the N tasks, and determine the first value according to a difference between the first timestamp and the second timestamp.

13. An embedded device, characterized in that: include: a memory for storing computer readable instructions; Also included is a processor coupled to the memory, executing computer readable instructions in the memory to perform the following operations: Load N tasks in a system image file and run the N tasks, wherein the N tasks are tasks in a startup process of an embedded device, and the N tasks are linked from large to small according to a first value, wherein the first value is a first duration required to execute each of the N tasks, or the first value is a ratio of the first duration to a second duration, and the second duration is a duration required to load each of the N tasks, wherein N is a positive integer, and the next task is loaded while the previous task is being executed, or a task whose loading time is shorter than its execution time is loaded first.

14. The embedded device according to claim 13, characterized in that: The processor is further configured to: After the N tasks are run, one or more tasks included in the image file other than the N tasks are loaded.

15. A computer-readable storage medium, characterized in that: When the instructions are executed on a computer device, the computer device is caused to perform the method according to any one of claims 1 to 5.

16. A computer-readable storage medium, characterized in that: When the instructions are executed on a computer device, the computer device is caused to execute the method according to claim 6 or 7.

Citation Information

Patent Citations

  • Starting method and starting device of embedded type device

    CN105760201A

  • Obfuscating Execution Traces of Computer Program Code

    US20100262839A1

  • System and method for dynamically loading a webpage

    US20140280719A1