CN112506626A - Application program starting method, computer equipment and storage medium - Google Patents

Application program starting method, computer equipment and storage medium Download PDF

Info

Publication number
CN112506626A
CN112506626A CN202011288694.5A CN202011288694A CN112506626A CN 112506626 A CN112506626 A CN 112506626A CN 202011288694 A CN202011288694 A CN 202011288694A CN 112506626 A CN112506626 A CN 112506626A
Authority
CN
China
Prior art keywords
task
initialization
application program
tasks
type
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
Application number
CN202011288694.5A
Other languages
Chinese (zh)
Inventor
蒋杰文
潘叶江
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Vatti Co Ltd
Original Assignee
Vatti Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Vatti Co Ltd filed Critical Vatti Co Ltd
Priority to CN202011288694.5A priority Critical patent/CN112506626A/en
Publication of CN112506626A publication Critical patent/CN112506626A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration

Abstract

The invention discloses a starting method of an application program, computer equipment and a storage medium. The method comprises the following steps: when the application program is started, screening out a third-party framework needing initialization from all the third-party frameworks of the application program; adding an initialization task corresponding to a third-party framework needing initialization to a task set; classifying initialization tasks in a task set to obtain a first class of initialization tasks and a second class of initialization tasks, and adding the first class of initialization tasks to a task manager; and calling the main thread to execute the first type of initialization task in the task manager, and calling the sub thread to execute the second type of initialization task. The computer device comprises a memory and a processor, the computer program implementing the above-mentioned method when being executed by the processor. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the above-mentioned method. The invention can optimize the execution logic of the third-party framework and improve the starting efficiency of the application program.

Description

Application program starting method, computer equipment and storage medium
Technical Field
The invention belongs to the technical field of computers, and particularly relates to a starting method of an application program, computer equipment and a storage medium.
Background
With the development of computer technology, a variety of applications have emerged. Some applications may integrate a third party framework. When the application program is started, some third-party frameworks need to be initialized, and some third-party frameworks do not need to be initialized. In the prior art, when an application program is started, all third-party frameworks are initialized simultaneously in one thread, so that processor resources are excessively consumed, and the situations of unsmooth application program page, long loading time and even breakdown easily occur.
Disclosure of Invention
In order to solve the problems and disadvantages of the prior art, an object of the present invention is to provide a method, a computer device, and a storage medium for starting an application program, which can improve the starting efficiency of the application program.
In order to achieve the above object, the present invention first provides a method for starting an application program, including:
when the application program is started, screening out a third-party framework needing initialization from all the third-party frameworks of the application program;
adding an initialization task corresponding to a third-party framework needing initialization to a task set;
classifying initialization tasks in a task set to obtain a first class of initialization tasks and a second class of initialization tasks, and adding the first class of initialization tasks to a task manager;
and calling the main thread to execute the first type of initialization task in the task manager, and calling the sub thread to execute the second type of initialization task.
Further, the first type of initialization task includes: when an application program is started, an initialization task which needs to be executed preferentially is needed; the second type of initialization tasks includes: and the initialization task is executed after the first type task initialization task is executed.
Further, still include: and sequencing the first-class initialization tasks in the task manager according to the executed logic sequence, and executing the first-class initialization tasks in sequence according to the sequencing.
Further, the logical order of execution includes directed acyclic graph topological ordering.
Further, before the main thread executes the task, the main thread is added with a synchronous lock for ensuring the priority execution of the task in the main thread according to the number of the tasks in the task manager.
And further, after the execution of the main thread is finished, unlocking the synchronous lock of the main thread.
Further, the number of the first type initialization tasks in the task manager is recorded by the task counter, and when the count of the task counter is 0, the application program is indicated to be started completely.
Further, the recording of the number of tasks in the task manager by the task counter comprises: every time a first type of initialization task is added in task management, adding 1 to the count of a task counter; whenever the main thread executes to complete a first type of initialization task, the count of the task counter is decremented by 1.
The invention also provides a computer device, which comprises a memory and a processor, wherein the memory is stored with a computer program capable of running on the processor, and the computer program realizes the starting method of the application program when being executed by the processor.
The present invention also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method for launching an application program as described above.
Compared with the prior art, the invention has the beneficial effects that: the method comprises the steps of screening out a third-party frame needing initialization, dividing the initialization task of the third-party frame into a first-class initialization task and a second-class initialization task, calling a main thread to execute the first-class initialization task, and calling a sub-thread to execute the second-class initialization task, so that the utilization efficiency of the main thread of a processor can be improved, the initialization task of the third-party frame with high priority can be executed preferentially, unnecessary waste of processor resources is reduced, the execution logic of the third-party frame initialization is optimized, and the starting efficiency of an application program is improved.
Drawings
FIG. 1 is a diagram of method steps according to a first embodiment of the present invention;
fig. 2 is a circuit diagram of a second embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The first embodiment is as follows:
an embodiment of the present invention provides a method for starting an application, which can be applied to devices such as a mobile phone, a tablet computer, and a PC, and the embodiment is described by taking an application to an android mobile phone as an example, as shown in fig. 1, the method includes the following steps:
s1, a task manager is generated according to the codes of the application program, and the application program is started.
S2, carrying out logic judgment according to the codes of the application program, and judging whether each third-party framework needs to be initialized; if yes, adding the initialization task of the third-party framework into a task set created according to the application program code, and if not, distributing the loading task of the third-party framework into the sub-thread for execution; tasks executed in the child thread do not affect the main thread. This screens out third party frameworks that need to be initialized.
And S3, dividing the initialization tasks in the task set into a first type of initialization task and a second type of initialization task according to the execution logic sequence of the initialization tasks, adding the first type of initialization task to the task manager, and adding 1 to the count of the task counter.
The first type of initialization task comprises the following steps: when an application program is started, an initialization task which needs to be executed preferentially is needed; the second type of initialization tasks includes: and the initialization task is executed after the first type task initialization task is executed. The first type of initialization task is executed in the main thread, and the second type of initialization task is executed in the sub-thread. This allows the initialization task of the third-party framework with the higher priority to be preferentially executed.
S4, sorting the first type of initialization tasks in the task manager according to the executed logic sequence, in this embodiment, sorting is performed by using a directed acyclic graph topology sorting method. For example, A, B, C, D four tasks, the logical order of execution is that A needs to be executed after B and C needs to be executed after D, then A, B, C, D four tasks may be ordered as (B, A), (D, C), or (D, C), (B, A).
And S5, adding synchronous locks to the main thread according to the number of the first type of initialization tasks in the task manager, wherein the number of the synchronous locks is equal to that of the first type of initialization tasks in the task manager, and the synchronous locks can ensure that the processor processes the tasks in the main thread preferentially. When the main thread executes tasks, the tasks are sequentially executed in the order of step S4.
And S6, starting distributing tasks, traversing all the first-class initialization tasks in the task manager, and judging whether the first-class initialization tasks need to be executed in the main thread. If so, after the main thread executes the task, unlocking the synchronous lock, and simultaneously subtracting 1 from the count of the task counter; if not, the method is distributed to the sub-thread for execution, and the main thread is not influenced. Therefore, the first type of initialization tasks are subdivided again, the first type of initialization tasks with higher priority are put into the main thread to be executed, and the initialization logic of a third-party framework is further optimized.
S7, judging whether the count of the task counter is 0, if yes, indicating that all third-party frameworks needing initialization are initialized, and starting the application program; if not, steps S5 and S6 continue until the task counter count is 0.
In this embodiment, a third-party framework to be initialized is first screened out, then the initialization task of the third-party framework is divided into a first-class initialization task and a second-class initialization task, the first-class initialization task is executed by calling the main thread, and the second-class initialization task is executed by the sub-thread, so that the utilization efficiency of the main thread of the processor can be improved, the initialization task of the third-party framework with a high priority is executed preferentially, unnecessary waste of processor resources is reduced, the execution logic of the initialization of the third-party framework is optimized, and the starting efficiency of the application program is improved.
Example two:
a second embodiment of the present invention provides a computer device, as shown in fig. 2, including a memory and a processor, where the memory stores a computer program that can be executed on the processor, and when the computer program is executed by the processor, the computer device implements the method for starting an application program provided in the first embodiment.
In an implementation of the device of this embodiment, the memory and the processor are electrically connected directly or indirectly to enable data transmission or interaction. For example, the elements may be electrically connected to each other via one or more communication buses or signal lines, such as via a bus. The memory stores computer-executable instructions for implementing the data access control method, and includes at least one software functional module which can be stored in the memory in the form of software or firmware, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a programmable read-only memory (PROM), an erasable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), and the like. The memory is used for storing programs, and the processor executes the programs after receiving the execution instructions. Further, the software programs and modules within the aforementioned memories may also include an operating system, which may include various software components and/or drivers for managing system tasks (e.g., memory management, storage device control, power management, etc.), and may communicate with various hardware or software components to provide an operating environment for other software components. The processor may be an integrated circuit chip having signal processing capabilities. The processor may be a general-purpose processor, and includes a central processing unit (central processing unit, abbreviated as processor), a network processor (network processor, abbreviated as NP), and the like. The various methods, steps, and logic flow diagrams disclosed in this embodiment may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The computer device of the second embodiment of the invention can be an electronic device with computing capability, such as a mobile phone and a computer, which are loaded with Android, iOS or windows systems.
In a second embodiment, the method for starting the application program provided in the first embodiment is adopted, a third-party framework needing to be initialized is screened out, then the initialization tasks of the third-party framework are divided into a first-class initialization task and a second-class initialization task, a main thread is called to execute the first-class initialization task, and a sub-thread executes the second-class initialization task, so that the utilization efficiency of the main thread of the processor can be improved, the initialization tasks of the third-party framework with high priority can be executed preferentially, unnecessary waste of processor resources is reduced, the execution logic of the initialization of the third-party framework is optimized, and the starting efficiency of the application program is improved.
Example three:
the third embodiment of the present invention provides a computer-readable storage medium, on which instructions are stored, and when the instructions are executed by a processor, the method for starting an application program provided in the first embodiment is performed.
Those of ordinary skill in the art will understand that: all or a portion of the method steps for implementing the embodiments described above may be performed by hardware associated with program instructions. The aforementioned program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the foregoing storage media include, but are not limited to: various media capable of storing program codes, such as ROM, RAM, magnetic or optical disk, etc., and the specific type of media is not limited in this application.
In a third embodiment, the method for starting the application program provided in the first embodiment is adopted, a third-party framework needing to be initialized is screened out, then the initialization tasks of the third-party framework are divided into a first-class initialization task and a second-class initialization task, a main thread is called to execute the first-class initialization task, and a sub-thread executes the second-class initialization task, so that the utilization efficiency of the main thread of the processor can be improved, the initialization tasks of the third-party framework with high priority can be executed preferentially, unnecessary waste of processor resources is reduced, the execution logic of the initialization of the third-party framework is optimized, and the starting efficiency of the application program is improved.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A method for starting an application program, the method comprising:
when an application program is started, screening out a third-party framework needing initialization from all the third-party frameworks of the application program;
adding an initialization task corresponding to the third-party framework needing initialization to a task set;
classifying the initialization tasks in the task set to obtain a first class of initialization tasks and a second class of initialization tasks, and adding the first class of initialization tasks to a task manager;
and calling a main thread to execute the first type of initialization task in the task manager, and calling a sub thread to execute the second type of initialization task.
2. The method for starting the application program according to claim 1, wherein the first type initialization task comprises: when the application program is started, an initialization task which needs to be executed preferentially is needed; the second type of initialization task comprises the following steps: and the initialization task is executed after the first type task initialization task is executed.
3. The method for starting an application program according to claim 1, further comprising: and sequencing the first type initialization tasks in the task manager according to an execution logic sequence, and executing the first type initialization tasks in sequence according to the sequencing.
4. The method of claim 3, wherein the logical order of execution comprises a directed acyclic graph topological sort.
5. The method for starting an application program according to claim 1, further comprising: and before the main thread executes the tasks, adding a synchronous lock for ensuring the priority execution of the tasks in the main thread to the main thread according to the number of the tasks in the task manager.
6. The method for starting an application program according to claim 5, further comprising: and after the main thread is executed, unlocking the synchronous lock of the main thread.
7. The method for starting an application program according to claim 1, further comprising: and recording the number of the first type of initialization tasks in the task manager through a task counter, and when the count of the task counter is 0, indicating that the application program is started and completed.
8. The method for starting an application program according to claim 7, wherein the recording of the number of tasks in the task manager by the task counter comprises: every time one first type of initialization task is added in the task management, the counting of the task counter is increased by 1; and each time the main thread completes one initialization task of the first class, the counting number of the task counter is reduced by 1.
9. A computer device comprising a memory and a processor, the memory having stored thereon a computer program operable on the processor, wherein the computer program, when executed by the processor, implements a method of launching an application program as claimed in any of claims 1 to 8.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a method for starting an application program according to any one of claims 1 to 8.
CN202011288694.5A 2020-11-17 2020-11-17 Application program starting method, computer equipment and storage medium Pending CN112506626A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011288694.5A CN112506626A (en) 2020-11-17 2020-11-17 Application program starting method, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011288694.5A CN112506626A (en) 2020-11-17 2020-11-17 Application program starting method, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112506626A true CN112506626A (en) 2021-03-16

Family

ID=74956624

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011288694.5A Pending CN112506626A (en) 2020-11-17 2020-11-17 Application program starting method, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112506626A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114495147A (en) * 2022-01-25 2022-05-13 北京百度网讯科技有限公司 Identification method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001082121A2 (en) * 2000-04-19 2001-11-01 Microsoft Corporation Pre-computing and encoding techniques for an electronic document to improve run-time processing
CN105630543A (en) * 2015-12-21 2016-06-01 北京奇虎科技有限公司 Application cold start acceleration method and apparatus
CN107943576A (en) * 2017-12-14 2018-04-20 中国平安人寿保险股份有限公司 Starting guide method, apparatus, equipment, system and the medium of application program
CN109117203A (en) * 2018-07-13 2019-01-01 广州小鹏汽车科技有限公司 A kind of Android APP starting velocity optimization method and system
CN111258740A (en) * 2020-02-03 2020-06-09 北京无限光场科技有限公司 Method and device for starting application program and electronic equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001082121A2 (en) * 2000-04-19 2001-11-01 Microsoft Corporation Pre-computing and encoding techniques for an electronic document to improve run-time processing
CN105630543A (en) * 2015-12-21 2016-06-01 北京奇虎科技有限公司 Application cold start acceleration method and apparatus
CN107943576A (en) * 2017-12-14 2018-04-20 中国平安人寿保险股份有限公司 Starting guide method, apparatus, equipment, system and the medium of application program
CN109117203A (en) * 2018-07-13 2019-01-01 广州小鹏汽车科技有限公司 A kind of Android APP starting velocity optimization method and system
CN111258740A (en) * 2020-02-03 2020-06-09 北京无限光场科技有限公司 Method and device for starting application program and electronic equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114495147A (en) * 2022-01-25 2022-05-13 北京百度网讯科技有限公司 Identification method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
WO2019062304A1 (en) Method, device and system for managing computing resources of block chain node
CN111767143A (en) Transaction data processing method, device, equipment and system
CN110162344B (en) Isolation current limiting method and device, computer equipment and readable storage medium
CN110222535B (en) Processing device, method and storage medium for block chain configuration file
CN110633135A (en) Asynchronous task allocation method and device, computer equipment and storage medium
CN104714804A (en) Track traffic automatic fare collection system reader-writer middleware
CN111694677A (en) Message queue management method, device, terminal and computer-readable storage medium
CN114401250A (en) Address allocation method and device
CN111813517A (en) Task queue allocation method and device, computer equipment and medium
CN112506626A (en) Application program starting method, computer equipment and storage medium
US20240045787A1 (en) Code inspection method under weak memory ordering architecture and corresponding device
CN110908644B (en) Configuration method and device of state node, computer equipment and storage medium
CN115145381A (en) Method, system, storage medium and equipment for remotely resetting BMC chip
CN114791854A (en) User-state virtual machine task scheduling method, device, equipment and storage medium
CN112764729A (en) Application software development method and device, computer equipment and readable storage medium
CN113961364A (en) Large-scale lock system implementation method and device, storage medium and server
CN110058866B (en) Cluster component installation method and device
CN114157662A (en) Cloud platform parameter adaptation method and device, terminal equipment and storage medium
CN113961366A (en) Kernel function calling method of operating system and computer equipment
CN111416780A (en) Real-time priority ceiling optimization method, system, medium and terminal
CN105138898A (en) Method for allocating operation right to application program in intelligent terminal
CN103713962A (en) Method for detecting data chain table and electronic equipment
CN108804144A (en) Control method/system, storage medium and the electronic equipment of os starting
WO2024027515A1 (en) Information transmission method and apparatus, cloud platform, network element, and storage medium
CN110895464B (en) Application deployment method, device and system

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