Process management method and device and electronic equipment
1. A process management method, comprising:
when the processes are switched, at least two processes needing to store the field information are determined from the sleep processes; the sleep process is a process which is about to enter a sleep state when the process is switched;
saving the determined field information of the at least two processes;
when an abnormal process which is abnormal exists in the at least two processes, acquiring the stored field information of the at least two processes;
and determining the reason of the abnormal process according to the field information of the at least two processes.
2. The method of claim 1, wherein before determining at least two processes needing to save the presence information from the sleep process during the process switching, further comprising:
at least two processes are set that require saving field information.
3. The method of claim 2, wherein the setting requires at least two processes that save field information, including:
after the operating system is started, determining at least two processes needing to save the field information through a configuration command;
wherein the configuration command comprises: configuring a save subcommand, checking a current configuration subcommand and clearing the current configuration subcommand;
the configuration saving sub-command is used for saving the pre-configured identifiers of the at least two processes;
the view current configuration subcommand is used for viewing the at least two saved processes;
the clear current configuration sub-command is used to clear the configuration command;
the determining at least two processes needing to store the field information from the sleep process comprises:
and determining all processes indicated by the identifiers of the at least two pre-configured processes from the sleep processes.
4. The method of claim 2 or 3, wherein said saving the determined presence information of the at least two processes comprises:
calling an execution function and traversing a process memory area; the execution function is used for saving the field information of the at least two processes;
extracting the field information of the at least two processes from the process memory area;
saving the field information of the at least two processes as a file which can be debugged by a GNU project debugger GDB;
the acquiring the stored field information of the at least two processes includes:
acquiring the file which is saved as a GDB and can be debugged;
the determining the reason for the abnormal process to be abnormal according to the field information of the at least two processes includes:
analyzing the file which is saved as the GDB and can be debugged, and acquiring the field information of the at least two processes;
and analyzing the field information of the at least two processes, and determining the reason of the abnormal process.
5. The method according to any one of claims 2 to 4, wherein the at least two processes requiring saving of field information are determined according to tasks performed by the processes.
6. A process management apparatus, comprising:
the determining module is used for determining at least two processes needing to store the field information from the sleep processes when the processes are switched; the sleep process is a process which is about to enter a sleep state when the process is switched;
the storage module is used for storing the determined field information of the at least two processes;
the acquiring module is used for acquiring the stored field information of the at least two processes when an abnormal process which is abnormal exists in the at least two processes;
and the processing module is used for determining the reason of the abnormal process according to the field information of the at least two processes.
7. The apparatus of claim 6, wherein the process management apparatus further comprises:
setting a module: at least two processes for setting up the need to save the field information.
8. The apparatus according to claim 7, wherein the setting module is specifically configured to:
after the operating system is started, determining at least two processes needing to save the field information through a configuration command;
wherein the configuration command comprises: configuring a save subcommand, checking a current configuration subcommand and clearing the current configuration subcommand;
the configuration saving sub-command is used for saving the pre-configured identifiers of the at least two processes;
the view current configuration subcommand is used for viewing the at least two saved processes;
the clear current configuration sub-command is used to clear the configuration command;
the determining module is specifically configured to:
and determining all processes indicated by the identifiers of the at least two pre-configured processes from the sleep processes.
9. The apparatus according to claim 7 or 8, wherein the saving module is specifically configured to:
calling an execution function and traversing a process memory area; the execution function is used for saving the field information of the at least two processes;
extracting the field information of the at least two processes from the process memory area;
saving the field information of the at least two processes as a GDB debuggable file;
the acquisition module is specifically configured to:
acquiring the file which is saved as a GDB and can be debugged;
the processing module is specifically configured to:
analyzing the file which is saved as the GDB and can be debugged, and acquiring the field information of the at least two processes;
and analyzing the field information of the at least two processes, and determining the reason of the abnormal process.
10. The apparatus according to any one of claims 7 to 9, wherein the at least two processes requiring saving of the field information are determined according to tasks performed by the processes.
11. An electronic device, comprising: a memory and a processor, the memory coupled with the processor;
the memory is to store program instructions;
the processor is configured to call program instructions in the memory to perform the method of any one of claims 1-5.
12. A computer-readable storage medium, characterized in that the readable storage medium has stored thereon a computer program which, when executed, implements the method of any one of claims 1-5.
Background
A process is a running activity of a program with some independent functionality with respect to a certain data set. It is the basic unit that the operating system executes dynamically, and in the traditional operating system, the process is the basic allocation unit and the basic execution unit. In the prior art, when a process is abnormal, problems existing in a system are positioned through field information of the abnormal process.
However, with the prior art methods, the positioning problem is not efficient.
Disclosure of Invention
The embodiment of the application provides a process management method and device and electronic equipment, and is used for solving the problem of low positioning efficiency.
In a first aspect, an embodiment of the present application provides a process management method, including:
when the processes are switched, at least two processes needing to store the field information are determined from the sleep processes; the sleep process is a process which is about to enter a sleep state when the process is switched;
saving the determined field information of the at least two processes;
when an abnormal process which is abnormal exists in the at least two processes, acquiring the stored field information of the at least two processes;
and determining the reason of the abnormal process according to the field information of the at least two processes. Optionally, before determining at least two processes needing to store the field information from the sleep process during the process switching, the method further includes:
at least two processes are set that require saving field information.
Optionally, the setting at least two processes that need to store the field information includes:
after the operating system is started, determining at least two processes needing to save the field information through a configuration command;
wherein the configuration command comprises: configuring a save subcommand, checking a current configuration subcommand and clearing the current configuration subcommand;
the configuration saving sub-command is used for saving the pre-configured identifiers of the at least two processes;
the view current configuration subcommand is used for viewing the at least two saved processes;
the clear current configuration sub-command is used to clear the configuration command;
the determining at least two processes needing to store the field information from the sleep process comprises:
and determining all processes indicated by the identifiers of the at least two pre-configured processes from the sleep processes.
Optionally, the saving the determined field information of the at least two processes includes:
calling an execution function and traversing a process memory area; the execution function is used for saving the field information of the at least two processes;
extracting the field information of the at least two processes from the process memory area;
saving the field information of the at least two processes as a GNU Project Debugger (GDB) debuggable file;
the acquiring the stored field information of the at least two processes includes:
acquiring the file which is saved as a GDB and can be debugged;
the determining the reason for the abnormal process to be abnormal according to the field information of the at least two processes includes:
analyzing the file which is saved as the GDB and can be debugged, and acquiring the field information of the at least two processes;
and analyzing the field information of the at least two processes, and determining the reason of the abnormal process.
Optionally, the at least two processes that need to store the field information are determined according to tasks executed by the processes.
In a second aspect, an embodiment of the present application provides a process management apparatus, including:
the determining module is used for determining at least two processes needing to store the field information from the sleep processes when the processes are switched; the sleep process is a process which is about to enter a sleep state when the process is switched;
the storage module is used for storing the determined field information of the at least two processes;
the acquiring module is used for acquiring the stored field information of the at least two processes when an abnormal process which is abnormal exists in the at least two processes;
and the processing module is used for determining the reason of the abnormal process according to the field information of the at least two processes.
Optionally, the process management apparatus further includes:
setting a module: at least two processes for setting up the need to save the field information.
Optionally, the setting module is specifically configured to:
after the operating system is started, determining at least two processes needing to save the field information through a configuration command;
wherein the configuration command comprises: configuring a save subcommand, checking a current configuration subcommand and clearing the current configuration subcommand;
the configuration saving sub-command is used for saving the pre-configured identifiers of the at least two processes;
the view current configuration subcommand is used for viewing the at least two saved processes;
the clear current configuration sub-command is used to clear the configuration command;
the determining module is specifically configured to:
and determining all processes indicated by the identifiers of the at least two pre-configured processes from the sleep processes.
Optionally, the saving module is specifically configured to:
calling an execution function and traversing a process memory area; the execution function is used for saving the field information of the at least two processes;
extracting the field information of the at least two processes from the process memory area;
saving the field information of the at least two processes as a GDB debuggable file;
the acquisition module is specifically configured to:
acquiring the file which is saved as a GDB and can be debugged;
the processing module is specifically configured to:
analyzing the file which is saved as the GDB and can be debugged, and acquiring the field information of the at least two processes;
and analyzing the field information of the at least two processes, and determining the reason of the abnormal process.
Optionally, the at least two processes that need to store the field information are determined according to tasks executed by the processes.
In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor; the memory is coupled with the processor; the memory is to store program instructions; the processor is configured to invoke program instructions in the memory to perform the method of any of the first aspects.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium having stored thereon a computer program, which when executed, implements the method according to any one of the first aspect.
The embodiment of the application provides a process management method, a process management device and electronic equipment, wherein at least two processes needing to store field information are determined from sleep processes when the processes are switched, and the determined at least two processes are stored; the method comprises the steps of obtaining field information of at least two processes, and locating the reason of the abnormal process according to the field information of the at least two processes when the abnormal process exists in the at least two processes. On one hand, the field information of the abnormal process and the field information of other processes except the abnormal process are obtained, and the problem of the abnormal process is positioned by combining the field information of the other processes; on the other hand, compared with the problem that the process management mechanism in the prior art cannot simultaneously acquire the field information of the multiple processes, by adopting the technical scheme, the field information of the multiple processes is simultaneously acquired by modifying the process management mechanism, so that the function of positioning the abnormal process problem through the field information of the multiple processes is ensured.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic diagram of an electronic device according to an embodiment of the present application;
fig. 2 is a flowchart of a process management method according to an embodiment of the present application;
FIG. 3 is a flowchart of a process management method according to another embodiment of the present application;
FIG. 4 is a block diagram of a process management method according to an embodiment of the present application;
FIG. 5 is a flowchart illustrating a process for saving field information of at least two processes determined according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of a process management device according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
fig. 8 is a block diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Software systems are typically comprised of an operating system and application software; at present, a lot of application software is run by a part of electronic products by taking Linux or vxworks as an operating system, and the operating system realizes various functions by taking a process as a unit. The process is a program that can be executed concurrently, is a basic unit for resource allocation and scheduling by an operating system, and is the basis of an operating system structure.
The running process in the operating system may be terminated due to an internal error, a fault, or an external intervention exception, and in order to ensure that the process can run normally, the problem of the abnormal process needs to be located, that is, the reason why the process is abnormal is obtained.
In systems such as Linux system or vxworks, the process management mechanism is usually: in the operating process of the operating system, the field information of the running process is not saved, and only when the running process is abnormal, the field information of the abnormal process is saved; the kernel only stores the field information of the abnormal process, so that the system only stores the field information of the abnormal process. For example: if A, B, C processes are sequentially run in the operating system, the system only stores the field information of the process A after the process A is abnormal, and does not store the field information of the process B or the field information of the process C; however, the cause of the process A exception may be related to process B or process C. When the process a is abnormal, the reason for the abnormality of the process a can only be determined through the field information of the process a itself, and because the field information of the process a is not rich and comprehensive enough, it is necessary to combine the field information of other processes other than the process a, for example, it is inferred through other methods that the abnormality of the process a may be related to the process B or the process C, and the field information of the process B and the field information of the process C are not stored and need to be acquired through other methods, so that the efficiency and accuracy of the positioning problem are low.
The embodiment of the application provides a process management method, a process management device and electronic equipment, which can store field information of at least two processes in advance, and when an abnormal process which is abnormal exists in the at least two processes, the reason for the abnormal process to be abnormal can be determined through the field information of the at least two processes, so that the field information of the process which is used for problem location is more comprehensive, and field information of other processes which are possibly related to the abnormal process does not need to be inferred through other modes, and therefore, the efficiency and the accuracy of location problems can be improved.
Fig. 1 is a schematic view of an electronic device according to an embodiment of the present application, and as shown in fig. 1, a process management method, an apparatus, and an electronic device according to this embodiment may be applied to an electronic device capable of running a process, and include: mobile terminal devices and computer devices, such as mobile phones, tablet computers, home computers, etc. The process management method, the device and the electronic equipment provided by the embodiment can be applied to a Linux operating system and can also support operating systems such as vxworks.
Fig. 2 is a flowchart of a process management method according to an embodiment of the present application, and as shown in fig. 2, the method according to the embodiment includes:
s201, when the processes are switched, at least two processes needing to store the field information are determined from the sleep processes.
The sleep process is a process which is about to enter a sleep state when the process is switched. In the process of process running in an operating system or application software, when process switching occurs, a currently running process enters a sleep state from a running state; generally, any process can enter a sleep state in two ways, namely, an active way to enter the sleep state and a passive way to enter the sleep state, where the active way includes that the process ends running to enter the sleep state or that the process enters the sleep state by waiting for the system to allocate resources, and the passive way includes that the operating system controls the process to enter the sleep state for some specific reason. Optionally, when the process is switched, the process to be in the sleep state is referred to as a sleep process.
In this embodiment, a plurality of processes may be simultaneously run in the operating system, and the processes may be functionally dependent on each other or may be independent of each other.
Optionally, the field information of the process mainly includes a context of the process, the context of the process is a static description of a whole process of the process execution activity, and the context of the process includes an upper context, a text context, and a lower context. For any process, the above refers to the content of the executed process instructions and data in the relevant registers and stack in the process; the text refers to the content of the process instructions and data in registers and stacks being executed in any process; the following refers to the contents of process instructions and data in registers and stacks to be executed in any of the processes. In particular, a process context includes the values of various registers (e.g., general purpose registers, program counters, etc.) in the computer system that are relevant to executing the process. When the process is abnormal in the running process, the reason of the process abnormality can be determined by looking up the field information of the process.
Wherein, one possible implementation manner of S201 is:
and determining all processes indicated by the identifications of at least two pre-configured processes from the sleep processes. Namely, the process needing to store the field information can be determined in a mode of presetting a process identifier; for example, when the application software runs, the application software includes a plurality of processes, the process identifiers are respectively process a, process B and process C, and process a and process B are preset as processes requiring field information storage. The process needing to store the field information can be preset in a mode of application software identification of the process; for example, the electronic device includes a plurality of application software, the application software identifiers are application software a, application software B, and application software C, each application software includes a plurality of processes when running, and all the processes running when running the application software a are preset as processes requiring field information storage. The specific manner by which at least two processes requiring to store the field information are preset may be determined according to a specific application scenario, and details are not described here.
Optionally, the field information of the at least two processes to be stored may be field information of a part of processes in all processes running in a certain specified time period, or may be field information of all processes in the certain specified time period. For example: the operating system runs 10 processes in a specified time period T, which are process 1, process 2, and process … …, respectively, and the partial process refers to more than or equal to 1 and less than 10 processes among the 10 processes, and may be process 1, process 2, and process 5, for example.
S202, saving the determined field information of the at least two processes.
In this embodiment, when determining a process that needs to store field information by presetting a process identifier, optionally, the application software includes multiple processes during running, where the process identifiers are process a, process B, and process C, and process a and process B are preset as processes that need to store field information; when the application software is operated, once the process a needs to be switched, that is, the process a needs to enter the sleep state, the field information of the process a is stored, and similarly, once the process B needs to be switched, that is, the process B needs to enter the sleep state, the field information of the process B is stored, and when the process C needs to be switched, the preset process identifier does not include the process C, so that the field information of the process C does not need to be stored.
When the process needing to store the field information is preset in a mode of the application software identifier to which the process belongs, optionally, the electronic device comprises a plurality of application software, and all processes running when the application software A is running are preset as the processes needing to store the field information; once the application software a is run, all running processes of the application software a need to store corresponding field information when each process is switched.
S203, when an abnormal process which is abnormal exists in the at least two processes, the stored field information of the at least two processes is obtained.
In this embodiment, at least two processes that need to store the field information may be processes having correlation; at least two processes needing to store the field information can be appointed other types of processes; the above-described dependencies do not necessarily exist between each two of the other types of processes.
Optionally, the at least two processes that need to store the field information are determined according to tasks executed by the processes. Wherein, the task executed according to the process determines which processes have correlation, and the functions are mutually supported. After the processes are abnormal, acquiring the field information of the processes which are related to the abnormal processes according to the correlation among the processes; the correlation among the processes can be determined according to the executed tasks, namely, a plurality of processes executing the same task are determined as processes with correlation; dependencies between processes may also be determined by executing the associated plurality of tasks, i.e., determining all processes running in the associated plurality of tasks to be executing as processes having dependencies. For example: the process 1, the process 2 and the process 3 are used for executing the same task, and it can be determined that the process 1, the process 2 and the process 3 are related processes, and if any one of the process 1, the process 2 and the process 3 is abnormal, the operating system stores the field information of the three processes in advance, so that the field information of the process 1, the process 2 and the process 3 can be directly acquired at this time. The correlation between the processes may also be determined according to other manners, and the present application is not limited thereto.
Optionally, after the process is abnormal, no matter which process is abnormal, the preset field information of all the processes is obtained. The all processes may refer to all processes that have saved the field information before the process is abnormal. That is, if all the processes are configured in advance and the field information needs to be stored, the acquired field information is the field information of all the processes; if the field information is pre-configured to only store the field information for a part of the processes, the correlation may not exist between all the part of the processes, but the field information for storing the part of the processes is pre-configured, when an abnormal process exists in the part of the processes, the acquired field information is the already stored field information for the part of the processes, and the field information for the part of the processes includes the field information for the abnormal process.
And S204, determining the reason for the abnormal process to be abnormal according to the field information of the at least two processes.
In the embodiment, in the process of process operation, when a process abnormality occurs, the field information of the at least two processes is acquired, and the judgment can be directly performed based on the field information of the abnormal process and the field information of other processes without inferring the conditions of other processes in other manners, so that the cause of the process abnormality can be accurately and efficiently determined.
In connection with the previous examples, for example: the process 1, the process 2 and the process 3 are used for executing the same task, so that any one of the process 1, the process 2 and the process 3 is likely to be related to two other processes due to abnormality, the field information of the process 1, the process 2 and the process 3 can be obtained according to the S203 for carrying out abnormality positioning analysis, and the field information of the other two related processes can be directly known and judged based on the known field information without deducing the conditions of the process 2 and the process 3 in other modes, so that the efficiency and the accuracy of positioning problems can be improved.
For another example: if all the processes are configured in advance in the operating system and the field information is stored, the field information of all the processes is acquired. If any one of the processes 1 to 10 is abnormal, performing process abnormal positioning analysis based on the field information of the processes 1 to 10 acquired in the step S203; because the processes which are related to the abnormal process exist in all the processes, the field information of the processes which are related to the abnormal process is directly extracted from the field information of all the processes to assist in analyzing the reason of the abnormal process, and the efficiency and the accuracy of positioning problems can be improved.
For another example: if the operating system is pre-configured with partial process to store the field information, the field information of the partial process is acquired. If any process in the partial processes is abnormal, acquiring the preset field information of all the processes in the partial processes based on S203, and performing abnormal positioning analysis; the stored partial processes may only have the correlation between the partial processes and the abnormal processes, but the stored field information is richer and more comprehensive, and the reason of the process abnormality is directly analyzed in an auxiliary manner through the stored field information, so that the efficiency of positioning problems can be improved.
In this embodiment, when an abnormal process which is abnormal exists in at least two processes configured in advance, the field information of the at least two processes is acquired; and positioning the abnormal problem of the process according to the field information of the at least two processes. Because the field information of the at least two processes is richer and more comprehensive, the problem of process abnormity can be directly positioned through the field information of the at least two processes, and the conditions of other processes do not need to be inferred through other modes, so that the efficiency of positioning the problem can be improved. And whether the process abnormity is related to other processes can be verified through the acquired field information of at least two processes, so that the accuracy of the positioning problem can be improved.
Fig. 3 is a flowchart of a process management method according to another embodiment of the present application, and as shown in fig. 3, the method according to this embodiment includes:
s301, setting at least two processes needing to store the field information.
In this embodiment, when a process is switched, before determining at least two processes needing to store field information from sleep processes, the field information of which processes need to be stored needs to be set first after an operating system is started.
Optionally, after the operating system is started, at least two processes needing to save the field information may be determined by the configuration command. The processes can be distinguished by process identifiers, for example, a process number can be used as a unique identifier of a process, and a process to be saved is set based on the process identifier.
Wherein the configuration command comprises: configure save subcommands, view current configuration subcommands, and clear current configuration subcommands.
Specifically, the configuration saving subcommand in the configuration command is used to save the identifiers of the at least two processes configured in advance; for example: when the field information of the process 1 and the process 2 needs to be saved, pid1 and pid2 are set as the identifiers of the process 1 and the process 2, and one possible implementation manner of the configuration saving sub-command is as follows:
in the process running process, a user can check the configuration command, and the system can determine which process field information is actively stored when the process is abnormal through checking the configuration command. When the process is abnormal, the user can locate the reason of the process abnormality through the stored field information of the process. The view current configuration sub-command in the configuration commands is used for viewing the at least two saved processes; one possible implementation manner of viewing the current configuration subcommand is as follows:
and when the field information of the process is not required to be saved, clearing the configuration command and restoring the default configuration. The emptying current configuration sub-command in the configuration commands is used for emptying the configuration commands; one possible implementation manner of clearing the current configuration subcommand is as follows:
whether the process is abnormal or not, the field information of the process can be configured and saved.
If the field information of partial processes is determined to be saved according to the task started each time, a command needs to be configured after each task is started, and the field information of the processes needs to be saved is determined according to the started tasks.
If the field information of all the processes needs to be stored, the processes do not need to be reconfigured after each task is started, the field information of the processes does not need to be determined and stored according to the started tasks, the processes only need to be configured once after the operating system is started, and the current configuration is not cleared.
Fig. 4 is a block diagram of a process management method according to an embodiment of the present application, as shown in fig. 4.
The steps in the above embodiments may be performed by the configuration management module in the save field module shown in fig. 4.
The configuration management module mainly comprises a command line module, a command analysis module and kernel mode configuration data. The configuration management module mainly realizes that: command line, command parsing function.
The command line module executes the configuration save subcommand, view current configuration command subcommand and clear current configuration command subcommand contained in the configuration command.
And the command analysis module executes the field information of which processes need to be stored according to the configuration command analysis obtained by the operating system.
The kernel-mode configuration data performs the configuration of the storage system after being updated according to the configuration command.
S302, when the processes are switched, at least two processes needing to store the field information are determined from the sleep processes, and the determined field information of the at least two processes is stored.
In an operating system, a plurality of processes are simultaneously operated, switching occurs between the processes, and a processor is always occupied by the process which is being operated. Therefore, the process site information needs to be saved, that is, the process site information of any process (e.g., process a) needs to be saved at the time when the process is going to enter the sleep state, so that the complete process site information of the process a is obtained. The complete field information of the process A can be acquired only after the complete field information of the process to be sleeped is stored so as to realize the positioning of the process abnormity problem.
After the operating system is started, the identification of the process needing to store the field information is determined by looking up the configuration command, and the identification of the process can be the identification of a part of processes or the identification of all the processes.
When the identification of the process is the identification of a part of processes, the process needing to store the field information updates the configuration of the operating system according to the configuration command. Specifically, in the process of running the process a, when the process a is to be switched to the next process, that is, when the process a is to enter a sleep state from a running state, it is determined whether the process a needs to store the field information by checking the configuration of the operating system, if so, the field information of the process a is stored, and if not, the process a enters the sleep state and is switched to the next process.
When the process identification is the identification of all the processes, the field information of all the processes is determined to be required to be stored by checking the configuration command, and when the processes are switched, the field information of the processes is directly stored when the processes are going to sleep, and whether the processes are the target processes or not is not required to be judged.
Optionally, the saving the determined field information of the at least two processes includes: calling an execution function and traversing a process memory area; the execution function is used for saving the field information of the at least two processes; extracting the field information of the at least two processes from the process memory area; and saving the field information of the at least two processes as a GDB debuggable file. Wherein the execution function may be implemented by a do _ coredump function.
The process memory area refers to a memory space occupied by the process during operation, traverses the process memory area, collects process memory information, and acquires field information of the at least two processes from the process memory information, wherein the process memory information includes the field information of the processes.
Fig. 5 is a schematic flowchart of saving the determined field information of at least two processes according to an embodiment of the present application, as shown in fig. 5.
And traversing the process memory area when the process needs to be switched, checking whether the process needs to store the field information of the process according to the configuration command, calling an execution function to store the field information of the process if the process needs to be stored, and switching to the next process to judge again if the process does not need to be stored. The memory information of the process comprises the field information of the process.
The operation flow of the execution function is as follows: and analyzing the process memory information to acquire the field information of the processes, and storing the field information of the at least two processes as a GDB debuggable file, so that the problem of the abnormal process can be positioned by using a GDB program debugging tool when the process is abnormal, and the problem positioning efficiency is improved.
The steps in the above embodiments may be performed by the process field analysis storage module in the save field module shown in fig. 4.
The process field analysis module is mainly realized as follows: analyzing the field information of the process, and saving the field information of the process as a file which can be debugged by the GDB.
When the process is abnormal, the process field analysis storage module analyzes the field information of the process, determines which processes need to be stored according to the kernel mode configuration data, and stores the field information of the process as a GDB (graphics device library) debuggable file.
S303, when an abnormal process which is abnormal exists in the at least two processes, the stored field information of the at least two processes is obtained.
Wherein, one possible implementation manner for obtaining the stored field information of the at least two processes is as follows:
and acquiring the file saved as a GDB debuggable file. When an abnormal process which is abnormal exists in the at least two processes, traversing a process memory area, calling an execution function to extract field information of the at least two processes, saving the field information of the at least two processes as a GDB debuggable file, before positioning the problem of the abnormal process, acquiring the GDB debuggable file, and positioning the problem of the abnormal process according to the acquired GDB debuggable file.
S304, determining the reason of the abnormal process according to the field information of the at least two processes.
One possible implementation manner of S304 is:
analyzing the file which is saved as the GDB and can be debugged, and acquiring the field information of the at least two processes; and analyzing the field information of the at least two processes, and determining the reason of the abnormal process.
In this embodiment, at least two processes that need to store the field information are set; when the processes are switched, at least two processes needing to store the field information are determined from the sleep processes; saving the determined field information of the at least two processes; when an abnormal process which is abnormal exists in the at least two processes, acquiring the stored field information of the at least two processes; and determining the reason of the abnormal process according to the field information of the at least two processes. At least two processes needing to store the field information can be set through the configuration command, and the execution function is called to store the field information of the at least two processes when the processes are going to sleep, so that the field information of the complete processes can be stored, the problem of process abnormity is positioned through the complete field information of the at least two processes, and the efficiency and the accuracy of positioning the problem can be improved.
Fig. 6 is a schematic structural diagram of a process management device according to an embodiment of the present application, and as shown in fig. 6, the process management device according to the embodiment includes: a determination module 601, a saving module 602, an acquisition module 603 and a processing module 604.
The determining module 601 is configured to determine at least two processes in which field information needs to be stored from sleep processes when the processes are switched; the sleep process is a process which is about to enter a sleep state when the process is switched;
a saving module 602, configured to save the determined field information of the at least two processes;
an obtaining module 603, configured to obtain, when an abnormal process that occurs an abnormality exists in the at least two processes, stored field information of the at least two processes;
the processing module 604 is configured to determine a reason for the abnormal process occurring an abnormality according to the field information of the at least two processes.
Optionally, the apparatus further includes:
the setting module 605: at least two processes for setting up the need to save the field information.
Optionally, the setting module 605 is specifically configured to:
after the operating system is started, determining at least two processes needing to save the field information through a configuration command;
wherein the configuration command comprises: configuring a save subcommand, checking a current configuration subcommand and clearing the current configuration subcommand;
the configuration saving sub-command is used for saving the pre-configured identifiers of the at least two processes;
the view current configuration subcommand is used for viewing the at least two saved processes;
the clear current configuration sub-command is used to clear the configuration command;
the determining module 601 is specifically configured to:
and determining all processes indicated by the identifiers of the at least two pre-configured processes from the sleep processes.
Optionally, the saving module 602 is specifically configured to:
calling an execution function and traversing a process memory area; the execution function is used for saving the field information of the at least two processes;
extracting the field information of the at least two processes from the process memory area;
saving the field information of the at least two processes as a GDB debuggable file;
the obtaining module 603 is specifically configured to:
acquiring the file which is saved as a GDB and can be debugged;
the processing module 604 is specifically configured to:
analyzing the file which is saved as the GDB and can be debugged, and acquiring the field information of the at least two processes;
and analyzing the field information of the at least two processes, and determining the reason of the abnormal process.
Optionally, the at least two processes that need to store the field information are determined according to tasks executed by the processes.
The process management apparatus provided in this embodiment may be used to execute the technical solution of the method embodiment shown in fig. 2 or fig. 3, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 7 is a schematic view of an electronic device according to an embodiment of the present application, and as shown in fig. 7, the electronic device according to the embodiment includes: a memory 701 and a processor 702, the memory 701 being coupled to the processor 702.
The memory 701 is used to store program instructions.
The processor 702 is configured to invoke the program instructions in the memory to perform:
when the processes are switched, at least two processes needing to store the field information are determined from the sleep processes; the sleep process is a process which is about to enter a sleep state when the process is switched;
saving the determined field information of the at least two processes;
when an abnormal process which is abnormal exists in the at least two processes, acquiring the stored field information of the at least two processes;
and determining the reason of the abnormal process according to the field information of the at least two processes.
Optionally, the processor 702 is further configured to:
at least two processes are set that require saving field information.
Optionally, the processor 702 is specifically configured to:
after the operating system is started, determining at least two processes needing to save the field information through a configuration command;
wherein the configuration command comprises: configuring a save subcommand, checking a current configuration subcommand and clearing the current configuration subcommand;
the configuration saving sub-command is used for saving the pre-configured identifiers of the at least two processes;
the view current configuration subcommand is used for viewing the at least two saved processes;
the clear current configuration sub-command is used to clear the configuration command;
the processor 702 is specifically configured to:
and determining all processes indicated by the identifiers of the at least two pre-configured processes from the sleep processes.
Optionally, the processor 702 is specifically configured to:
calling an execution function and traversing a process memory area; the execution function is used for saving the field information of the at least two processes;
extracting the field information of the at least two processes from the process memory area;
saving the field information of the at least two processes as a GDB debuggable file;
the processor 702 is specifically configured to:
acquiring the file which is saved as a GDB and can be debugged;
determining the reason for the abnormal process to be abnormal according to the field information of the at least two processes, wherein the method comprises the following steps:
analyzing the file which is saved as the GDB and can be debugged, and acquiring the field information of the at least two processes;
and analyzing the field information of the at least two processes, and determining the reason of the abnormal process.
Optionally, the at least two processes that need to store the field information are determined according to tasks executed by the processes.
The electronic device provided in this embodiment may be used to execute the technical solutions of the method embodiments shown in fig. 2 or fig. 3, and the implementation principles and technical effects are similar, which are not described herein again.
Fig. 8 is a block diagram of an electronic device 800 provided by an embodiment of the present application. For example, the process management electronic device 800 may be a mobile phone, a computer, or a tablet computer.
As shown in fig. 8, electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input/output (I/O) interface 812, a sensor component 814, and a communication component 816.
The processing component 802 generally controls overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power components 806 provide power to the various components of the electronic device 800. Power components 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for electronic device 800.
The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the electronic device 800 is in an operation mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the electronic device 800. For example, the sensor assembly 814 may detect an open/closed state of the electronic device 800, the relative positioning of components, such as a display and keypad of the electronic device 800, the sensor assembly 814 may also detect a change in the position of the electronic device 800 or a component of the electronic device 800, the presence or absence of user contact with the electronic device 800, orientation or acceleration/deceleration of the electronic device 800, and a change in the temperature of the electronic device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In some embodiments, the electronic device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In some embodiments, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the electronic device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.