CN114327574A - Differential upgrading method, electronic device and storage medium - Google Patents
Differential upgrading method, electronic device and storage medium Download PDFInfo
- Publication number
- CN114327574A CN114327574A CN202011038865.9A CN202011038865A CN114327574A CN 114327574 A CN114327574 A CN 114327574A CN 202011038865 A CN202011038865 A CN 202011038865A CN 114327574 A CN114327574 A CN 114327574A
- Authority
- CN
- China
- Prior art keywords
- differential
- upgrading
- task
- threads
- sub
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Stored Programmes (AREA)
Abstract
The application discloses a differential upgrading method, an electronic device and a storage medium, wherein the differential upgrading method comprises the following steps: acquiring a differential packet corresponding to the current running version of an object to be upgraded; generating a plurality of difference tasks according to the difference packets; concurrently executing the acquired difference tasks by at least two sub-threads; and when all the differential tasks are executed, finishing the differential upgrading. According to the method and the device, a plurality of sub-threads are created, and a plurality of differential upgrading instructions are executed by all the sub-threads in the idle state at the same time, so that differential parallel upgrading is realized, the differential upgrading efficiency is greatly improved, the whole upgrading time is shortened, and convenience is brought to users.
Description
Technical Field
The present application relates to the field of upgrading technologies, and in particular, to a differential upgrading method, an electronic device, and a storage medium.
Background
In the prior art, there are various upgrading modes, and one of the upgrading modes is differential upgrading. The differential upgrading mode is an effective upgrading mode which is provided for solving the problem of overlarge full package, a certain algorithm is used for finding out the different places of a new version and an old version, then the different places are extracted to form a so-called updating patch (patch), and the patch file is used for upgrading a source file.
However, with the increase of functional applications, patch files of the differentially upgraded application become more and more large, and the patch files are too large, which easily results in too long time for upgrading the application, and greatly reduces the upgrading efficiency.
Accordingly, there is a need for improvements and developments in the art.
Disclosure of Invention
Therefore, it is necessary to provide a differential upgrade method, an electronic device, and a storage medium for solving the technical problem of low upgrade efficiency caused by an excessively long differential upgrade time in the prior art.
In order to achieve the purpose, the following technical scheme is adopted in the application:
in a first aspect, the present application provides a differential upgrade method, comprising the steps of:
acquiring a differential packet corresponding to the current running version of an object to be upgraded;
generating a plurality of difference tasks according to the difference packets;
concurrently executing the acquired difference tasks by at least two sub-threads;
and when all the differential tasks are executed, finishing the differential upgrading.
Optionally, after obtaining the differential packet corresponding to the current running version of the object to be upgraded, the method further includes:
checking whether the differential packet is complete and/or whether the downloading is successful;
and when the verification is complete and the downloading is successful, automatically restarting the terminal equipment and entering a recovery mode.
Optionally, the generating a plurality of difference tasks according to the difference packet specifically includes:
obtaining an upgrading script corresponding to the difference packet;
reading the upgrading script according to a preset rule in a recovery mode, and determining an upgrading mode corresponding to each file to be upgraded; the upgrading script comprises a plurality of files to be upgraded and an upgrading mode corresponding to each file to be upgraded;
if the upgrading mode corresponding to a certain file to be upgraded is differential upgrading, packaging the related parameter information required when the file to be upgraded is differential into a data structure, and generating a differential task according to the data structure.
Optionally, the concurrently executing the obtained difference task by the at least two sub-threads specifically includes:
creating a thread pool in a recovery mode, wherein the thread pool comprises at least two sub-threads, and starting the at least two sub-threads;
and at least two sub threads respectively acquire a differential task and concurrently execute the acquired differential task.
Optionally, the concurrently executing the acquired difference task by at least two child threads includes:
if the number of the sub-threads in the idle state is larger than the number M of the residual differential tasks, randomly selecting M sub-threads, and executing all the residual differential tasks concurrently by the M sub-threads; m is a positive integer greater than or equal to 1.
Optionally, after the concurrently executing the obtained differentiated tasks by the at least two child threads, the method further includes:
judging whether the current differential task to be executed is the last differential task or not;
if the current differential task to be executed is the last differential task, releasing resources after the differential task is executed, and finishing differential upgrading;
and if the current differential task to be executed is not the last differential task, continuing to execute the step of concurrently executing the obtained differential task through the at least two sub-threads until the current differential task to be executed is the last differential task.
Optionally, when all the differential tasks are executed, after the differential upgrade is completed, the method further includes:
closing all the sub threads;
and restarting in a normal mode to detect whether the upgrade is successful.
Optionally, the differential upgrade employs FOTA upgrade.
In a second aspect, the present application further provides an electronic device, which includes a processor and a memory connected to the processor, where the memory stores one or more programs, and the processor is configured to execute:
acquiring a differential packet corresponding to the current running version of an object to be upgraded;
generating a plurality of difference tasks according to the difference packets;
concurrently executing the acquired difference tasks by at least two sub-threads;
and when all the differential tasks are executed, finishing the differential upgrading.
In a third aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, performs the steps of the differential upgrade method.
Has the advantages that:
compared with the prior art, the application provides a differential upgrading method, electronic equipment and a storage medium, wherein the differential upgrading method comprises the steps of obtaining a differential package corresponding to the current running version of an object to be upgraded; generating a plurality of difference tasks according to the difference packets; concurrently executing the acquired difference tasks by at least two sub-threads; and when all the differential tasks are executed, finishing the differential upgrading. According to the method and the device, a plurality of sub-threads are created, and a plurality of differential upgrading instructions are executed by all the sub-threads in the idle state at the same time, so that differential parallel upgrading is realized, the differential upgrading efficiency is greatly improved, the whole upgrading time is shortened, and convenience is brought to users.
Drawings
Fig. 1 is a flowchart of a differential upgrade method provided in the present application.
Fig. 2 is a block diagram of an application scenario of a differential upgrading method provided in the present application.
Fig. 3 is a block diagram of an electronic device according to the present disclosure.
Detailed Description
The present application provides a differential upgrading method, an electronic device and a storage medium, and in order to make the objects, technical solutions and effects of the present application clearer and clearer, the present application will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
It will be understood by those within the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
The inventor researches and discovers that the existing differential upgrade finds out the different places of the new version and the old version through a certain algorithm, then extracts the different places to form a so-called update patch (patch), and uses the patch file to upgrade the source file one by one, and only one differential upgrade instruction can be executed in sequence at the same time to realize the differential serial upgrade. Then, as the application is made larger, the patch file of the application to be differentially upgraded is larger, and the larger the patch file is, the longer the application is upgraded. The differential package contains all patch files of files to be upgraded, and the characteristic of serial execution of the current differential upgrade can cause the whole upgrade process to be overlong, reduce the upgrade efficiency and increase the upgrade cost.
Based on the above problems, the present application provides a differential upgrade method, an electronic device, and a storage medium, in which a plurality of sub-threads are used, and all sub-threads in an idle state execute a plurality of differential upgrade instructions at the same time, so as to implement differential upgrade in parallel, thereby greatly improving the differential upgrade efficiency, shortening the whole upgrade time, and saving the overhead.
The technical solution of the present application is described below with reference to the accompanying drawings and specific embodiments, as follows:
referring to fig. 1, fig. 1 is a flowchart of a differential upgrade method. It should be noted that the differential upgrade method according to the embodiment of the present invention is not limited to the steps and the sequence in the flowchart shown in fig. 1, and the steps in the flowchart may be added, removed, or changed in sequence according to different requirements. As shown in fig. 1, the differential upgrade method includes:
and S10, acquiring a differential packet corresponding to the current running version of the object to be upgraded.
In this embodiment, the object to be upgraded may be a certain application program, a system, or a certain software. And the upgrading modes of the objects to be upgraded are divided into two modes, one mode is a full upgrading mode and adopts a full upgrading packet for upgrading, and the other mode is a differential upgrading mode and adopts a differential packet for upgrading. The full package upgrade is upgrading complete firmware, and the full package is large and has several GB, for example, reinstalling a system, and completely installing a new system on a mobile phone or a tablet. In practice, the device is usually connected to a PC through a USB interface, and then software upgrade is performed by using the PC.
The downloading steps through the PC are as follows:
1. a user manually appoints a specific model of the mobile phone and downloads an upgrade package from the internet;
2. pressing a specific hot key under the power-off state of the mobile phone, inserting a USB line, and entering a downloading mode;
3. the PC sends the upgrade package to the mobile phone through the USB interface, and the mobile phone writes the received data to each partition.
The upgrade data packet adopted by the upgrade mode is a whole packet, and a large data flow is needed.
Correspondingly, the differential packet is also called an incremental packet, which is a version-oriented upgrade, and is a difference part for adding patches or repairing and updating the system or software on the basis of the original system or software or application program. For example: the low version 3 is upgraded to the high version 4, only the part with the difference from the low version 3 to the high version 4 needs to be upgraded, the version upgrading is realized by a patching mode, and the upgrading package is small and is generally several MB to several hundred MB. The advantage of adopting the differential packet for upgrading is that seamless upgrading does not have any influence on the use of the terminal; secondly, the operation is convenient and fast; thirdly, the upgrading speed is high, only the difference part is upgraded, unnecessary flow cannot be brought, and meanwhile the upgrading speed is high.
Correspondingly, the differential packet upgrading is mainly online upgrading, the differential packet online upgrading is cloud service, whether the latest upgrading exists is judged according to the version numbers of the detection server and the terminal system, if the latest upgrading exists, differential processing is adopted, only the difference part is upgraded, and therefore the flow brought by upgrading is reduced. In this embodiment, The differential upgrade is mainly performed by FOTA (Firmware Over-The-Air) upgrade, which is mainly used for mobile terminals such as mobile phones, is a way for a user to update an operating system wirelessly using a mobile phone, and is not an application installed on The mobile phone. The terminal in this embodiment is not limited to a mobile phone, but may be a tablet or the like.
Further, the FOTA upgrading method comprises the following steps:
1. running the FOTA program;
2. checking the version of the native software;
3. detecting whether the FOTA server has a software differential packet corresponding to the FOTA server, if so, continuing, and if not, exiting the FOTA program;
4. downloading an upgrade package to a mobile phone/cache partition (a system cache partition);
5. restarting the mobile phone and entering a recovery mode;
6. under a recovery mode, generating new version software according to the differential package and the local software;
7. checking the generated new software data, if the checking is successful, continuing, and if the checking is identified, jumping to the step 9;
8. programming new software data into the mobile phone;
9. and restarting the mobile phone to a normal mode, and finishing upgrading.
Therefore, the FOTA upgrading is a simple and friendly upgrading method, and the mobile phone software can be upgraded to the latest version almost without any operation of a user.
Since the differential package upgrade is an online cloud service, the differential package is generated by the server. That is, the differentiated packet upgrade can be used in an application scenario as shown in fig. 2, where the terminal 101 is connected to the server 102, and the terminal 101 may be any network-enabled device such as a mobile phone, an ipad, a desktop computer, and the like. The server 102 may be a database server, a web server, etc., as long as the server 102 can store, identify, and generate differential packages corresponding to different versions.
As shown in fig. 2, when the terminal 101 is started in the normal mode, the server 102 connected to the terminal 101 detects whether the system or software of the terminal 101 has the latest version, and once the system or software of the terminal 101 has the latest version, it continues to detect whether the current operating version of the system or software of the terminal 101 is the latest version, and if the server 102 detects that the version number of the current operating version of the system or software of the terminal is different from the version number of the latest version, it sends a request and a prompt for updating to the terminal 101. The terminal 101 receives the request for upgrading and updating and the prompt sent by the server 102, and then responds to the request for upgrading and updating: the user may choose to upgrade or may choose not to upgrade. In this embodiment, the latest version may be regarded as the target version, and the current running version may be regarded as the version to be upgraded.
That is to say, the differential packet corresponding to the currently running version of the object to be upgraded is obtained before a detection operation and a generation operation of the version to be upgraded, where the detection operation of the version to be upgraded refers to determining the latest version of the version to be upgraded, and the differential packet generation operation refers to a generation operation of the differential packet required to upgrade the version to be upgraded to the target version when the version to be upgraded is not the latest version.
Illustratively, the detection operation of the version to be upgraded specifically includes:
m1, starting the terminal equipment in a normal mode, and acquiring the current running version of an object to be upgraded in the terminal equipment;
m2, determining a target version corresponding to the current running version;
m3, if the current running version is different from the target version, taking the current running version as a version to be upgraded, and sending an upgrade update request to the terminal device so that the terminal device responds to the upgrade update request.
It should be noted that the detection operation and the generation operation of the version to be upgraded are both completed by the server.
In specific implementation, the terminal takes the mobile phone as an example, the mobile phone is started, the server first determines whether the mobile phone software or the application program has the latest version (target version), and if so, then determines whether the current running version of the mobile phone software is the same as the version number of the target version, and if not, the server sends a software updating request or prompt to the mobile phone.
Further, if the user selects to determine the upgrade or click the software update request, the upgrade update request is fed back to the server. The server receives and analyzes the upgrade update request, when the upgrade update request indicates that the upgrade is needed and the upgrade selected mode is differential upgrade, the server obtains a current running version and a target version of the terminal system or software, differentiates a source package of the current running version and a target package of the target version to obtain a plurality of patch files after differentiation, and then packs the plurality of patch files, the upgrade script and the like into differential packages for downloading by the terminal equipment.
Illustratively, the generating of the differential packet specifically includes:
m10, acquiring a source package of a version to be upgraded and a target package of a target version;
m20, differentiating each file in the source package and the corresponding file in the target package one by one;
m30, each patch file obtained by difference is packaged to generate a difference packet.
Correspondingly, the differential packets corresponding to different versions to be upgraded are different. And the differential packet is obtained by carrying out differential acquisition on the version to be upgraded and the target version by adopting a bsdiff tool. The version to be upgraded and the target version can be two adjacent versions, and an adjacent version difference packet is generated. Of course, the version to be upgraded and the target version may also be two non-adjacent versions, and the difference between the versions is more than one version, so as to generate the cross-version difference packet. Thus, the types of differential packets include neighbor version differential packets, cross-version differential packets, and the like. The differential upgrade file of the adjacent version differential package is small, but the upgrade needs to circularly solve the differential synthesis for multiple times, and a plurality of version patch files need to be saved. The cross-version differential upgrading file is large, but only needs one-time differential solution, and the patch of one version is stored, so that the upgrading is flexible. When the requirement on the size of the uploaded file is high, the adjacent version difference can be preferably adopted; when upgrade time requirements are high, cross-version differencing may be preferred.
Furthermore, if the target version is changed more than the version to be upgraded, the size of the differential file generated after the difference is performed is larger, so in this embodiment, the source package of the version to be upgraded and the corresponding single file in the target package corresponding to the target version are differentiated one by one, and then all the single files after the difference are collectively packaged to generate the differential packet with a smaller size.
Then, when the server generates a differential packet corresponding to the current running version of the terminal, the differential packet is sent to the terminal; the terminal downloads the differential packet in a wireless networking mode, enters a recovery mode after successful downloading, and needs to check the differential packet in order to ensure that the downloaded differential packet is accurate and complete, avoid influencing the subsequent differential upgrading process, and avoid equipment damage caused by the fact that the differential upgrading fails due to the illegal downloading of the differential packet. The verification means that the target version information is matched with the version information to be upgraded so as to determine the legality of the differential packet. The checking comprises the following specific steps:
1. reading the version information description file and acquiring version information corresponding to the differential packet;
2. verifying whether the current running version information is consistent with the version information corresponding to the differential packet;
3. if the two are consistent, judging that the two are legal;
4. and if the two are not consistent, judging that the two are illegal.
The version information description file records the name of the version image file to be upgraded and the name of the patch image file.
Illustratively, after obtaining the differential packet corresponding to the current running version of the object to be upgraded, the method further includes:
m10, checking whether the differential packet is complete and/or whether the downloading is successful;
and M20, when the verification is complete and the downloading is successful, automatically restarting the terminal equipment and entering a recovery mode.
Once the difference packet is confirmed to be illegal, the terminal can display an upgrade failure warning prompt and store the prompt so as to facilitate the developer to find and solve the basis of the problem.
Once the differential packet inclusion method, namely verification success, is confirmed, the differential packet is subjected to differential solution to obtain an upgrade packet, wherein the upgrade packet is a target packet, namely the upgrade packet or the target packet corresponding to the target version is formed on the basis of the source packet and the differential packet of the version to be upgraded.
Further, it is also required to check whether the differential packet is successfully downloaded. And if the differential package is downloaded successfully, the terminal is upgraded in a recovery mode, and the differential package is compiled continuously to realize differential upgrade of a terminal system or software.
And S20, generating a plurality of difference tasks according to the difference packets.
In this embodiment, the terminal upgrade adopts FOTA upgrade, where the FOTA upgrade mode is to be upgraded in a recovery mode, and after the terminal enters the recovery mode, a thread pool is created, where the thread pool includes at least one sub-thread. That is, the at least one child thread includes at least two child threads, at least three child threads. For example: the thread pool comprises 1 sub-thread or 2 sub-threads or 3 sub-threads or 4 sub-threads and the like. A main thread is configured in the differential upgrading process. The number of main threads is only 1. The main thread and the plurality of sub threads are located in a thread pool, and the thread pool is used for maintaining a task queue and is responsible for creating, multiplexing and destroying the threads. The thread in this embodiment refers to the smallest unit that the operating system can perform operation scheduling, and is included in the process, and is the actual operation unit in the process. A thread refers to a single sequential control flow in a process, multiple threads can be executed in parallel in a process, and each thread executes different tasks in parallel.
Correspondingly, the main thread is used for analyzing the upgrading script in the differential package to generate a plurality of upgrading instructions. The upgrading instruction comprises a full upgrading instruction and a differential upgrading instruction, the full upgrading instruction corresponds to a full upgrading mode, and the differential upgrading instruction corresponds to a differential upgrading mode. And packaging each differential upgrading instruction into a differential task, and adding the generated multiple differential tasks into the task queue. And the sub thread is used for selecting the differential task to execute the differential task through the differential upgrading instruction corresponding to the differential task so as to complete differential upgrading.
Further, since resource configuration information of different terminal devices is different, sub-threads that can be supported at the same time are necessarily different. That is, the number of the sub-threads is determined based on resource configuration information of the terminal, and the resource configuration information includes hardware configuration information and software configuration information. For example: if the number of the CPU cores of the terminal equipment is 4, the maximum value of the number of the created sub-threads is N-4, and at the moment, the terminal enters a recovery mode and immediately creates 4 sub-threads; if the core number of the CPU is 8 cores, the maximum number of created sub-threads is N-8, and at this time, the terminal enters the recovery mode and immediately creates 8 sub-threads.
And after the creation of the plurality of sub threads, starting the created plurality of sub threads. That is, at least one child thread is initiated, which includes initiating at least two child threads, and initiating at least three child threads. For example: start 2 sub-threads or start 3 sub-threads or start 4 sub-threads. When the sub-thread is started, the corresponding state is an idle state so as to wait for the differential task to be executed. The states of the child thread include an idle state and a busy state. When the state of the sub-thread is in the busy state, the sub-thread is indicated to execute the differential task. And when the state of the sub-thread is in an idle state, the sub-thread is in a waiting state, which indicates that the differential task is not executed by the sub-thread.
Illustratively, the generating a plurality of difference tasks according to the difference packet specifically includes:
s21, obtaining the upgrading script corresponding to the difference packet;
s22, reading the upgrading script according to preset rules in a recovery mode, and determining the upgrading mode corresponding to each file to be upgraded; the upgrading script comprises a plurality of files to be upgraded and an upgrading mode corresponding to each file to be upgraded;
s23, if the upgrade mode corresponding to a certain file to be upgraded is differential upgrade, packaging the related parameter information required by the file to be upgraded when the file to be upgraded is differential into a data structure, and generating a differential task according to the data structure.
The upgrading mode comprises a differential upgrading mode and a full package upgrading mode. The differential upgrading mode corresponds to a differential task, and the full-package upgrading mode corresponds to a whole-package task. In this embodiment, only the differential upgrade corresponding to the differential upgrade method is performed.
Further, the differential task in the task queue list is generated by the main thread, the main thread is in an active state all the time before the differential upgrade is completed, that is, each line of script in the upgrade script corresponding to the differential packet is continuously analyzed, if the upgrade mode corresponding to a certain file to be upgraded is differential upgrade, the related parameter information required when the file to be upgraded is differential is packaged into a data structure, and a differential task is generated according to the data structure, that is, each time a differential upgrade instruction in the upgrade script is analyzed, the differential upgrade instruction is packaged into the differential task and added into the task queue, and the activity of other sub-threads is not influenced. One differential upgrade order corresponds to one differential task. And after the main thread finishes analyzing the upgrading script and all the difference tasks are executed, releasing the resources and finishing upgrading.
And S30, executing the acquired differential tasks through at least two sub threads concurrently.
In this embodiment, the main thread continuously parses each line of script in the upgrade script, continuously generates a differential upgrade instruction, and correspondingly encapsulates the differential upgrade instruction into a differential task. Meanwhile, each sub-thread in the idle state sequentially retrieves one differential task from the task queue list to execute, and each sub-thread can only execute one differential task 1 time, so that the N sub-threads in the idle state can execute N differential upgrade instructions (N differential tasks) at a time, in other words, the N sub-threads in the idle state are concurrently executed at the same time, which is different from the existing method that only one differential task corresponding to one differential upgrade instruction can be executed at a time, and only serial differential upgrade can be realized. Just because the differential upgrading process is equivalent to that N +1 threads run simultaneously, the purpose of simultaneously and differentially upgrading N files to be upgraded at the same time can be achieved, the speed is increased, and convenience is brought to users.
Illustratively, the concurrently executing the acquired difference task by the at least two sub-threads specifically includes:
creating a thread pool in a recovery mode, wherein the thread pool comprises at least two sub-threads, and starting the at least two sub-threads;
and at least two sub threads respectively acquire a differential task and concurrently execute the acquired differential task.
Further, in the process of executing the difference task, each sub-thread has different execution speeds, a sub-thread preferentially completes the difference task and is in an idle state again, at this time, the sub-thread in the idle state continues to select the next difference task from the task queue in sequence, and the next difference task is not required to be taken until the difference tasks of other sub-threads are completed. And if all the differential tasks in the task queue are finished, all the sub-threads are in a waiting state, namely an idle state, so as to wait for the subsequent upgrading operation of the main thread to finish the differential upgrading.
And as long as the sub-thread executes the current task, the sub-thread immediately acquires the next unexecuted differential task from the task queue list to execute again without waiting for other sub-threads to finish the task. Therefore, by the detection mechanism, the states of all the difference tasks are detected in real time, and then the remaining difference tasks which are not executed are determined according to the states of the difference tasks. It is to be understood that, after the concurrently executing the acquired differential task by the at least two sub-threads, the method further includes:
judging whether the current differential task to be executed is the last differential task or not;
if the current differential task to be executed is the last differential task, releasing resources after the differential task is executed, and finishing differential upgrading;
and if the current differential task to be executed is not the last differential task, continuing to execute the step of concurrently executing the obtained differential task through the at least two sub-threads until the current differential task to be executed is the last differential task.
For example: and detecting the remaining 5 differential tasks and 4 idle-state sub-threads, wherein at the moment, the 4 idle-state sub-threads sequentially select 4 remaining differential tasks from the task queue list (only 1 differential task remains in the task queue list to wait for the idle-state sub-threads), and the sub-threads in the differential tasks are in a busy state.
Furthermore, if the number of the sub-threads in the idle state is larger than the number M of the remaining differential tasks, M sub-threads are randomly selected and execute all the remaining differential tasks concurrently; m is a positive integer greater than or equal to 1.
For example: and detecting the remaining 3 differential tasks and 4 idle sub-threads, wherein at the moment, randomly controlling the 3 idle sub-threads to sequentially select the 3 differential tasks from the task queue list (only 1 idle sub-thread is left), and updating the states of the 3 idle sub-threads in the execution of the differential tasks to be busy. In order to further understand the technical solution of parallel upgrading in the differential upgrading method of the present application, an example is described below, as follows:
for example: the task queue table stores 10 differential tasks, which are respectively marked as 1,2, 3,4,5,6,7,8,9 and 10, and 4 sub-threads, which are respectively marked as X1, X2, X3 and X4, are started.
At time T1:
the X1 takes the task 1 and executes the differential task 1, and the state is updated from an idle state to a busy state at the moment;
the X2 takes task 2 and executes differential task 2, and the state is updated from an idle state to a busy state at the moment;
the X3 takes task 3 and executes differential task 3, and the state is updated from an idle state to a busy state;
the X4 takes task 4 and executes differential task 4, and the state is updated from an idle state to a busy state at the moment;
at time T2:
x1 is still executing differential task 1, while the status is still busy;
x2 is still executing differential task 2, while the status is still busy;
x3 ends the difference task 3, the state is updated from busy state to idle state, then continues to get task 5, and executes the difference task 5, the state is updated from idle state to busy state;
x4 ends difference task 4, the state is updated from busy state to idle state, then continues to get task 6, and executes difference task 6, the state is updated from idle state to busy state;
at time T3:
x1 ends the differential task 1, the state is updated from the busy state to the idle state, then the differential task 7 is continuously taken, the differential task 7 is executed, and the state is updated from the idle state to the busy state;
x2 ends the differential task 2, the state is updated from the busy state to the idle state, then the differential task 8 is continuously taken, the differential task 8 is executed, and the state is updated from the idle state to the busy state;
x3 is still executing differencing task 5, which is still busy;
x4 ends the differential task 6, the state is updated from the busy state to the idle state, then continues to get the differential task 9, and executes the differential task 9, the state is updated from the idle state to the busy state;
at time T4:
x1 is still executing differencing task 7, which is still busy;
x2 ends the differential task 8, the state is updated from the busy state to the idle state, then continues to get the differential task 10, and executes the differential task 10, the state is updated from the idle state to the busy state;
x3 is still executing differencing task 5, which is still busy;
x4 is still executing differencing task 9, which is still busy;
at time T5:
x1 ends difference task 7, where the status is updated from busy status to idle status;
x2 ends difference task 10, where the status is updated from busy status to idle status;
x3 ends difference task 5, where the status is updated from busy status to idle status;
x4 ends difference task 9 when the status is updated from busy to idle.
And between the time T1 and the time T5, the main thread analyzes each line of script in the upgrading script all the time to generate a corresponding upgrading instruction, at this time, it is determined that 10 differential tasks in the task list are all completed, the sub-threads X1, X2, X3 and X4 are all in an idle state, the main thread waits for the completion of subsequent upgrading operation until the upgrading operation is completed, and the upgrading is finished.
And S40, finishing the differential upgrading when all the differential tasks are executed.
Specifically, the specific process of the differential upgrade specifically includes:
m41, acquiring a patch file corresponding to the differential task to be executed;
m42, determining a file to be upgraded corresponding to the patch file, wherein the file to be upgraded is a file to be upgraded in a source package of a version to be upgraded of the terminal;
the differential package comprises a patch file corresponding to a file to be upgraded which needs to adopt a differential upgrading mode in the version to be upgraded and a version information description file. The version information description file comprises source image names, source image paths, upgrading modes, patch image names and patch image paths corresponding to a plurality of files to be upgraded. And analyzing the upgrading script in the differential package compiling process, and once the applypatch key word in the upgrading script is analyzed, indicating that the file to be upgraded corresponding to the applypatch key word needs to be patched and upgraded and corresponding to the differential upgrading mode. Therefore, each patch file corresponds to a unique file to be upgraded, and the file to be upgraded refers to the file to be upgraded stored in the source package corresponding to the version to be upgraded of the terminal. If the script analyzed in the upgrading script does not have the applypatch keyword, the file to be upgraded does not need to be patched, and the full-scale upgrading mode is directly adopted and can be directly regarded as the upgrading file corresponding to the target version. That is, the file to be upgraded is the same as the upgrade file corresponding to the target package in the target version. It should be noted that the upgrading mode in the upgrade script includes one or more of differential upgrading and full upgrading.
The differential upgrading is a process of one-to-one printing of corresponding patch files on files to be upgraded in versions to be upgraded of the terminal, which need differential upgrading, and the differential packages do not contain the files to be upgraded corresponding to the current version of the terminal, so that the files to be upgraded corresponding to each patch file need to be determined through the patch files and the version information description files in the differential upgrading process.
Because the version information description file stores the source image name and the corresponding patch image name corresponding to each file to be upgraded, the file to be upgraded in the current running version corresponding to the patch file in the differential packet can be searched based on the patch image name of each patch file.
M43, determining an upgrade file corresponding to the target version according to the patch file and the corresponding file to be upgraded;
and M44, replacing the file to be upgraded with the upgrade file.
That is, the upgrade file can be synthesized according to the searched file to be upgraded and the corresponding patch file, so that the upgrade file replaces the corresponding file to be upgraded in the original version, and the differential upgrade is completed, thereby restoring the upgrade package. And then, writing the upgrade file data corresponding to the target version to the terminal.
And once the main thread finishes analyzing the upgrading script and all the difference tasks are executed, releasing the resources and finishing upgrading.
Therefore, a plurality of differential tasks are executed at the same time, namely a plurality of files to be upgraded are upgraded, the upgrading speed is increased, the whole upgrading time is greatly shortened, the differential upgrading efficiency is improved, and convenience is brought to users.
Further, when all the differential tasks are executed, after the completion of the differential upgrade, the method further includes:
closing all the sub threads;
and restarting in a normal mode to detect whether the upgrade is successful. That is, when the last differential task in the task queue is executed, determining that the states of all the sub-threads are updated to be idle after all the sub-threads execute the differential upgrade operation, and waiting for other upgrade operations of the main thread to be executed; when the upgrade operation is finished, the terminal is restarted in a normal mode, and after the restart is successful, the terminal receives a prompt of successful update, namely a prompt of successful upgrade to the target version.
If the terminal fails to restart in the normal mode, the terminal can restart successfully in the original version through the prompt for restoring the original version to be upgraded, then receives the prompt for updating failure and displays the reason of updating failure, and stores the reason of updating failure and uploads the reason to the server so as to be used as the basis for monitoring and solving the updating failure by subsequent developers.
In summary, the differential upgrade method provided by the present application includes the steps of
Acquiring a differential packet corresponding to the current running version of an object to be upgraded; generating a plurality of difference tasks according to the difference packets; concurrently executing the acquired difference tasks by at least two sub-threads; and when all the differential tasks are executed, finishing the differential upgrading. According to the method and the device, a plurality of sub-threads are created, and a plurality of differential upgrading instructions are executed by all the sub-threads in an idle state at the same time, so that differential parallel upgrading is realized, the differential upgrading efficiency is greatly improved, the whole upgrading time is shortened, and the upgrading cost is saved.
Based on the differential upgrade method, the present application further provides an electronic device, as shown in fig. 3, where the electronic device 1 may be any network-enabled device such as a mobile phone, an ipad, and a desktop computer. The electronic device 1 comprises a processor 11 and a memory 22 connected to said processor 11, fig. 3 only showing some components of the electronic device 1, but it is to be understood that not all shown components are required to be implemented, and more or less components may be implemented instead.
The memory 22 may in some embodiments be an internal storage unit of the electronic device 1, such as a memory of the system 100. The memory 22 may also be an external storage device of the system 100 in other embodiments, such as a plug-in usb disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the electronic device 1. Further, the memory 22 may also include both an internal storage unit and an external storage device of the electronic device 1. The memory 22 is used for storing application software installed in the electronic device 1 and various types of data, such as the differential upgrade program code. The memory 22 may also be used to temporarily store data that has been output or is to be output. In one embodiment, the memory 22 stores a differential upgrade program, which is executed by the processor 11 to perform the following steps:
acquiring a differential packet corresponding to the current running version of an object to be upgraded;
generating a plurality of difference tasks according to the difference packets;
concurrently executing the acquired difference tasks by at least two sub-threads;
and when all the difference tasks are executed, completing the difference upgrading, specifically as described in the above method.
The processor 11 may be, in some embodiments, a Central Processing Unit (CPU), a microprocessor, a mobile phone baseband processor or other data Processing chip, and is configured to execute the program codes stored in the memory 22 or process data, for example, execute the differential upgrade method.
The present application also provides a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor 11, implements the steps of the differential upgrade method, in particular the method as described above.
Of course, it will be understood by those skilled in the art that all or part of the processes of the methods of the above embodiments may be implemented by a computer program instructing relevant hardware (such as a processor, a controller, etc.), and the program may be stored in a computer readable storage medium, and when executed, the program may include the processes of the above method embodiments. The storage medium may be a memory, a magnetic disk, an optical disk, etc.
It should be understood that the application of the present application is not limited to the above examples, and that modifications or changes may be made by those skilled in the art based on the above description, and all such modifications and changes are intended to fall within the scope of the appended claims.
Claims (10)
1. A differential upgrade method, characterized in that it comprises the steps of:
acquiring a differential packet corresponding to the current running version of an object to be upgraded;
generating a plurality of difference tasks according to the difference packets;
concurrently executing the acquired difference tasks by at least two sub-threads;
and when all the differential tasks are executed, finishing the differential upgrading.
2. The differential upgrade method according to claim 1, wherein after obtaining the differential package corresponding to the current running version of the object to be upgraded, the method further comprises:
checking whether the differential packet is complete and/or whether the downloading is successful;
and when the verification is complete and the downloading is successful, automatically restarting the terminal equipment and entering a recovery mode.
3. The differential upgrade method according to claim 1, wherein the generating a plurality of differential tasks according to the differential packet specifically includes:
obtaining an upgrading script corresponding to the difference packet;
reading the upgrading script according to a preset rule in a recovery mode, and determining an upgrading mode corresponding to each file to be upgraded; the upgrading script comprises a plurality of files to be upgraded and an upgrading mode corresponding to each file to be upgraded;
if the upgrading mode corresponding to a certain file to be upgraded is differential upgrading, packaging the related parameter information required when the file to be upgraded is differential into a data structure, and generating a differential task according to the data structure.
4. The differential upgrade method according to claim 3, wherein the concurrently executing the obtained differential task by the at least two child threads specifically includes:
creating a thread pool in a recovery mode, wherein the thread pool comprises at least two sub-threads, and starting the at least two sub-threads;
and at least two sub threads respectively acquire a differential task and concurrently execute the acquired differential task.
5. The differential upgrade method according to claim 4, wherein the concurrently executing the acquired differential tasks by at least two child threads comprises:
if the number of the sub-threads in the idle state is larger than the number M of the residual differential tasks, randomly selecting M sub-threads, and executing all the residual differential tasks concurrently by the M sub-threads; m is a positive integer greater than or equal to 1.
6. The differential upgrade method according to claim 1, wherein after the concurrently executing the acquired differential task by the at least two child threads, the method further comprises:
judging whether the current differential task to be executed is the last differential task or not;
if the current differential task to be executed is the last differential task, releasing resources after the differential task is executed, and finishing differential upgrading;
and if the current differential task to be executed is not the last differential task, continuing to execute the step of concurrently executing the obtained differential task through the at least two sub-threads until the current differential task to be executed is the last differential task.
7. The differential upgrade method according to claim 1, wherein when all the differential tasks are executed, after completing the differential upgrade, the method further comprises:
closing all the sub threads;
and restarting in a normal mode to detect whether the upgrade is successful.
8. The differential upgrade method according to claim 1, wherein the differential upgrade employs FOTA upgrade.
9. An electronic device, characterized in that the electronic device comprises a processor and a memory connected to the processor, the memory storing a computer program, the processor implementing the steps in the differential upgrade method according to any one of claims 1-8 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps in the differential upgrade method of any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011038865.9A CN114327574A (en) | 2020-09-28 | 2020-09-28 | Differential upgrading method, electronic device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011038865.9A CN114327574A (en) | 2020-09-28 | 2020-09-28 | Differential upgrading method, electronic device and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114327574A true CN114327574A (en) | 2022-04-12 |
Family
ID=81011454
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011038865.9A Pending CN114327574A (en) | 2020-09-28 | 2020-09-28 | Differential upgrading method, electronic device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114327574A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117174612A (en) * | 2023-08-28 | 2023-12-05 | 江苏道达智能科技有限公司 | Plate lifting control method for wafer processing process flow |
WO2024051465A1 (en) * | 2022-09-09 | 2024-03-14 | 荣耀终端有限公司 | Differential file restoration method and electronic device |
-
2020
- 2020-09-28 CN CN202011038865.9A patent/CN114327574A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024051465A1 (en) * | 2022-09-09 | 2024-03-14 | 荣耀终端有限公司 | Differential file restoration method and electronic device |
CN117174612A (en) * | 2023-08-28 | 2023-12-05 | 江苏道达智能科技有限公司 | Plate lifting control method for wafer processing process flow |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108847950B (en) | Electronic device, cloud system software automatic deployment method and storage medium | |
EP2966566B1 (en) | Driver program loading method and embedded device | |
CN102902556B (en) | The multistage boot load method of a kind of embedded equipment | |
US9928059B1 (en) | Automated deployment of a multi-version application in a network-based computing environment | |
JP2021002317A (en) | Method, apparatus, device and storage medium for upgrading application | |
CN103559065B (en) | Method and system for OTA (Over-the-Air Technology) upgrade | |
WO2016101503A1 (en) | Hot patching realization method and apparatus | |
KR20170040734A (en) | Electronic system with update control mechanism and method of operation thereof | |
CN105760191A (en) | Embedded system equipment programming mass production method | |
CN111813428A (en) | Method and device for upgrading terminal firmware, electronic equipment and storage medium | |
CN114327574A (en) | Differential upgrading method, electronic device and storage medium | |
CN112015447B (en) | System updating method and device of electronic equipment, electronic equipment and storage medium | |
CN105677409B (en) | A kind of method for upgrading system and device | |
US20130080751A1 (en) | Method and device for updating bios program for computer system | |
CN114546819A (en) | Code processing method and device, electronic equipment and readable medium | |
CN118051277A (en) | Method and device for starting server, storage medium and electronic equipment | |
CN116339908A (en) | Virtual machine starting method, device, computer equipment and storage medium | |
CN112711427A (en) | Method and device for acquiring mirror image file | |
CN108121561B (en) | Application program repairing method, device and system | |
WO2018014687A1 (en) | Parameter passing method and apparatus, and computer storage medium | |
CN109426546B (en) | Application starting method and device, computer storage medium and equipment | |
CN118276887A (en) | Set top box cross-system upgrading method and device, set top box and storage medium | |
CN114237654A (en) | OTA (over the air) upgrading method and system | |
CN113010195B (en) | System upgrading method, storage medium and terminal equipment | |
KR100558394B1 (en) | electronic apparatus and program update method of thereof |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |