CN115599610A - Process daemon method and electronic equipment - Google Patents

Process daemon method and electronic equipment Download PDF

Info

Publication number
CN115599610A
CN115599610A CN202211374533.7A CN202211374533A CN115599610A CN 115599610 A CN115599610 A CN 115599610A CN 202211374533 A CN202211374533 A CN 202211374533A CN 115599610 A CN115599610 A CN 115599610A
Authority
CN
China
Prior art keywords
daemon
processes
main process
determining
main
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
CN202211374533.7A
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.)
Avatr Technology Chongqing Co Ltd
Original Assignee
Avatr Technology Chongqing 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 Avatr Technology Chongqing Co Ltd filed Critical Avatr Technology Chongqing Co Ltd
Priority to CN202211374533.7A priority Critical patent/CN115599610A/en
Publication of CN115599610A publication Critical patent/CN115599610A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/20Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements
    • G06F11/202Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where processing functionality is redundant
    • G06F11/2023Failover techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/55Detecting local intrusion or implementing counter-measures
    • 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
    • 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/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/526Mutual exclusion algorithms

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Quality & Reliability (AREA)
  • Computer Hardware Design (AREA)
  • Retry When Errors Occur (AREA)

Abstract

The embodiment of the application discloses a process daemon method and electronic equipment, wherein the process daemon method comprises the following steps: starting a plurality of processes; determining a main process and a plurality of daemon processes in the started plurality of processes, wherein the main process is used for running an application program, and the daemon processes comprise the main process; determining whether the main process fails through each daemon process except the main process; and under the condition that the main process is determined to be invalid, determining a first daemon process in the plurality of daemon processes, taking the first daemon process as a new main process, and running the application program. According to the scheme provided by the application, the main process is simultaneously guarded by the plurality of the daemon processes, so that the probability that the main process is quitted can be reduced.

Description

Process daemon method and electronic equipment
Technical Field
The present application relates to the field of electronic technologies, and in particular, to a process daemon method and an electronic device.
Background
At present, electronic devices usually include a security application, and a system of the electronic device is protected by the security application. After the security application is started, the electronic device may implement the function of the security application through a process (i.e., a host process) corresponding to the security application. And when the safety application program exits from operation, the system of the electronic equipment cannot be protected.
In order to avoid the security of the system of the electronic device from being reduced due to the host process being out of operation, the host process is usually protected by a daemon process. Namely, when the daemon monitors that the main process quits operation, the daemon restarts the main process, so that the security main process can be ensured to be in an operating state.
However, when the daemon process is exited first, or when both the daemon process and the main process are exited, the main process cannot be restarted, which results in the reduction of the security of the system of the electronic device.
Disclosure of Invention
The embodiment of the application provides a process daemon method and electronic equipment, which can prevent a main process corresponding to a security application program from being restarted, so that the security of a system of the electronic equipment is improved.
In order to achieve the above purpose, the embodiment of the present application adopts the following technical solutions:
in a first aspect, an embodiment of the present application provides a process daemon method applied to an application program of an electronic device, where the process daemon method may include: starting a plurality of processes; determining a main process and a plurality of daemon processes in the started plurality of processes, wherein the main process is used for running an application program, and the daemon processes comprise the main process; determining whether the main process fails through each daemon process except the main process; and under the condition that the main process is determined to be invalid, determining a first daemon process in the plurality of daemon processes, and taking the first daemon process as a new main process and running the application program.
Based on the method of the first aspect, it may be determined whether the host process fails through each of the multiple daemon processes, that is, the host process may be simultaneously guarded by the multiple daemon processes, and when the host process fails, one daemon process may be determined among the multiple daemon processes as a new host process to run an application program.
With reference to the first aspect, in another possible implementation manner, the process daemon method may further include determining, by the second daemon process, whether the third daemon process is failed; the second daemon process is each daemon process except the main process in the plurality of daemon processes; the third daemon process comprises a daemon process except the second daemon process and the main process in the plurality of daemon processes; in the event that it is determined that the third daemon process is to fail, a new daemon process is created.
Based on the possible implementation mode, whether other daemon processes are invalid or not can be monitored through each daemon process except the main process, and a new daemon process is created under the condition that the other daemon processes are invalid, so that the number of daemon processes can be guaranteed to be unchanged, the probability that the main process is quitted can be further reduced, and the safety of the electronic equipment is further improved.
With reference to the first aspect, in another possible implementation manner, the process daemon method may further include determining, by the host process, whether each daemon process, except the host process, of the plurality of daemon processes is invalid; in the event that it is determined that any of the plurality of daemons other than the host process has failed, a new daemon process is created.
Based on the possible implementation manner, the main process can also monitor whether other daemon processes except the main process fail, and a new daemon process is created under the condition that other daemon processes except the main process fail, so that the number of daemon processes is unchanged, the probability that the main process is quitted can be further reduced, and the safety of the electronic equipment can be improved.
With reference to the first aspect, in another possible implementation manner, the determining a host process and a plurality of daemon processes in the plurality of started processes may include: determining a plurality of daemons based on the plurality of processes; based on the multiple daemon processes, multiple mutually exclusive locks respectively corresponding to the multiple daemon processes are created; according to the multiple mutual exclusion locks, a main process and multiple daemon processes except the main process are determined in the multiple processes, the state of the mutual exclusion lock corresponding to the main process is a first state, the state of the mutual exclusion lock corresponding to the daemon processes except the main process is a second state, and the first state is different from the second state.
Based on the possible implementation mode, a plurality of daemons can be determined in the created plurality of processes through the mutual exclusion lock, the main process is determined in the plurality of daemons, one main process can be determined to be used for running the application program, and other daemons except the main process can simultaneously daemons the main process, so that the application program can be prevented from being run by the plurality of processes, and the waste of resources of the electronic equipment is avoided.
With reference to the first aspect, in another possible implementation manner, the determining the first daemon process in the multiple daemon processes may include: according to the mutual exclusion locks corresponding to the multiple daemon processes, a first daemon process is determined in the other daemon processes except the main process in the multiple daemon processes, the state of the mutual exclusion lock corresponding to the first daemon process is a first state, and the state of the mutual exclusion lock corresponding to the other daemon processes except the first daemon process and the main process in the multiple daemon processes is a second state.
Based on the possible implementation, a second daemon process which can replace the main process can be determined in the plurality of created daemon processes through mutual exclusion lock, the method can determine a daemon process which can replace a main process, thereby avoiding a plurality of processes from running the application program and avoiding the waste of resources of the electronic equipment.
With reference to the first aspect, in another possible implementation manner, before starting a plurality of processes, the process daemon method may further include acquiring resource information of the electronic device; determining the number of creatable processes according to the resource information; a plurality of processes are created according to the number of processes that can be created.
Based on the possible implementation mode, the number of the processes which can be created can be determined and a plurality of processes can be created according to the resource use condition of the electronic equipment, more processes can be created under the resource use condition according with the electronic equipment, so that more daemon processes can defend the main process, the probability that the main process is quitted can be further reduced, and the safety of the electronic equipment can be improved.
In a second aspect, an embodiment of the present application provides a process daemon device, where the process daemon device may be applied to an electronic device, and is used to implement the method in the first aspect. The function of the process daemon device can be realized by hardware, and can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the above functions, for example, an activation module and a determination module, etc.
The starting module can be used for starting a plurality of processes.
The determining module can be used for determining a main process and a plurality of daemon processes in the started plurality of processes, wherein the main process is used for running the application program, and the daemon processes comprise the main process;
the determining module is further used for determining whether the main process fails or not through each daemon process except the main process;
the determining module is further used for determining a first daemon process in the plurality of daemon processes under the condition that the main process is determined to be invalid, taking the first daemon process as a new main process and running the application program.
With reference to the second aspect, in a possible implementation manner, the determining module may be further configured to determine whether the third daemon process fails through the second daemon process; the second daemon process is each daemon process except the main process in the plurality of daemon processes; the third daemon includes a daemon of the plurality of daemons except the second daemon and the main process.
The process daemon device further comprises a creation module.
And the creating module can be used for creating a new daemon process under the condition that the third daemon process is determined to be invalid.
With reference to the second aspect, in a possible implementation manner, the determining module may be further configured to determine, by the host process, whether each daemon process, except for the host process, in the multiple daemon processes is failed.
The creating module can be further used for creating a new daemon process under the condition that any daemon process except the main process in the plurality of daemon processes is determined to be invalid.
With reference to the second aspect, in a possible implementation manner, the creating module may be further configured to determine, based on the multiple processes, multiple daemon processes; based on the multiple daemon processes, multiple mutually exclusive locks corresponding to the multiple daemon processes are created.
The determining module may be further configured to determine, according to the multiple mutexes, the host process and the multiple daemons except the host process in the multiple processes, where a state of the mutex corresponding to the host process is a first state, and a state of the mutex corresponding to the multiple daemons except the host process is a second state, where the first state is different from the second state.
With reference to the second aspect, in a possible implementation manner, the determining module may be further configured to determine, according to the mutex lock corresponding to the multiple daemon processes, a first daemon process in the daemon processes except the main process, where a state of the mutex lock corresponding to the first daemon process is a first state, and a state of the mutex lock corresponding to the daemon processes except the first daemon process and the main process is a second state.
With reference to the second aspect, in a possible implementation manner, the process daemon device may further include an obtaining module.
The acquisition module may be configured to acquire resource information of the electronic device.
The determining module may be further configured to determine a number of creatable processes according to the resource information.
The creating module can be further used for creating a plurality of processes according to the number of the creatable processes.
In a third aspect, a process daemon device is provided, where the process daemon device has a function of implementing the method of the first aspect. The function can be realized by hardware, and can also be realized by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the functions described above.
In a fourth aspect, a process daemon device is provided, which includes: a processor and a memory; the memory is used for storing computer execution instructions, and when the process daemon device runs, the processor executes the computer execution instructions stored by the memory, so that the process daemon device executes the process daemon method according to any one of the first aspect.
In a fifth aspect, a process daemon device is provided, which comprises: a processor; the processor is configured to be coupled to the memory, and after reading the instruction in the memory, execute the process daemon method according to any one of the above first aspects according to the instruction.
In a sixth aspect, embodiments of the present application provide a computer-readable storage medium having computer program instructions stored thereon. The computer program instructions, when executed by the electronic device, cause the electronic device to implement the process daemon method of the first aspect or any one of the possible implementations of the first aspect.
In a seventh aspect, an embodiment of the present application provides a computer program product, which includes computer readable code and when the computer readable code is run in an electronic device, causes the electronic device to implement the process daemon method according to the first aspect or any one of the possible implementation manners of the first aspect.
In an eighth aspect, an apparatus (e.g., the apparatus may be a system-on-a-chip) is provided that includes a processor for enabling an electronic device to implement the functionality referred to in the first aspect above. In one possible design, the apparatus further includes a memory for storing program instructions and data necessary for the electronic device. When the device is a chip system, the device may be composed of a chip, or may include a chip and other discrete devices.
It should be understood that the beneficial effects of the second to eighth aspects can be referred to the related description of the first aspect, and are not repeated herein.
Drawings
Fig. 1 is a schematic hardware structure diagram of an electronic device according to an embodiment of the present disclosure;
fig. 2 is a first flowchart illustrating a process daemon method according to an embodiment of the present disclosure;
fig. 3 is a schematic flowchart illustrating a process daemon method according to an embodiment of the present application;
fig. 4 is a schematic flowchart of a process daemon method according to an embodiment of the present application;
fig. 5 is a schematic flowchart illustrating a process of determining a host process and a plurality of daemon processes according to an embodiment of the present application;
fig. 6 is a schematic flowchart of creating multiple processes according to an embodiment of the present application;
fig. 7 is a fourth schematic flowchart of a process daemon method according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a process daemon device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present application, "a plurality" means two or more unless otherwise specified.
At present, electronic devices usually include a security application or some special applications, and the application is started and then runs in the form of a process. For the security application program, the security application program is operated in the form of a process after being started, so that the system of the electronic device is protected.
In order to avoid the reduction of the security of the system of the electronic device, the secure application needs to be always running, that is, the process corresponding to the secure application needs to be always running. When the security application exits from running, if the security application exits abnormally or is ended maliciously, that is, the process corresponding to the security application exits from running, the system of the electronic device cannot be protected.
In order to avoid the security application from being removed from operation and causing the system of the electronic device to be degraded, the security application is usually monitored by a daemon process. When the daemon process monitors that the safety application program exits from running, the daemon process restarts the safety application program, so that the safety application program can be ensured to be in a running state.
However, when the daemon process is exited first, if the security application is also exited, the security application cannot be restarted, which results in a reduction in the security of the system of the electronic device. Or, when the daemon process and the process corresponding to the security application are simultaneously abnormally exited, the security application cannot be restarted, which may also result in a reduction in the security of the system of the electronic device.
That is, the conventional way of daemon (i.e., keeping alive the process corresponding to the security application, which may also be referred to as daemon the process corresponding to the security application) is performed by a daemon. Before starting the process (i.e. the protected process) corresponding to the security application, a daemon process is started. And then starting the protected process, monitoring the state of the protected process in real time by the daemon process after the protected process is abnormal or is forcibly ended (namely the protected process is quit to run), and actively restarting the protected process by the daemon process when detecting that the protected process does not exist. If the daemon is ended first (i.e. the daemon exits from running first), the protected process will lose protection and cannot be restarted.
In the related technology, the protected process can be kept alive through mutual protection of a main process and a father process, namely, the father process (namely, the protected process) is used as a main process to process business and monitors the state of a subprocess by using a system function, and if the subprocess (namely, the guarded process) is abnormal, the subprocess is recovered and is reestablished; when the father process is abnormal, the child process switches itself to be the main process, creates a service processing thread, and creates a child process at the same time, and forms mutual guard again. However, when the parent process and the child process are maliciously closed at the same time, that is, the parent process and the child process are quitted from running at the same time, then the parent process (i.e., the protected process) cannot be restarted, so that the related art does not well solve the problem that the security application cannot be restarted, which causes the system security of the electronic device to be low.
In view of the foregoing problems, an embodiment of the present invention provides a process daemon method, which is applied to an electronic device. In some embodiments, the electronic device may be a mobile phone, a tablet computer, a handheld computer, a Personal Computer (PC), a cellular phone, a Personal Digital Assistant (PDA), a wearable device, or other electronic devices. The embodiments of the present application do not limit the specific form of the electronic device.
Fig. 1 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 1, the electronic device 100 may include: at least one processor 101, a communication link 102, a memory 103, and a communication interface 104.
Among other things, the processor 101 may perform various functions of the electronic device 100 by running or executing software programs stored in the memory 103, as well as invoking data stored in the memory 103.
In one embodiment, the electronic device 100 may include one processor or may include a plurality of processors. Each of these processors may be a single-Core Processor (CPU) or a multi-Core Processor (CPU). A processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (e.g., computer program instructions).
The Memory 103 may be a Read-Only Memory (ROM) or other types of static storage devices that can store static information and instructions, a Random Access Memory (RAM) or other types of dynamic storage devices that can store information and instructions, an Electrically Erasable Programmable Read-Only Memory (EEPROM), a Compact Disc Read-Only Memory (CD-ROM) or other optical Disc storage, optical Disc storage (including Compact Disc, laser Disc, optical Disc, digital versatile Disc, blu-ray Disc, etc.), a magnetic Disc storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to such. The memory 103 may be separate and coupled to the processor 101 via a communication link 102. The memory 103 may also be integrated with the processor 101.
The memory 103 is used for storing software programs for executing the scheme of the application, and is controlled by the processor 101 to execute.
The communication interface 104, which may be any transceiver or the like, is used for communicating with other devices or communication networks.
The communication line 102 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one line is shown in FIG. 1, but that does not indicate only one bus or type of bus.
The device architecture shown in fig. 1 does not constitute a limitation of the electronic device 100, and the electronic device 100 may include more or fewer components than shown, or combine certain components, or a different arrangement of components.
The process daemon method provided by the embodiment of the application is described in detail below with reference to the accompanying drawings.
The following describes a process daemon method provided by the embodiment of the present application with reference to fig. 2, where the method may be executed by an electronic device. As shown in FIG. 2, the process daemon method may include the following S201-S204.
S201, starting a plurality of processes.
In some examples, an execution subject of the process daemon method provided by the embodiment of the present application may be an electronic device, and the electronic device may include an application program.
In some examples, the application may be a security application of the electronic device. The system of the electronic device may be protected after the secure application is run (which may also be referred to as booted). After the security application exits from running, the security application cannot protect the system of the electronic device. Therefore, when the application is a secure application, the secure application needs to be in a running state all the time, so that the security of the system of the electronic device can be ensured.
In some examples, when an application included in the electronic device needs to be run, the electronic device may receive an operation of starting the application, and the electronic device may start a plurality of processes, so that a main process may be determined from the plurality of processes, and the main process is used for running the secure application.
In other examples, the application may be other applications of the electronic device, such as some special applications.
In some embodiments, multiple processes may be created before they are started. Creating the plurality of processes may include: and determining the number of created processes according to the resource information of the electronic equipment. Then, a plurality of processes are created according to the number of creatable processes. The number of the processes which can be created can be determined and a plurality of processes can be created according to the resource use condition of the electronic equipment, and more processes can be created under the resource use condition of the electronic equipment, so that more daemon processes can defend the main process, the probability that the main process is quitted can be further reduced, and the safety of the electronic equipment can be improved.
In some examples, the resource information of the electronic device may include memory information of the electronic device, cache information of the electronic device, CPU utilization of the electronic device, and the like, which may be used to determine the number of processes that the electronic device is capable of creating.
S202, determining a main process and a plurality of daemon processes in the started plurality of processes, wherein the main process is used for running the application program, and the daemon processes comprise the main process.
After the plurality of processes are started, a host process and a plurality of daemon processes can be determined from the plurality of started processes. The host process may be used to run the application program, and the multiple daemons may be used to daemons the host process, that is, the multiple daemons may be used to monitor whether the host process is out of order.
The daemon process may comprise a host process. In some examples, determining the host process and the plurality of daemons among the plurality of processes launched may include: based on the multiple processes, multiple daemons are determined. And then, determining the main process and a plurality of daemons except the main process based on the plurality of daemons and the corresponding mutual exclusion locks.
For example, among the plurality of processes that are started, determining a host process and a plurality of daemons may include: determining a plurality of daemons based on the plurality of processes; the method includes the steps of establishing a plurality of mutual exclusion locks corresponding to a plurality of daemon processes respectively based on the plurality of daemon processes, establishing a plurality of mutual exclusion locks corresponding to the plurality of daemon processes respectively, wherein the states of the mutual exclusion locks can comprise a first state and a second state, and when the state of the mutual exclusion lock is the first state, the daemon process corresponding to the mutual exclusion lock can be used for achieving the function of a first application program. Thereafter, the host process may be determined among the plurality of daemon processes based on the plurality of mutually exclusive locks. The state of the mutual exclusion lock corresponding to the main process is a first state, the state of the mutual exclusion lock corresponding to other daemon processes except the main process is a second state, and the first state is different from the second state.
That is to say, when the state of the mutex lock corresponding to one daemon process of the multiple daemon processes is the first state, it may be determined that the daemon process is a main process, that is, the main process is used to run the application program, so as to implement the function of the application program. When the daemon process is determined to be the main process, the states of other daemon processes are the second state and cannot be the first state, namely, the other daemon processes cannot be the main process. Namely, the main process and the multiple daemon processes can be determined in the multiple created processes through the mutual exclusion lock, and one main process can be determined to be used for realizing the function of the first application program, so that the multiple processes can be prevented from realizing the function of the first application program, and the waste of resources of the electronic equipment is avoided.
S203, determining whether the main process fails through each daemon process except the main process.
After determining the host process and the plurality of daemon processes among the plurality of processes that are started, whether the host process is out of order may be determined by each daemon process except the host process.
In some examples, determining whether the host process has failed (i.e., determining whether the host process is out of service) by each daemon other than the host process may include: and acquiring the identifier of the main process through each daemon process, and determining whether the main process fails or not through the identifier of the main process.
In the case where the main process fails, a new main process may be determined among the plurality of daemon processes, that is, the following S204 may be continuously performed. In the case where the main process has not failed, it may be continuously determined whether the main process has failed by each daemon other than the main process, that is, the above-described S203 may be continuously performed.
S204, determining a first daemon process in the plurality of daemon processes, taking the first daemon process as a new main process, and running the application program.
In some examples, determining the first daemon process in the plurality of daemon processes may include: and determining the first daemon process according to the mutual exclusion locks corresponding to the plurality of daemon processes.
For example, determining the first daemon process according to the mutual exclusion lock corresponding to the multiple daemon processes may include: according to the mutual exclusion locks corresponding to the multiple daemon processes, a first daemon process is determined in the other daemon processes except the main process in the multiple daemon processes, the state of the mutual exclusion lock corresponding to the first daemon process is a first state, and the state of the mutual exclusion lock corresponding to the other daemon processes except the first daemon process and the main process in the multiple daemon processes is a second state. After determining the first daemon process, the application may be run with the first daemon process as a new host process. Namely, the first daemon process capable of replacing the main process can be determined in the multiple created daemon processes through the mutual exclusion lock, namely, the daemon process capable of replacing the main process can be determined, so that the multiple processes can be prevented from realizing the function of the first application program, and the waste of resources of the electronic equipment is avoided.
It should be noted that, after determining the first daemon process among the multiple daemon processes and taking the first daemon process as a new main process and running the application program, it may be continued to determine whether the new main process fails through each daemon process except the main process, so that the main process may be circularly daemon through each daemon process except the main process, and the probability that the main process is exited may be reduced.
According to the scheme, after the starting operation of the application program is received, the multiple processes can be started, the main process for running the application program is determined in the multiple processes, and the multiple daemon processes for keeping the main process alive are determined. The method comprises the steps that whether a main process fails or not is determined through each daemon process in a plurality of daemon processes, namely the main process can be simultaneously guarded by the plurality of daemon processes, and when the main process fails, one daemon process can be determined to be used as a new main process to run an application program in the plurality of daemon processes.
The present application further provides a process daemon method, as shown in fig. 3, the method further includes the following S205-S206.
S205, determining whether the third daemon process is invalid or not through a second daemon process, wherein the second daemon process is each daemon process except the main process in the plurality of daemon processes; the third daemon includes a daemon of the plurality of daemons except the second daemon and the main process.
By each daemon (i.e., the second daemon) except the main process, it is possible to determine whether not only the main process fails, but also whether other daemons (i.e., the daemon except the second daemon and the main process among the plurality of daemons, referred to as a third daemon) fail.
In some examples, determining, by the second daemon, whether the third daemon has failed may include: and acquiring the identifier of the third daemon process through the second daemon process, and determining whether the third daemon process is invalid or not through the identifier of the third daemon process.
In the case that the third daemon process fails, a new daemon process may be created, for example, a new daemon process is created, that is, the following S206 may be continuously executed. If the third daemon process is not disabled, the second daemon process may continue to daemon the third daemon process, that is, the foregoing S205 may continue to be executed.
It should be noted that, the present application does not limit the execution sequence of S203-S204 in fig. 2 and S205 in fig. 3. In the embodiment of the present application, S203-S204 are performed before S205 for schematic explanation.
S206, creating a new daemon process.
Under the condition that the second daemon process determines that the third daemon process is invalid, a new daemon process can be created, so that the number of daemon processes is unchanged, the probability that the main process is quitted can be further reduced, and the safety of the electronic equipment can be improved.
After determining that the third daemon process is invalid and creating a new daemon process through the second daemon process, the second daemon process may continue to determine whether the third daemon process is invalid, that is, may continue to execute the above S205, so that the second daemon process may cyclically daemon the third daemon process, and the probability that the third daemon process is exited may be reduced.
In some embodiments, after determining that the third daemon process fails through the second daemon process and creating a new daemon process, the second daemon process may continue to determine whether the main process fails, that is, the above S203 may continue to be performed, so that the main process and the third daemon process may be circularly guarded through the second daemon process.
It should be noted that after the new daemon process is created, the new daemon process can daemon the host process, that is, the new daemon process can determine whether the host process fails. The new daemon process may also daemon other daemon processes, that is, the new daemon process may determine whether the other daemon processes are out of order, and at this time, the new daemon process may be a second daemon process.
According to the scheme in the embodiment of the application, whether other daemon processes are invalid or not can be monitored through each daemon process except the main process, and a new daemon process is created under the condition that the other daemon processes are invalid, so that the number of daemon processes can be guaranteed to be unchanged, the probability that the main process is quitted can be further reduced, and the safety of the electronic equipment is further improved.
The present application further provides a process daemon method, as shown in fig. 4, the method further includes the following steps S207 to S208.
S207, determining whether each daemon process except the main process in the plurality of daemon processes is invalid or not through the main process.
According to the scheme, whether each daemon process except the main process fails or not can be determined through the main process.
In some examples, determining, by the host process, whether each of the plurality of daemons other than the host process fails may include: the method comprises the steps that the main process obtains the identification of each daemon process except the main process in the multiple daemon processes, and whether the daemon process fails or not is determined according to the identification of each daemon process except the main process in the multiple daemon processes.
In the case where it is determined that any daemon process other than the main process among the plurality of daemon processes is out of order, a new daemon process may be created, that is, the following S208 may be continuously performed. If none of the daemons other than the host process in the multiple daemons fails, the host process may continue to perform the daemons on the daemons other than the host process in the multiple daemons, that is, the step S207 may continue to be performed.
It should be noted that, the present application does not limit the execution sequence of S203-S204 in fig. 2, S205-S206 in fig. 3, and S207 in fig. 4. In the embodiment of the present application, S203-S204 are performed before S205, and S207 is performed after S205-S206.
And S208, creating a new daemon process.
When the main process determines that any daemon process except the main process in the plurality of daemon processes is invalid, a new daemon process can be created, so that the number of daemon processes is unchanged, the probability that the main process is quitted can be further reduced, and the safety of the electronic equipment can be improved.
After determining that any daemon process except the main process in the multiple daemon processes is invalid through the main process and creating a new daemon process, the main process can continuously determine whether each daemon process except the main process in the multiple daemon processes is invalid, and the new daemon process can be each daemon process except the main process in the multiple daemon processes, namely the step S207 can be continuously executed, so that the main process can circularly defend any daemon process except the main process in the multiple daemon processes, and the probability that any daemon process except the main process in the multiple daemon processes is quitted can be reduced.
It should be noted that after the new daemon process is created, the new daemon process can daemon the host process, that is, the new daemon process can determine whether the host process fails. The new daemon can also daemon other daemons, i.e., the new daemon can determine whether the other daemons fail, at which time the new daemon can be the second daemon.
According to the scheme in the embodiment of the application, the main process can also monitor whether other daemon processes except the main process are invalid, and the new daemon process is created under the condition that other daemon processes except the main process are invalid, so that the number of daemon processes can be guaranteed to be unchanged, the probability that the main process is quitted can be further reduced, and the safety of the electronic equipment can be improved.
In some examples, determining the host process and the plurality of daemons among the plurality of processes launched may include: based on the multiple processes, multiple daemons are determined. And determining the main process and a plurality of daemons except the main process based on the plurality of daemons and the corresponding mutual exclusion locks. The following describes schematically a process of determining a host process and a plurality of daemon processes among the plurality of started processes, with reference to fig. 5. As shown in fig. 5, among the plurality of processes, the process of determining the host process and the plurality of daemon processes may include the following S501 to S503.
S501, determining a plurality of daemon processes based on the started processes.
In some examples, after the plurality of processes are started, a portion of the plurality of started processes may be determined as a daemon process for guarding the main process, i.e., the daemon process is used to determine whether the main process fails.
In other examples, after the plurality of processes are launched, all of the plurality of launched processes may be determined to be daemons.
S502, based on the multiple daemon processes, multiple mutually exclusive locks corresponding to the multiple daemon processes are created.
After the multiple daemon processes are determined, multiple mutually exclusive locks corresponding to the multiple daemon processes can be created according to the multiple daemon processes, and therefore the main process and the multiple daemon processes are determined according to the multiple mutually exclusive locks corresponding to the multiple daemon processes.
In some examples, according to a plurality of daemons, when a plurality of mutually exclusive locks respectively corresponding to the plurality of daemons are created, corresponding process lists may also be generated. The process list may correspond to mutexes, for example, the process list may include lists corresponding to multiple daemons, each list may correspond to a daemon, and each list may correspond to a mutex (i.e., each daemon corresponds to a mutex).
The process list may be used to store information for each daemon. The mutual exclusion lock can be used for determining a main process from a plurality of determined daemon processes, so that the application program can be prevented from being simultaneously operated by a plurality of processes.
In some examples, the process list may include an identification of each daemon process, such as an Identity Document (ID) of the process. Whether the daemon process is in a running state or not can be determined through the identification of the process. For example, the electronic device may call the daemon process through the identification of the process, thereby determining whether the daemon process is in a running state.
For example, after determining N daemons, N may be an integer greater than or equal to 3, a process list of N +1 and N +1 mutually exclusive locks may be generated.
As shown in table 1, after N daemon processes are determined, the computer may generate a process list (i.e., the 0 th list to the nth list) of N +1 and N +1 mutexes (i.e., the 0 th mutex to the nth mutex), where the 1 st list in the process list has a corresponding identifier of a first daemon process, and the 1 st list corresponds to the first mutex. The corresponding identifier of the 2 nd list in the process list is the identifier of the second daemon process, and the 2 nd list corresponds to the second mutex lock. The corresponding identifier of the Nth list in the process list is the identifier of the Nth daemon process, and the Nth list corresponds to the Nth mutual exclusion lock. That is, after N daemons are determined, each daemon process corresponds to one of the process lists, and each daemon process corresponds to one mutex lock.
It should be noted that, the 0 th list in the process list may correspond to an identifier of the host process, and the 0 th mutual exclusion lock may be a mutual exclusion lock corresponding to the host process. The host process may be a process determined from the N daemon processes.
That is, after the N daemons are determined, a process list of N +1 and N +1 mutually exclusive locks are generated. Then, each daemon process may correspond to one of the process lists, and each daemon process may correspond to one of the mutexes. Then, a main process can be determined from the multiple daemon processes, and the main process is corresponding to the 0 th list in the process list and the 0 th exclusive lock.
TABLE 1
Figure BDA0003918784250000091
Figure BDA0003918784250000101
It should be noted that after the N +1 process list and the N +1 mutexes are generated, the N daemons may be corresponding to the process list in a preset order, or the N daemons may be corresponding to the process list out of order. In the embodiment of the present application, the sequence of the N daemons in the process list is not limited. For example, the electronic device can randomly assign or automatically schedule the order of the N daemons in the process list.
S503, according to the plurality of mutual exclusion locks, determining a main process and a plurality of daemon processes except the main process in the plurality of processes, wherein the state of the mutual exclusion lock corresponding to the main process is a first state, the state of the mutual exclusion lock corresponding to the daemon processes except the main process is a second state, and the first state is different from the second state.
After creating the plurality of mutually exclusive locks respectively corresponding to the plurality of daemon processes, the main process and the plurality of daemon processes other than the main process may be determined among the plurality of daemon processes according to the plurality of mutually exclusive locks. The state of the mutual exclusion lock corresponding to the main process can be a first state. The state of the mutual exclusion lock corresponding to the plurality of daemons except the main process can be the second state. The first state is different from the second state.
In some examples, when a plurality of mutually exclusive locks respectively corresponding to a plurality of daemons are created according to the plurality of daemons and a corresponding process list is generated, the main process and the plurality of daemons other than the main process may be determined through the process list and the mutually exclusive locks.
In some examples, determining the host process through the process lists and the mutex locks may include, after the corresponding process lists and the mutex locks are generated, simultaneously acquiring permissions of the mutex locks corresponding to the host process (that is, permissions of a 0 th mutex lock corresponding to a 0 th list in the process lists) by multiple daemon processes corresponding to the process lists, and when one daemon process acquires the permissions of the mutex locks corresponding to the host process, the daemon process may be determined as the host process, and the other daemon processes cannot serve as the host process.
For example, continuing with Table 1, after N daemons are determined, a list of N +1 processes and N +1 mutually exclusive locks are generated. Each daemon process may then correspond to one of the process lists, and each daemon process may correspond to one mutex. Then, the N daemon processes may simultaneously acquire the authority of the 0 th mutual exclusion lock, and when the xth daemon process acquires the authority of the 0 th mutual exclusion lock, the electronic device may determine that the xth daemon process is a main process, and other daemon processes cannot acquire the authority of the 0 th mutual exclusion lock any more. The electronic device may correspond the identifier of the xth daemon process to the identifier corresponding to the 0 th list in the process list.
In some examples, when a daemon process acquires the right of a mutex lock corresponding to a host process, it may first determine whether the host process currently exists through a process list. When it is determined that the main process does not exist currently, the daemon process for acquiring the authority of the mutual exclusion lock corresponding to the main process can be determined as the main process.
When determining that the main process currently exists, whether the existing main process is in a running state can be determined through the identification of the existing main process. When the existing host process is in a running state, the daemon process that acquires the authority of the mutex lock corresponding to the host process may not be determined as the host process.
When the existing host process is not in a running state, the daemon process that acquires the authority of the mutex lock corresponding to the host process can be determined as the host process.
For example, continuing with Table 1, after N daemons are determined, a list of N +1 processes and N +1 mutually exclusive locks are generated. Each daemon process may then correspond to one of the process lists, and each daemon process may correspond to one mutex. Then, the N daemon processes may obtain the authority of the 0 th mutex at the same time, when the xth daemon process obtains the authority of the 0 th mutex, it may be determined whether the corresponding identifier exists in the 0 th list in the process list, and when the corresponding identifier does not exist in the 0 th list, it may be determined that the host process does not exist currently. The xth daemon process may be determined to be the main process, and the identifier of the xth daemon process may be corresponding to the identifier corresponding to the 0 th list in the process list.
When the corresponding identifier exists in the 0 th list, it may be determined that the host process already exists currently, and it is determined whether the host process already exists currently in a running state through the identifier corresponding to the 0 th list. When the currently existing host process is in a running state, the xth daemon process may not be determined as the host process.
When the currently existing main process is not in a running state, X daemon processes may be determined as the main process, and the identifier of the X daemon process is corresponding to the identifier corresponding to the 0 th list in the process list.
According to the scheme, the multiple daemon processes can be determined in the multiple established processes through the mutual exclusion lock, the main process can be determined in the multiple daemon processes, one main process can be determined to be used for running the application program, other daemon processes except the main process can simultaneously daemon the main process, the application program can be prevented from running by the multiple processes, and waste of resources of the electronic equipment is avoided.
In some examples, multiple processes may be created before they are started. A plurality of processes are created, and the number of creatable processes can be determined and the plurality of processes can be created for the resource usage in conjunction with the electronic device. The process of creating multiple processes is schematically described below in conjunction with the illustration of fig. 6. As shown in FIG. 6, creating multiple processes may include the following S601-S605.
S601, acquiring resource information of the electronic equipment.
After receiving an operation of starting the first application program, in response to the operation, configuration information of the electronic device may be acquired, so that the electronic device may determine the number of creatable processes according to the configuration information (which may also be referred to as resource information in this embodiment).
In some examples, the configuration information of the electronic device may include memory information of the electronic device, cache information of the electronic device, CPU utilization of the electronic device, and the like, which may be used to determine the number of processes that the electronic device is capable of creating. The configuration information of the electronic device may further include other information that may be used to determine the number of processes that the electronic device can create, which is not limited in this embodiment of the application.
S602, determining the number of the creatable processes according to the resource information.
After determining the configuration information of the electronic device, the number of creatable processes may be determined according to the configuration information, so that a corresponding number of processes may be created according to the number of creatable processes.
In some examples, the number of creatable processes may be multiple, e.g., the number of creatable processes may be three or more. The number of the creatable processes can be the first number of the processes which can be created according to the configuration information of the electronic equipment, and the more the number of the created processes is, the lower the possibility that all the processes are forced to quit operation is, so that the main program can be ensured to be kept alive by other daemon processes when the main program quits operation, namely, other daemon processes defend the main application program, the availability of the main process is ensured, the continuity of the main process is also ensured, and namely, the service of the application program corresponding to the main process cannot be interrupted.
S603, according to the number of the creatable processes, creating a plurality of processes.
After determining the number of creatable processes according to the configuration information, a plurality of processes may be created according to the number of creatable processes, for example, the electronic device may create three or more processes, the created plurality of processes may determine a plurality of daemons by the plurality of processes, and determine a main process from the plurality of daemons.
In some examples, after determining the number of creatable processes according to the configuration information, a plurality of processes may be created, and each process of the created plurality of processes may be used to run the application program to implement the function of the application program.
According to the scheme, the number of the processes which can be created can be determined and the multiple processes can be created by combining the resource using condition of the electronic equipment, more processes can be created under the resource using condition which accords with the resource using condition of the electronic equipment, so that more daemon processes can defend the main process, the probability that the main process is quitted can be further reduced, and the safety of the electronic equipment can be improved.
For ease of understanding, referring to fig. 7 below, after the host process and the plurality of daemons are determined among the plurality of processes that are started, the host process is daemon by the daemons (i.e., it is determined whether the host process has failed), the process daemon method in the embodiment of the present application is schematically described by taking an example in which the daemon process performs daemon on other daemon processes (that is, determines whether other daemon processes are invalid) and determining whether a main process is invalid by taking determination of whether the main process is invalid as an identifier of the main process.
S701, acquiring the identification of the main process in the process list through a second daemon process, wherein the second daemon process is each daemon process except the main process in the plurality of daemon processes.
The identification of the main process in the process list is determined and obtained through each daemon process (namely, the second daemon process) except the main process, so that whether the main process is invalid or not can be determined according to the identification of the main process, namely, each daemon process except the main process can perform protection on the main process. Each daemon process except the main process can acquire the identification of the main process in the process list and determine whether the main process is invalid or not according to the identification of the main process, so that each daemon process except the main process can simultaneously defend the main process.
For example, continuing with Table 1 above, after N daemons are determined, a list of N +1 processes and N +1 mutually exclusive locks are generated. Then, the host process may be determined from the N daemon processes, and the identifier of the host process may be mapped to the identifier corresponding to the 0 th list in the process list. And then, each daemon process except the main process can acquire the identifier corresponding to the 0 th list through the process list, so that each daemon process except the main process can determine whether the main process quits operation or not through the identifier of the main process.
S702, determining whether the main process is invalid or not through the identification of the main process.
After each daemon process except the main process acquires the identification of the main process in the process list, whether the main process is invalid or not can be determined through the identification of the main process, namely whether the main process exits from running or not is determined.
In some examples, determining whether the host process has failed, via the identification of the host process, may include, via the identification of the host process, invoking the host process to determine whether the host process is in a running state (i.e., whether to exit from running).
When the host process is determined to exit from the operation by the identifier of the host process, that is, when the host process is determined to be invalid, a new host process can be re-determined from the plurality of daemon processes by the process list and the mutex lock, so that the functions of the application program can be ensured to be continuous, that is, the following S703 can be continuously executed. Under the condition that the host process is determined not to exit from running through the identifier of the host process, that is, the host process is determined not to be invalid, each daemon process except the host process can continue to acquire identifiers of other daemon processes in the process list, so that whether the other daemon processes are invalid or not can be determined according to the identifiers of the other daemon processes, that is, the electronic device can continue to execute the following S704.
S703, determining a new main process in the plurality of daemon processes through the process list and the mutual exclusion lock.
In the case of determining that the main process fails, a new main process can be determined among the plurality of daemons through the process list and the mutual exclusion lock.
In some examples, determining a new main process in multiple daemon processes through the process list and the mutex lock may include that multiple daemon processes corresponding to the process list may simultaneously acquire the authority of the mutex lock corresponding to the main process, when one daemon process acquires the authority of the mutex lock corresponding to the main process, the daemon process may determine that the daemon process is the new main process, and other daemon processes may not serve as the new main process. That is, the state of the mutex lock corresponding to the new host process is the first state, the state of the mutex lock corresponding to the other daemon process is the second state, and the first state is different from the second state.
It should be noted that after determining a new main process in the multiple daemons through the process list and the mutex lock, each of the daemons except the main process may continue to acquire the identifiers of the other daemons in the process list, so as to determine whether the other daemons fail, and thus the following S704 may be continuously executed.
S704, acquiring the identifier of a third daemon process in the process list through the second daemon process, wherein the third daemon process comprises daemon processes except the second daemon process and the main process in the plurality of daemon processes.
After determining whether the host process is out of order through each daemon process (i.e., the second daemon process) except the host process, the second daemon process may continue to acquire an identifier of a third daemon process in the process list, and the third daemon process may include the daemon processes except the second daemon process and the host process among the plurality of daemon processes.
S705, determining whether the third daemon process is invalid or not according to the identifier of the third daemon process.
In the case that it is determined that the third daemon process is out of order (i.e., it is determined whether the third daemon process exits from running) according to the identifier of the third daemon process, a new daemon process may be created, so that the number of daemon processes can be ensured to be constant, that is, the following S706 may be continuously performed. Under the condition that it is determined that the third daemon process does not fail according to the identifier of the third daemon process, the electronic device may continue to monitor the daemon processes of the multiple daemon processes except the second daemon process and the third daemon process, that is, the electronic device may continue to execute the foregoing S704.
In some examples, when the third daemon process comprises a plurality of daemon processes, the second daemon process may monitor the plurality of third daemon processes in order of the plurality of third daemon processes in the process list.
For example, continuing with Table 1, after N daemons are determined, a list of N +1 processes and N +1 mutually exclusive locks are generated. Then, the host process may be determined from the N daemon processes, and the identifier of the host process may be mapped to the identifier corresponding to the 0 th list in the process list.
Then, the second daemon process, i.e. each daemon process except the main process, may obtain the identifier corresponding to the 0 th list through the process list, so as to determine whether the main process is invalid or not through the identifier of the main process. After the second daemon monitors the host process through the identifier of the host process, when the second daemon is not the daemon corresponding to the 1 st list in the process list, the second daemon can acquire the identifier of the daemon corresponding to the 1 st list in the process list, so that the daemon corresponding to the 1 st list in the process list can be monitored, that is, whether the daemon corresponding to the 1 st list in the process list is invalid or not is determined. Then, the second daemon process may obtain an identifier of the daemon process corresponding to the 2 nd list of the process list, so that the daemon process corresponding to the 2 nd list of the process list may be monitored, that is, it is determined whether the daemon process corresponding to the 1 st list of the process list is invalid. And then the second daemon process can continuously acquire the identifiers of other daemon processes so as to monitor the other daemon processes until the second daemon process monitors all the daemon processes except the second daemon process and the main process in the process list.
S706, creating a new daemon process, and replacing the identifier of the third daemon process in the process list with the identifier of the new daemon process.
In the event that the third daemon process is determined to be invalid based on the identifier of the third daemon process, a new daemon process may be created. After the new daemon process is created, the identifier of the third daemon process in the process list may be replaced with the identifier of the new daemon process, so that the second daemon process may determine whether the new daemon process exits from running through the identifier of the new daemon process, that is, the new daemon process is monitored through the identifier of the new daemon process.
S707, determining whether the second daemon process completes monitoring the third daemon process.
In a case that it is determined that the second daemon process completes monitoring of the third daemon process, it may be determined that the second daemon process completes single monitoring, that is, the following S708 may be continuously performed. Under the condition that it is determined that the second daemon process does not monitor the third daemon process completely, the second daemon process may continue to acquire the identifiers of the other third daemon processes in the process list, so as to monitor the other third daemon processes, that is, the electronic device may continue to execute the above S704.
And S708, determining that the second daemon process completes single monitoring.
When it is determined that the second daemon process completes monitoring of the third daemon process, it is determined that the second daemon process completes single monitoring, that is, the second daemon process completes one monitoring process for the main process and the third daemon process (i.e., all daemon processes except the second daemon process and the main process).
After the second daemon process completes the single monitoring, the second daemon process may continue to monitor the main process and the third daemon process, that is, the electronic device may continue to perform the above S701-S708. That is, the second daemon process may perform polling monitoring on the corresponding host process and the third daemon process in the process list.
It should be noted that, it may also be determined by the host process that each daemon process, except the host process, in the multiple daemon processes is monitored, that is, whether each daemon process, except the host process, in the multiple daemon processes is failed is determined, and in the case that it is determined that any daemon process, except the host process, in the multiple daemon processes is failed, a new daemon process may be created.
In some examples, the process of the host determining whether each of the plurality of daemons other than the host fails may refer to the process of the second daemon monitoring the third daemon process, i.e., S704-S708 described above.
That is, the process of the host process determining whether each of the plurality of daemons other than the host process fails may include: the host process obtains the identification of each daemon process except the host process in the process list. And the main process determines whether each daemon process except the main process exits the operation or not according to the identification of each daemon process except the main process in the process list. In the case that any daemon process quits running, a new daemon process can be created, and the identifier of the daemon process quitting running in the process list is replaced by the identifier of the newly created daemon process. Thereafter, the host process may continue to monitor other daemons in the process list.
When the host process determines that the daemon process does not quit operation according to the identifier of any daemon process, the host process can continue to acquire identifiers of other daemon processes in the process list, so that whether the other daemon processes quit operation or not is determined, namely, the other daemon processes are monitored.
When the host process completes monitoring of all the daemon processes, the host process may determine that single monitoring is completed, and then the host process may monitor each of the plurality of daemon processes again. That is, the host process may also perform polling monitoring on multiple daemons in the process list.
Corresponding to the method in the foregoing embodiment, an embodiment of the present application further provides a process daemon device. The process daemon device can be applied to electronic equipment and is used for realizing the method in the embodiment. The function of the process daemon device can be realized by hardware, and can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the above-described functions.
For example, fig. 8 shows a schematic structural diagram of a process daemon 800, and as shown in fig. 8, the process daemon 800 may include: an initiation module 801 and a determination module 802, etc.
The starting module 801 may be configured to start a plurality of processes.
The determining module 802 may be configured to determine, among the plurality of started processes, a host process and a plurality of daemon processes, where the host process is used to run the application program, and the daemon processes include the host process.
A determining module 802, further configured to determine, by each daemon process except the main process, whether the main process fails;
the determining module 802 is further configured to determine a first daemon process among the plurality of daemon processes, take the first daemon process as a new main process, and run the application program under the condition that it is determined that the main process is failed.
In a possible implementation manner, the determining module 802 may be further configured to determine, by the second daemon process, whether the third daemon process fails; the second daemon process is each daemon process except the main process in the plurality of daemon processes; the third daemon includes a daemon of the plurality of daemons except the second daemon and the main process.
The process daemon device 800 may further comprise a creating module 803.
A creating module 803, which may be configured to create a new daemon process if it is determined that the third daemon process fails.
In one possible implementation, the determining module 802 may be further configured to determine, by the host process, whether each of the plurality of daemons, other than the host process, is invalid.
The creating module 803 may be further configured to create a new daemon process when it is determined that any daemon process, except the main process, of the plurality of daemon processes fails.
In a possible implementation manner, the creating module 803 may be further configured to determine, based on a plurality of processes, a plurality of daemons; and based on the multiple daemon processes, multiple mutually exclusive locks respectively corresponding to the multiple daemon processes are created.
The determining module 802 may be further configured to determine, according to the plurality of mutexes, a host process and a plurality of daemon processes except the host process in the plurality of processes, where a state of the mutex lock corresponding to the host process is a first state, and a state of the mutex lock corresponding to the daemon processes except the host process is a second state, where the first state is different from the second state.
In a possible implementation manner, the determining module 802 may be further configured to determine, according to the mutex lock corresponding to the multiple daemon processes, a first daemon process in the other daemon processes except the main process among the multiple daemon processes, where a state of the mutex lock corresponding to the first daemon process is a first state, and a state of the mutex lock corresponding to the other daemon processes except the first daemon process and the main process among the multiple daemon processes is a second state.
In a possible implementation manner, the process daemon device 800 may further include an obtaining module 804.
The obtaining module 804 may be configured to obtain resource information of the electronic device.
The determining module 802 may be further configured to determine the number of creatable processes according to the resource information.
The creating module 803 may also be configured to create a plurality of processes according to the number of creatable processes.
It should be understood that the division of units or modules (hereinafter referred to as units) in the above apparatus is only a division of logical functions, and may be wholly or partially integrated into one physical entity or physically separated in actual implementation. And the units in the device can be realized in the form of software called by the processing element; or may be implemented entirely in hardware; part of the units can also be realized in the form of software called by a processing element, and part of the units can be realized in the form of hardware.
For example, each unit may be a processing element separately set up, or may be implemented by being integrated into a chip of the apparatus, or may be stored in a memory in the form of a program, and a function of the unit may be called and executed by a processing element of the apparatus. In addition, all or part of the units can be integrated together or can be independently realized. The processing element described herein, which may also be referred to as a processor, may be an integrated circuit having signal processing capabilities. In implementation, each step of the above method or each unit above may be implemented by an integrated logic circuit of hardware in a processor element or in a form called by software through the processor element.
In one example, the units in the above apparatus may be one or more integrated circuits configured to implement the above method, such as: one or more ASICs, or one or more DSPs, or one or more FPGAs, or a combination of at least two of these integrated circuit forms.
As another example, when a unit in an apparatus may be implemented in the form of a processing element scheduler, the processing element may be a general-purpose processor, such as a CPU or other processor that may invoke a program. As another example, these units may be integrated together, implemented in the form of a system on chip SOC.
In one implementation, the means for implementing the respective corresponding steps of the above method by the above apparatus may be implemented in the form of a processing element scheduler. For example, the apparatus may include a processing element and a memory element, the processing element calling a program stored by the memory element to perform the method described in the above method embodiments. The memory elements may be memory elements on the same chip as the processing elements, i.e. on-chip memory elements.
In another implementation, the program for performing the above method may be in a memory element on a different chip than the processing element, i.e. an off-chip memory element. At this time, the processing element calls or loads a program from the off-chip storage element onto the on-chip storage element to call and execute the method described in the above method embodiment.
For example, the embodiments of the present application may also provide an apparatus, such as: an electronic device may include: a processor, a memory for storing instructions executable by the processor. The processor is configured to execute the above instructions, so that the electronic device implements the process daemon method according to the foregoing embodiment. The memory may be located within the electronic device or external to the electronic device. And the processor includes one or more.
In yet another implementation, the unit of the apparatus for implementing the steps of the method may be configured as one or more processing elements, and these processing elements may be disposed on the electronic device corresponding to the foregoing, where the processing elements may be integrated circuits, for example: one or more ASICs, or one or more DSPs, or one or more FPGAs, or a combination of these types of integrated circuits. These integrated circuits may be integrated together to form a chip.
For example, the embodiment of the present application also provides a chip, and the chip can be applied to the electronic device. The chip includes one or more interface circuits and one or more processors; the interface circuit and the processor are interconnected through a line; the processor receives and executes computer instructions from the memory of the electronic device through the interface circuitry to implement the methods described in the method embodiments above.
Embodiments of the present application also provide a computer-readable storage medium having computer program instructions stored thereon. The computer program instructions, when executed by the electronic device, cause the electronic device to implement a process daemon method as described above.
The embodiment of the present application further provides a computer program product, which includes computer instructions executed by the electronic device as described above, and when the computer instructions are executed in the electronic device, the electronic device is enabled to implement the process daemon method as described above. Through the above description of the embodiments, it is clear to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional modules is merely used as an example, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above described functions.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the above-described device embodiments are merely illustrative, and for example, the division of the modules or units is only one logical functional division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another device, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may be one physical unit or multiple physical units, that is, may be located in one place, or may be distributed in multiple different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application may be embodied in the form of software products, such as: and (5) programming. The software product is stored in a program product, such as a computer readable storage medium, and includes several instructions for causing a device (which may be a single chip, a chip, or the like) or a processor (processor) to perform all or part of the steps of the methods according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.
For example, embodiments of the present application may also provide a computer-readable storage medium having stored thereon computer program instructions. The computer program instructions, when executed by the electronic device, cause the electronic device to implement a process daemon method as described in the preceding method embodiments.
The above description is only an embodiment of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions within the technical scope of the present disclosure should be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A process daemon method applied to an application program of an electronic device is characterized by comprising the following steps:
starting a plurality of processes;
determining a main process and a plurality of daemon processes in the started plurality of processes, wherein the main process is used for running the application program, and the daemon processes comprise the main process;
determining, by each of the daemon processes other than the main process, whether the main process has failed;
and under the condition that the main process is determined to be invalid, determining a first daemon process in the plurality of daemon processes, taking the first daemon process as a new main process, and running the application program.
2. The method of claim 1, further comprising:
determining whether the third daemon process fails or not through the second daemon process; the second daemon process is each daemon process except the main process in the plurality of daemon processes; the third daemon process comprises a daemon process of the plurality of daemon processes except the second daemon process and the main process;
creating a new daemon process if it is determined that the third daemon process fails.
3. The method of claim 1, further comprising:
determining, by the host process, whether each of the plurality of daemons other than the host process is dead;
creating a new daemon process if it is determined that any daemon process of the plurality of daemon processes except the main process fails.
4. The method according to any one of claims 1-3, wherein the determining, among the plurality of processes that are started, a host process and a plurality of daemon processes comprises:
determining the plurality of daemons based on the plurality of processes;
creating a plurality of mutually exclusive locks respectively corresponding to the plurality of daemon processes based on the plurality of daemon processes;
according to the multiple mutual exclusion locks, determining the main process and multiple daemon processes except the main process in the multiple processes, wherein the state of the mutual exclusion lock corresponding to the main process is a first state, the state of the mutual exclusion lock corresponding to the daemon processes except the main process is a second state, and the first state is different from the second state.
5. The method of claim 4, wherein determining the first daemon process from the plurality of daemon processes comprises:
according to the mutual exclusion locks corresponding to the multiple daemon processes, the first daemon process is determined in other daemon processes except the main process in the multiple daemon processes, the state of the mutual exclusion lock corresponding to the first daemon process is the first state, and the state of the mutual exclusion lock corresponding to other daemon processes except the first daemon process and the main process in the multiple daemon processes is the second state.
6. The method of any of claims 1-3, wherein prior to the initiating the plurality of processes, the method further comprises:
acquiring resource information of the electronic equipment;
determining the number of creatable processes according to the resource information;
and creating the plurality of processes according to the number of the creatable processes.
7. An apparatus for process daemon, the apparatus comprising:
the starting module is used for starting a plurality of processes;
the determining module is used for determining a main process and a plurality of daemon processes in the started processes, wherein the main process is used for running an application program, and the daemon processes comprise the main process;
the determining module is further configured to determine whether the main process fails through each daemon process except the main process;
the determining module is further configured to determine a first daemon process among the plurality of daemon processes under the condition that it is determined that the main process is invalid, take the first daemon process as a new main process, and run the application program.
8. The process daemon device of claim 7,
the determining module is further used for determining whether the third daemon process fails through the second daemon process; the second daemon process is each daemon process except the main process in the plurality of daemon processes; the third daemon process comprises a daemon process of the plurality of daemon processes except the second daemon process and the main process;
the process daemon device also comprises a creation module;
the creating module is used for creating a new daemon process under the condition that the third daemon process is determined to be invalid.
9. An electronic device, comprising: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is configured to store at least one executable instruction that causes the processor to perform the operations of the process daemon according to any one of claims 1 to 6.
10. A computer-readable storage medium having stored therein at least one executable instruction, which when executed on an electronic device, causes the electronic device to perform the operations of the process daemon method of any one of claims 1 to 6.
CN202211374533.7A 2022-10-31 2022-10-31 Process daemon method and electronic equipment Pending CN115599610A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211374533.7A CN115599610A (en) 2022-10-31 2022-10-31 Process daemon method and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211374533.7A CN115599610A (en) 2022-10-31 2022-10-31 Process daemon method and electronic equipment

Publications (1)

Publication Number Publication Date
CN115599610A true CN115599610A (en) 2023-01-13

Family

ID=84852078

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211374533.7A Pending CN115599610A (en) 2022-10-31 2022-10-31 Process daemon method and electronic equipment

Country Status (1)

Country Link
CN (1) CN115599610A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116150771A (en) * 2023-04-19 2023-05-23 北京集度科技有限公司 Redundancy processing device, redundancy processing method, redundancy processing system and intelligent vehicle

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116150771A (en) * 2023-04-19 2023-05-23 北京集度科技有限公司 Redundancy processing device, redundancy processing method, redundancy processing system and intelligent vehicle

Similar Documents

Publication Publication Date Title
CN109241745B (en) Trusted starting method and device of computing platform
CN112015599B (en) Method and apparatus for error recovery
CN114676424B (en) Container escape detection and blocking method, device, equipment and storage medium
CN113407383B (en) Main and standby system switching method and device, server and main and standby system
CN110162344B (en) Isolation current limiting method and device, computer equipment and readable storage medium
CN115599610A (en) Process daemon method and electronic equipment
CN111177703B (en) Method and device for determining data integrity of operating system
CN111538585A (en) Js-based server process scheduling method, system and device
CN114398631A (en) Business processing method and device, electronic equipment and storage medium
CN111125721A (en) Control method for process starting, computer equipment and readable storage medium
CN114327673B (en) Task starting method and device, electronic equipment and storage medium
CN114691241B (en) Task execution method, device, electronic equipment and storage medium
CN111783090A (en) Information processing method and device, equipment and storage medium
CN108959915B (en) Rootkit detection method, rootkit detection device and server
CN107179911B (en) Method and equipment for restarting management engine
CN116339908A (en) Virtual machine starting method, device, computer equipment and storage medium
CN111177726B (en) System vulnerability detection method, device, equipment and medium
CN111858075A (en) Deadlock detection method, system, equipment and readable storage medium
CN113467901A (en) Task scheduling method and related equipment
CN115396280B (en) Alarm data processing method, device, equipment and storage medium
CN112395149B (en) Script behavior identification method and device, storage medium and computer equipment
CN112906000B (en) Program access method, device, equipment and readable storage medium
CN117851988A (en) Application security reinforcement method, device, equipment and medium
JP7327057B2 (en) CONTAINER CONTROL DEVICE, CONTAINER CONTROL METHOD, AND CONTAINER CONTROL PROGRAM
JP2008077388A (en) Multiprocessor control system, method and program

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