Code file loading method and device and storage medium
By loading code files in parallel according to the priority of code files, the problem of slow code files loading speed is solved, the software startup and running speed is improved, and efficient code file loading is achieved.
Patent Information
- Application Number
- CN202310802893.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-30
- Publication Date
- 2024-12-31
AI Technical Summary
In the prior art, the code file loading speed is slow, which affects the software startup and operation speed. In addition, traditional serial loading methods cannot effectively load important code files, resulting in low efficiency.
By obtaining the priority of the code file, determining the target code file collection, loading the code file into memory in parallel, and using the interface without mutex locks for parallel loading, ensuring that multiple code files are loaded in parallel when there is sufficient computing resources, and writing code in serial File information table.
It improves the loading speed of code files, improves the startup and running speed of software, avoids long waits for traditional serial loading, and improves loading efficiency.
Smart Images

Figure CN119225838A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, system and storage medium for loading a code file. Background Art
[0002] With the development of computer technology, the volume of software is getting larger and larger. In some implementations, in order to facilitate the maintenance and management of the software code, the software can be optimized based on code modularization technology. Code modularization is to implement the functions of a program through multiple independent and reusable code files. In other words, a program may consist of multiple code files. Through code modularization technology, complex software code can be decomposed into multiple simple, easy-to-maintain and expandable code files, thereby improving the readability, maintainability and reusability of the code.
[0003] During the process of software startup or software running, it may be necessary to load the code file into the memory. The speed of loading the code file may affect the speed of software startup or running. Summary of the invention
[0004] In order to solve the problems of the prior art, the present application provides a method and device for loading a code file.
[0005] In a first aspect, the present application provides a method for loading a code file, the method comprising:
[0006] Obtain multiple code files to be loaded corresponding to the target software;
[0007] Determine a target code file set according to the priorities of the multiple code files, wherein the target code file set includes multiple target code files, and the multiple target code files have the same priority;
[0008] The plurality of object code files are loaded into the memory in parallel.
[0009] In some possible implementations, loading the multiple object code files into the memory in parallel includes:
[0010] Calling a preset interface, wherein the preset interface does not include a mutex lock, and the mutex lock is used for serially loading code files;
[0011] The multiple target code files are loaded into the memory in parallel through the preset interface.
[0012] In some possible implementations, before calling the preset interface, the method further includes:
[0013] The code of the target software is parsed, and the code of the preset interface is obtained and loaded.
[0014] In some possible implementations, the method further includes:
[0015] Acquire attribute information of each of the code files, wherein the attribute information of the code files includes information on the priority of the code files;
[0016] Determining the position of each of the code files in the code file queue according to the priority of the code files;
[0017] Determining the target code file set includes:
[0018] The target code file is determined from the head of the code file queue.
[0019] In some possible implementations, the target software is run on the first device, and before the multiple target code files are loaded into the memory in parallel, the method further includes:
[0020] Obtaining the remaining computing resources of the first device;
[0021] Determine whether the remaining computing resource amount is greater than a preset resource threshold.
[0022] In some possible implementations, after the multiple object code files are loaded, the method further includes:
[0023] The code file information of the plurality of target code files is serially written into a code file information table, wherein the code file information is obtained after the target code files are loaded.
[0024] In some possible implementations, the multiple code files to be loaded corresponding to the target software include shared object (so) library files.
[0025] In a second aspect, the present application provides a device for loading a code file, the device comprising: an acquisition unit, configured to acquire a plurality of code files to be loaded corresponding to a target software; a determination unit, configured to determine a target code file set according to the priorities of the plurality of code files, the target code file set comprising a plurality of target code files, the plurality of target code files having the same priority; and a loading unit, configured to load the plurality of target code files into a memory in parallel.
[0026] In some possible implementations, the loading unit is specifically used to call a preset interface, the preset interface does not include a mutex lock, and the mutex lock is used to serially load code files; and the multiple target code files are loaded into the memory in parallel through the preset interface.
[0027] In some possible implementations, the acquisition unit is further configured to parse the code of the target software, and acquire and load the code of the preset interface.
[0028] In some possible implementations, the acquisition unit is further configured to acquire attribute information of each of the code files, wherein the attribute information of the code files includes information of the priority of the code files. The determination unit is specifically configured to determine the position of each of the code files in the code file queue according to the priority of the code files; and determine the target code file from the head of the code file queue.
[0029] In some possible implementations, the target software runs on a first device. The acquisition unit is further configured to acquire a remaining amount of computing resources of the first device. The determination unit is further configured to determine that the remaining amount of computing resources is greater than a preset resource threshold.
[0030] In some possible implementations, the device further includes an information writing unit, which is specifically used to serially write the code file information of the multiple target code files into a code file information table, where the code file information is obtained after the target code files are loaded.
[0031] In some possible implementations, the multiple code files to be loaded corresponding to the target software include so library files.
[0032] In a third aspect, the present application provides an electronic device, including:
[0033] one or more processors;
[0034] a storage device having one or more programs stored thereon,
[0035] When the one or more programs are executed by the one or more processors, the one or more processors implement any method described in the first aspect.
[0036] In a fourth aspect, the present application provides a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, any method described in the first aspect is implemented.
[0037] In a fifth aspect, the present application provides a computer program product, which, when executed on a device, enables the device to execute the method described in the first aspect.
[0038] It can be seen that this application has the following beneficial effects:
[0039] Embodiments of the present application provide a method, device, and storage medium for loading code files. Specifically, when loading the code files corresponding to the target software, multiple code files to be loaded can be obtained first. Then, a target code file set can be determined based on the priority of the code file. The target code file set includes multiple target code files, and the priority of any two target code files is the same. After the target code file set is determined, multiple target code files can be loaded into the memory in parallel. In this way, multiple code files with the same priority can be loaded in parallel in one loading, without loading the code files of the target software one by one. In this way, by loading the target code files into the memory in parallel, the loading speed of the code files is improved, and the startup speed and running speed of the software are also improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0041] Figure 1 A flowchart of a method for loading a code file provided in an embodiment of the present application;
[0042] Figure 2 A schematic diagram of a code file loading device provided in an embodiment of the present application;
[0043] Figure 3 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be construed as being limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present application. It should be understood that the drawings and embodiments of the present application are only for exemplary purposes and are not intended to limit the scope of protection of the present application.
[0045] It should be understood that the various steps described in the method implementation of the present application can be performed in different orders and / or performed in parallel. In addition, the method implementation may include additional steps and / or omit the steps shown. The scope of the present application is not limited in this respect.
[0046] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0047] It should be noted that the concepts such as "first" and "second" mentioned in this application are only used to distinguish different objects, devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0048] It should be noted that the modifications of "one" and "plurality" mentioned in the present application are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0049] Based on code modularization technology, a complex software code can be split into multiple code files. The size of each code file will be smaller than the size of the original software code. In this way, a large code can be split into smaller code files, which is convenient for code management and modification. Therefore, as the amount of software code is getting larger and larger, code modularization technology is also being used more and more widely.
[0050] For software running on a device, before the software runs, the code corresponding to the software can be stored in a storage module of the device, for example, in the hard disk of the device. After the software is started, the code stored in the storage module can be loaded into the memory of the device so that the processor of the device reads the code from the memory and executes the corresponding method according to the code. Optionally, if the code stored in the storage module cannot be directly executed by the processor, the code can be compiled when the code is loaded into the memory to ensure that the code in the memory can be read and executed by the processor.
[0051] If the software includes multiple code files, one or more code files can be loaded from the storage device to the memory during the software startup process or during the software running process. Specifically, all code files corresponding to the software can be loaded into the memory during the software startup process. Alternatively, part of the code files corresponding to the software can be loaded during the software startup process. During the software running process, if a method corresponding to a code file needs to be run, the code file can be loaded into the memory.
[0052] At present, code files are mostly loaded in a serial manner to ensure the security of the code files. For example, in some possible implementations, the code files can be loaded into the memory through threads including mutual exclusion (mutex) locks. Since the thread has a mutual exclusion lock, the thread can only load one code file into the memory at the same time. In this way, only one code file is loaded into the memory at the same time, ensuring the stability and security of the code file.
[0053] However, if there are multiple code files that need to be loaded into the memory, the traditional serial loading solution may take too long. Specifically, because the code file can only be executed by the processor after it is loaded into the memory. Then, before the code file is loaded into the memory, the software cannot perform corresponding operations according to the code in the code file. Therefore, the longer time to load the code file may extend the time the software is in a waiting state. In this way, the user experience may be significantly reduced.
[0054] In addition, when loading code files serially, they are loaded according to the order of the code files, for example, the code files can be loaded according to the order of the first letters of the code files, or the code files can be loaded according to the time when the code files were created. However, this method of loading code files is not targeted and cannot load more important code files, resulting in low efficiency in loading code files.
[0055] In order to solve the problems of the prior art, an embodiment of the present application provides a method for loading a code file, which is described in detail below in conjunction with the drawings in the specification.
[0056] The above briefly introduces the application scenario of the method for loading code files provided in the embodiment of the present application. Figure 1 The method of loading code files is further introduced.
[0057] See also Figure 1 , Figure 1 An information interaction diagram of a method for loading a code file provided in an embodiment of the present application, the embodiment of the present application can be applied to an application scenario in which the code file of the target software is loaded into the memory. Among them, the target software is software pre-installed on the device and can be run on the device. The device can be a terminal device, for example, a mobile terminal device such as a mobile phone, or a terminal device such as a personal computer. Optionally, the target software includes multiple code files. Before the code file is loaded into the memory, the code file can be stored in the storage device of the device. In addition, the code file can be directly read by the processor, or it can be compiled into a format that can be directly read by the processor when it is loaded into the memory.
[0058] In the embodiment of the present application, the method for loading a code file may be executed by a code file loading device, which may be implemented by software. Optionally, the code file loading device may be software running on a device, for example, an operating system of the device, for compiling a method in the software running on the device. Figure 1 As shown, the method specifically comprises the following steps:
[0059] S101: Acquire multiple code files to be loaded corresponding to the target software.
[0060] When a code file needs to be loaded into the memory, a plurality of code files to be loaded corresponding to the target code file may be first obtained. The plurality of code files to be loaded may include code files in a software package corresponding to the target software, or may include code files corresponding to the operating system. If the code files to be loaded include code files corresponding to the operating system, then the code files may be called by the target software.
[0061] In some possible implementations, code files can be loaded during the startup of the target software. Accordingly, after obtaining the startup instruction for the target software, the code files to be loaded can be determined, and then the code files to be loaded can be loaded. Among them, the code files to be loaded can be all the code files corresponding to the target software, or they can be part of the code files corresponding to the target software. If the code files to be loaded are part of the code files corresponding to the target software, then the code files to be loaded may include the code files required during the startup of the target software, and may also include the code files corresponding to the methods that the target software may call after startup, and may also include more important code files in the target software. Among them, more important code files refer to more important methods corresponding to the code files. For example, the method being more important may include that the frequency of the method being called is greater than a preset frequency threshold, or the method is a method in the main process of the target software.
[0062] In some other possible implementations, the code file may also be loaded during the running of the target software. Accordingly, the loading of the code file may be triggered during the running of the target software. For example, if the running of the target software requires calling method A, and the code file corresponding to method A has not been loaded into the memory, then the loading of the code file corresponding to method A into the memory may be triggered.
[0063] In some possible implementations, different software may also use the same code file. A code file that can be used by multiple software may be referred to as a shared code file. Optionally, a shared code file may be deployed in the code of an operating system or in software. Specifically, if a shared code file is deployed in the code of an operating system, any software running on the operating system may call the shared code file. Alternatively, if a shared code file is deployed in the code of a software, although different software may not be able to implement cross-software calls, when developing software, the shared code files of other software may be used as the shared code files of the software, thereby reducing the time required for software development.
[0064] Optionally, the shared code file may include a so library file. A so library file is a reusable binary code library file, and the binary code in the so library file can be called by multiple files. Accordingly, the so library file may include a system so library file and a software so library file. Among them, the system so library file is an so library file integrated in the system operating system, and different software can call the same system so library file during operation. The software so library file is integrated in the code of the software. The software can call its corresponding so library file during operation, and the software so library files included in different software may be the same. In an embodiment of the present application, the code file may include a software so library file, and may also include a system so library file.
[0065] S102: Determine a target code file set according to the priorities of the plurality of code files.
[0066] After obtaining multiple code files to be loaded, a target code file set can be determined according to the priority of the code files. The target code file set includes multiple target code files. Any two target code files among the multiple target code files have the same priority, and the priority of the target code file is higher than that of the non-target code files among the multiple code files. That is, after obtaining multiple code files, multiple code files with the highest priority among the multiple code files can be determined as target code files to determine the target code file set.
[0067] In the embodiment of the present application, the priority of the code file is used to indicate the order in which the code file is loaded into the memory. That is, the higher the priority of the code file, the earlier it is loaded into the memory. The time when the code file with a low priority is loaded into the memory is later than the code file with a high priority. In other words, the target code file is the code file that needs to be loaded into the memory first among multiple code files to be loaded.
[0068] In some possible implementations, the priority of the code file may be attribute information of the code file. Specifically, a technician who writes the code file may determine the priority of the code file during the process of writing the code file, and write the priority of the code file into the attribute information of the code file. Accordingly, after the code file to be loaded is obtained, the priority of the code file may be determined from the attribute information of the code file.
[0069] In some other possible implementations, the priority of a code file can be determined based on the situation in which the code file is loaded, and / or the situation in which the method corresponding to the code file is called. For example, during the operation of the target software, the time when the code file is loaded, and / or the frequency with which the method corresponding to the code file is called can be recorded. The earlier the code file is loaded, the more important the code file is. The more frequently the method corresponding to the code file is called, the more important the code file is. In this way, the priority of the code file can be determined based on the situation in which the code file is loaded, and / or the situation in which the method corresponding to the code file is called.
[0070] In an embodiment of the present application, a target code file set can be determined based on a queue. Specifically, after obtaining multiple code files to be loaded, multiple code files (or identifiers of code files) can be added to a code file queue based on the priority of the code files. A code file queue is a pre-created queue for accommodating code files (or identifiers of code files). The higher the priority of a code file, the closer the code file (or identifier of a code file) is to the head of the code file queue. In this way, after multiple code files are added to the code file queue, the code file corresponding to the head of the code file queue is the queue with the highest priority among all code files.
[0071] Accordingly, when determining the target code file set, the code file corresponding to the head of the code file queue can first be determined as the target code file. Then, the target code file (or the identifier of the target code file) can be deleted from the code file queue, and the priority of the new code file corresponding to the head of the code file queue is determined to be the same as the priority of the target code file. If they are the same, the new code file can be determined as the target code file. If they are different, the determination of the target code file is stopped, and the code file that has been determined as the target code file is loaded into the memory.
[0072] S103: Load multiple target code files into the memory in parallel.
[0073] After determining the target code file set, the target code files in the target code file set can be loaded into the memory. Specifically, if the target code file set includes multiple target code files, the multiple target code files can be loaded into the memory in parallel. Alternatively, if the target code file set includes only one target code file, the target code file can be loaded into the memory. For ease of introduction, the following is an example of a target code file set including multiple target code files.
[0074] If the target code file set includes multiple target code files, then the multiple target code files can be loaded into the memory in parallel. Wherein, parallel loading refers to loading multiple target code files at the same time. Optionally, when loading target code files in parallel, all target code files in the target code file set can be loaded in parallel, or some target code files in the target code file set can be loaded in parallel.
[0075] Loading code files requires consumption of computing resources. Therefore, the more target code files loaded in parallel, the greater the amount of computing resources required. To this end, in an embodiment of the present application, before loading the target code files in parallel, the amount of available resources can be determined first. Specifically, if the target software is software running on a first device, then before loading multiple target code files in parallel, the remaining amount of computing resources of the first device can be obtained first. Among them, the remaining amount of computing resources of the first device refers to the computing resources that can be called by the thread for loading the target code file. Optionally, the remaining amount of computing resources of the first device can be the amount of all computing resources that are not occupied by the first device, or it can be the amount of resources allocated by the first device to the thread for loading the target code file. Among them, the computing resources can include, for example, the computing resources of a central processing unit (CPU), and can also include memory resources.
[0076] After obtaining the remaining computing resources of the first device, it can be determined whether the remaining computing resources of the first device can meet the demand of loading multiple target code files in parallel. If the remaining computing resources of the first device can meet the demand of loading multiple target code files in parallel, then the multiple target code files can continue to be loaded in parallel. If the remaining computing resources of the first device cannot meet the demand of loading multiple target code files in parallel, then the multiple target code files can be loaded in series.
[0077] As a possible implementation, the remaining computing resources of the first device may be compared with a preset resource threshold. If the remaining computing resources of the first device are greater than the preset resource threshold, it may be determined that the remaining computing resources of the first device can meet the requirements of loading multiple target code files in parallel. If the remaining computing resources of the first device are less than or equal to the preset resource threshold, it may be determined that the remaining computing resources of the first device cannot meet the requirements of loading multiple target code files in parallel.
[0078] Optionally, the preset resource threshold may be a preset resource amount threshold, which is determined based on the amount of computing resources required when loading multiple code files in parallel. Alternatively, the preset resource threshold may also be determined based on the number of target code files. For example, the amount of computing resources required when loading a code file may be predetermined, and then the preset resource threshold may be determined based on the number of target code files. Optionally, if the remaining amount of computing resources of the first device is less than the preset resource threshold, and the remaining amount of computing resources of the first device is greater than the amount of computing resources required for loading two code files in parallel, then multiple target code files may also be loaded in parallel. And the number of target code files loaded each time is determined based on the remaining amount of computing resources of the first device.
[0079] According to the previous introduction, in order to ensure the integrity of the code file, the code file can be loaded into the memory through a thread including a mutex lock. However, the mutex lock will limit the ability of parallel loading. For example, the code file can be loaded into the memory through the dynamic link library open (dynamic linker open, dlopen) thread. The dlopen thread includes a mutex lock. The mutex lock is used to limit the dlopen thread to load only one code file into the memory at a time.
[0080] If the target code file is loaded into the memory through a traditional thread, the target code file cannot be written in parallel due to the influence of the mutex lock. Therefore, in an embodiment of the present application, the target code file can be loaded into the memory through a thread that does not include a mutex lock. Specifically, the thread that loads the target code file can call a preset interface. The preset interface is a pre-set interface that does not include a mutex lock. By calling the preset interface, the code file can be loaded without using a mutex lock, thereby loading the target code file into the memory in parallel. Optionally, the preset interface can be an application programming interface (Application Programming Interface, API).
[0081] In some possible implementations, the operating system of the first device may not provide an interface including a mutex lock. Accordingly, in order to realize the parallel loading of the target code file, the code of the target software may include the code of the above-mentioned preset interface. Accordingly, when writing the target software, in order to enable the target code file corresponding to the target software to be loaded into the memory in parallel, the code corresponding to the preset interface may be added to the code of the target software. In other words, the code of the target software may include the code implementation of the preset interface.
[0082] In this way, when the target software is running, the code implementation of the preset interface can be loaded into the memory first. When the target code file needs to be loaded, the thread responsible for loading the target code file can call the preset interface through the code in the memory, thereby loading the target code file in parallel through the preset interface.
[0083] In the technical solution provided by the present application, when loading the code file corresponding to the target software, firstly, a plurality of code files to be loaded can be obtained. Then, a target code file set can be determined according to the priority of the code file. The target code file set includes a plurality of target code files, and the priority of any two target code files is the same. After the target code file set is determined, a plurality of target code files can be loaded into the memory in parallel. In this way, a plurality of code files with the same priority can be loaded in parallel in one loading, without loading the code files of the target software one by one. In this way, by loading the target code files into the memory in parallel, the loading speed of the code files is improved, and the startup speed and running speed of the software are also improved.
[0084] In actual application scenarios, after loading a code file into memory, the loaded code file in memory can be called to implement the functions of the code in the code file. In order to facilitate calling the loaded code file from memory, relevant information of the code file can be recorded in memory for easy search.
[0085] Specifically, a code file information table may be created in the memory. The code file information table is used to record relevant information of the code file that has been loaded into the memory. That is, after the code file is loaded into the memory, the relevant information of the code file may be written into the code file information table. Optionally, the code information table may be implemented by a global variable in the memory.
[0086] The relevant information of the code file may include the identifier of the code file and the address of the code file in the memory. Thus, when a code in a code file needs to be called, the address of the code file in the memory can be found from the code file information table according to the identifier of the code file, so as to find the code file from the corresponding address in the memory.
[0087] For example. Assuming that the code file is a so library file, the above-mentioned code file information table can be called a so list (solist). Specifically, after the target software is running, a global variable can be divided in the memory as solist. After a so library file is loaded into the memory, the relevant information of the so library file can be added to solist. Among them, the relevant information of the so library file may include so information (so information, so info). so info is the header information of the so library file, including the method definition of the so library file, and also includes the corresponding address of the so library file in the memory. In this way, if a so library file that has been loaded into the memory needs to be called during the software running process, the address of the so library file in the memory can be found from solist, so as to obtain the loaded so library file from the memory according to the address.
[0088] As can be seen from the above description, during the operation of the target software, the relevant information of the code file may be written into the code file information table, and other threads or processes may read the relevant information of the code file from the code file information table. In this way, if the relevant information of multiple code files is written into the code file information table at the same time, the information in the code file information table may be confused.
[0089] To this end, in some possible implementations, after the target code file is loaded into the memory, the relevant information of the target code file can be serially written into the code file information table. Specifically, after the target code file is loaded into the memory, the relevant information of the target code file can first be determined according to the target code file in the memory. For example, if the target code file is a so library file, then the so info corresponding to the target code file can be obtained. Then, the relevant information of the target code file can be serially written into the code file information table.
[0090] Optionally, when writing the relevant information of the target code file to the code file information table serially, a thread including a mutex lock can be called to write. In this way, the mutex lock can prevent two data from being written to a file at the same time to realize the serial writing of the relevant information of the target code file.
[0091] The target code file is still taken as an example for explanation. After calling the preset interface to load multiple target code files into the memory, if the target code file X is loaded, the soinfo of the target code file X can be obtained, and the dlopen thread can be called to write the soinfo of the target code file x into the solist in the memory. According to the previous introduction, the dlopen thread is included in the mutex lock. Therefore, through the dlopen thread, only the soinfo of one so library file can be written into solist at a time, which ensures the serial writing of the relevant information of the target code file.
[0092] Based on the method for loading a code file provided in the above method embodiment, the embodiment of the present application also provides a code file loading device, which will be described below in conjunction with the accompanying drawings.
[0093] See also Figure 2 As shown in FIG. 1 , this figure is a schematic diagram of the structure of a code file loading device provided in an embodiment of the present application. Figure 2 As shown, the code file loading device includes an acquisition unit 210, a determination unit 220 and a loading unit 230.
[0094] The acquisition unit 210 is used to acquire multiple code files to be loaded corresponding to the target software. The determination unit 220 is used to determine a target code file set according to the priorities of the multiple code files, wherein the target code file set includes multiple target code files, and the multiple target code files have the same priority. The loading unit 230 is used to load the multiple target code files into the memory in parallel.
[0095] In some possible implementations, the loading unit 230 is specifically used to call a preset interface, the preset interface does not include a mutex lock, and the mutex lock is used to load code files serially; and the multiple target code files are loaded into the memory in parallel through the preset interface.
[0096] In some possible implementations, the acquisition unit 210 is further configured to parse the code of the target software, and acquire and load the code of the preset interface.
[0097] In some possible implementations, the acquisition unit 210 is further configured to acquire attribute information of each of the code files, wherein the attribute information of the code files includes information of the priority of the code files. The determination unit 220 is specifically configured to determine the position of each of the code files in the code file queue according to the priority of the code files; and to determine the target code file from the head of the code file queue.
[0098] In some possible implementations, the target software runs on a first device. The acquisition unit 210 is further configured to acquire the remaining computing resources of the first device. The determination unit is further configured to determine that the remaining computing resources are greater than a preset resource threshold.
[0099] In some possible implementations, the device further includes an information writing unit, which is specifically used to serially write the code file information of the multiple target code files into a code file information table, where the code file information is obtained after the target code files are loaded.
[0100] In some possible implementations, the multiple code files to be loaded corresponding to the target software include so library files.
[0101] Based on the method for loading a code file provided in the above method embodiment, the present application also provides an electronic device, including: one or more processors; a storage device, on which one or more programs are stored, when the one or more programs are executed by the one or more processors, the one or more processors implement the method for loading a code file as described in any of the above embodiments.
[0102] Reference below Figure 3 , which shows a schematic diagram of the structure of an electronic device 300 suitable for implementing an embodiment of the present application. The terminal device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (portable android devices), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs (televisions), desktop computers, etc. The electronic device shown in the figure is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0103] like Figure 3 As shown, the electronic device 300 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage device 308 into a random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device 300 are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0104] Typically, the following devices may be connected to the I / O interface 305: input devices 308 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 308 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 309. The communication devices 309 may allow the electronic device 300 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 3 The electronic device 300 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0105] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 309, or installed from the storage device 308, or installed from the ROM 302. When the computer program is executed by the processing device 301, the above-mentioned functions defined in the method of the embodiment of the present application are executed.
[0106] The electronic device provided in the embodiment of the present application and the method for loading a code file provided in the above embodiment belong to the same inventive concept. For technical details not fully described in this embodiment, reference can be made to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0107] Based on a method for loading a code file provided in the above method embodiment, an embodiment of the present application provides a computer storage medium on which a computer program is stored, wherein when the program is executed by a processor, the method for loading a code file as described in any of the above embodiments is implemented.
[0108] It should be noted that the computer-readable medium mentioned above in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0109] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0110] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0111] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method for loading the code file.
[0112] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0113] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0114] The units involved in the embodiments described in this application may be implemented by software or hardware. The name of a unit / module does not limit the unit itself in some cases. For example, a voice data acquisition module may also be described as a "data acquisition module".
[0115] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0116] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0117] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0118] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0119] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0120] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for loading a code file, characterized in that: The method comprises: Obtain multiple code files to be loaded corresponding to the target software; Determining a target code file set according to the priorities of the multiple code files, the target code file set comprising multiple target code files, and the multiple target code files have the same priority; The plurality of object code files are loaded into the memory in parallel.
2. The method according to claim 1, characterized in that The loading of the plurality of target code files into the memory in parallel comprises: Calling a preset interface, wherein the preset interface does not include a mutex lock, and the mutex lock is used for serially loading code files; The multiple object code files are loaded into the memory in parallel through the preset interface.
3. The method according to claim 2, characterized in that Before calling the preset interface, the method further includes: The code of the target software is parsed, and the code of the preset interface is obtained and loaded.
4. The method according to claim 1, characterized in that: The method further comprises: Acquire attribute information of each of the code files, wherein the attribute information of the code files includes information on the priority of the code files; Determining the position of each of the code files in the code file queue according to the priority of the code files; Determining the target code file set includes: The target code file is determined from the head of the code file queue.
5. The method according to claim 1, characterized in that The target software is run on the first device, and before the multiple target code files are loaded into the memory in parallel, the method further includes: Obtaining the remaining computing resources of the first device; Determine whether the remaining computing resource amount is greater than a preset resource threshold.
6. The method according to claim 1, characterized in that After loading the multiple target code files, the method further includes: The code file information of the plurality of target code files is serially written into a code file information table, wherein the code file information is obtained after the target code files are loaded.
7. The method according to any one of claims 1 to 6, characterized in that: The multiple code files to be loaded corresponding to the target software include a shared object so library file.
8. A device for loading a code file, characterized in that: The device comprises: An acquisition unit, used for acquiring a plurality of code files to be loaded corresponding to the target software; A determining unit, configured to determine a target code file set according to the priorities of the plurality of code files, wherein the target code file set includes a plurality of target code files, and the plurality of target code files have the same priority; The loading unit is used to load the multiple target code files into the memory in parallel.
9. An electronic device, characterized in that: include: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer-readable medium, characterized in that A computer program is stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
