[go: up one dir, main page]

CN108121594B - Process management method and device - Google Patents

Process management method and device Download PDF

Info

Publication number
CN108121594B
CN108121594B CN201611078446.1A CN201611078446A CN108121594B CN 108121594 B CN108121594 B CN 108121594B CN 201611078446 A CN201611078446 A CN 201611078446A CN 108121594 B CN108121594 B CN 108121594B
Authority
CN
China
Prior art keywords
program
sub
dynamic link
link library
function
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.)
Active
Application number
CN201611078446.1A
Other languages
Chinese (zh)
Other versions
CN108121594A (en
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.)
Youku Culture Technology Beijing Co ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201611078446.1A priority Critical patent/CN108121594B/en
Priority to TW106126766A priority patent/TW201820131A/en
Priority to PCT/CN2017/111997 priority patent/WO2018099292A1/en
Publication of CN108121594A publication Critical patent/CN108121594A/en
Application granted granted Critical
Publication of CN108121594B publication Critical patent/CN108121594B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application discloses a process management method and device. Starting an agent process, wherein the agent process loads a dynamic link library linked by the agent process to a memory; the agent process creates a first sub-process, and the first sub-process loads the first program by calling an entry function of the program; the agent process creates a second sub-process, and the second sub-process loads the second program by calling an entry function of the second program; and the first program and the second program share the memory occupied by the dynamic link library.

Description

Process management method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a process management method and apparatus.
Background
A Process (Process) is a running activity of a program in a computer on a data set, is a basic unit of resource allocation and scheduling of a system, and is the basis of an operating system structure. A program is a description of instructions, data, and their organization, and a process is an entity of a program.
In the Linux system, the init process is a parent process of all processes in the Linux system. The init process is guided by a Linux kernel to run and is the first process in the system. The init process generates a child process, the child process shares the memory space of the father process, once the father process or the child process modifies a certain page of memory, the Linux kernel creates a copy of the page of memory exclusively belonging to the process, and therefore the father process and the child process can share memory pages with the same content and are not interfered with each other.
Disclosure of Invention
The embodiment of the application provides a process management method and device.
The method provided by the embodiment of the application comprises the following steps: starting an agent process, wherein the agent process loads a dynamic link library linked by the agent process to a memory; the agent process creates a first sub-process, and the first sub-process loads the first program by calling an entry function of the first program; the agent process creates a second sub-process, and the second sub-process loads the second program by calling an entry function of the second program; and the first program and the second program share the memory occupied by the dynamic link library.
Drawings
FIG. 1 is a schematic diagram illustrating a process of loading a program in a Linux system according to the prior art;
FIG. 2 is a schematic diagram illustrating the distribution of a memory after a Linux system loads a program in the prior art;
FIG. 3 is a schematic diagram illustrating a process of loading a program in the Linux system according to the embodiment of the present application;
fig. 4 is a schematic diagram illustrating memory distribution after a program is loaded in the Linux system in an embodiment of the present application;
FIG. 5 is a schematic diagram illustrating a start-up process of an application in an embodiment of the present application;
FIG. 6 is a schematic structural diagram of an apparatus according to an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of an apparatus according to another embodiment of the present application.
Detailed Description
While the concepts of the present application are susceptible to various modifications and alternative forms, specific embodiments thereof have been shown by way of example in the drawings and will herein be described in detail. It should be understood, however, that there is no intention to limit the concepts of the application to the specific forms disclosed, but on the contrary, the intention is to cover all modifications, equivalents, and alternatives consistent with the application and the appended claims.
References in the specification to "one embodiment," "an illustrative embodiment," etc., indicate that the embodiment described may include a particular feature, structure, or characteristic, but every embodiment may or may not include the particular feature, structure, or characteristic. Moreover, such phrases are not necessarily referring to the same embodiment. Further, it is believed that when a particular feature, structure, or characteristic is described in connection with an embodiment, it is submitted that it is within the knowledge of one skilled in the art to affect such feature, structure, or characteristic in connection with other embodiments whether or not explicitly described. In addition, it should be understood that items included in the list in the form of "at least one of a, B, and C" may represent (a); (B) (ii) a (C) (ii) a (A and B); (A and C); (B and C); or (A, B and C). Similarly, an item listed in the form of "at least one of a, B, or C" may represent (a); (B) (ii) a (C) (ii) a (A and B); (A and C); (B and C) or (A, B and C).
In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored by one or more transitory or non-transitory machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. A machine-readable storage medium may be embodied as any storage device, mechanism, or other physical structure for storing or transmitting information in a form readable by a machine (e.g., volatile or non-volatile memory, media disk, or other medium).
In the drawings, some structural or methodical features may be shown in a particular arrangement and/or order. However, it is to be understood that such specific arrangement and/or ordering may not be required. Rather, in some embodiments, the features may be arranged in a different manner and/or order than shown in the illustrative figures. In addition, the inclusion of a structural or methodical feature in a particular figure is not meant to imply that such feature is required in all embodiments and may not be included or may be combined with other features in some embodiments.
Referring to fig. 1, a schematic diagram of an init process start program a and a program b in a current Linux system is shown. As shown, the system first starts an init process, which calls the fork function to generate a sub-process a, which calls the exec function to load the program a. The loading process of program b is similar.
When the subprocess calls the exec function to load a new program, the memory space of the subprocess is completely cleared and rebuilt, namely, the subprocess and the init process do not have a shared memory page any more. At present, all init processes in the Linux system are realized by calling exec functions when creating new programs. Fig. 2 is a schematic diagram showing the distribution of memory in the system after the program a and the program b are started, and it can be seen that a copy exists in both the sub-processes of the program a and the program b in the dynamic link library.
Among them, dynamically linked libraries are a way to implement shared function libraries, allowing processes to call functions that do not belong to their executable code. There are a large number of dynamically linked libraries in the system, which most executables use. These dynamically linked libraries take up a large amount of memory. Therefore, how to reduce the memory overhead of the dynamic link library is a problem to be solved at present.
In the Linux system, an init process cannot link a dynamic link library, so that in the embodiment of the application, a proxy process (called a cinit process) is used for linking the dynamic link library, a subprocess is created by the proxy process, the subprocess created by the proxy process calls an entry function of a program to load the program, and the subprocess created by the proxy process loads the program by calling the entry function of the program instead of calling an exec () function to load the program, so that memories of different programs are prevented from being completely isolated; and because the agent process is linked with the dynamic link library, and the dynamic link library is loaded to the memory when the agent process is started, a plurality of programs loaded in the mode can share the memory of the dynamic link library loaded by the agent process, so that the memory overhead of the dynamic link library is reduced compared with the prior art that each program needs to store a copy of the dynamic link library.
The principles provided by the embodiments of the present application can be applied to a Linux system, and can also be applied to other systems with similar requirements.
The following describes a specific implementation process of the embodiment of the present application, taking an example of applying the embodiment of the present application to a Linux system.
When the computer is started, only one init process is established by a system kernel (kernel). The Linux kernel does not provide a system call for directly establishing a new process, and all other processes are established by an init process through a fork mechanism. fork is a system call by which an old process (parent process) can get a new process (child process) by copying itself by calling the fork function. The processes survive in the memory, and each process is allocated its own address space (address space) in the memory. When the fork function is called, Linux opens up a new memory space in a memory for a new process, copies the content in the memory space of an old process to the new space, and then the two processes run simultaneously.
Since the init process cannot link the dynamically linked library, a proxy process (called cinit process) is introduced in the embodiment of the present application. The agent process links dynamic link library at compiling time, the dynamic link library can comprise basic dynamic link library provided by Linux system, and the dynamic link library is used when general application program runs. During the initiation of the init process, the proxy process is initiated, so that the dynamic link library linked by the proxy process is loaded into the memory. Other processes in the system may be initiated by the agent process.
When a new program needs to be loaded (for example, a user clicks an icon of an application program through a screen touch operation of the mobile terminal, or other operations triggering the loading of the application program occur), a sub-process is created by the proxy process, and the sub-process loads the program by calling an entry function of the program.
In this process, the proxy process can still create a sub-process by calling the fork function. After the proxy process calls the fork function, the system allocates resources to the new process (sub-process), for example, Linux opens a new memory space in the memory for the new process to store data and code, and copies the contents in the old process space into the new space, wherein only a few parameters are different from those of the old process, so that the new process and the old process can achieve substantially the same function. Of course, the initial parameters or incoming variables entered when the fork function is called may also be different, so that the new process and the old process may implement different functions.
And the newly created process is used as a subprocess of the proxy process, the address of the entry function of the application program is obtained, and the entry function of the application program is called, so that the application program is loaded. In this case, the application program usually has a main function, which is an entry function of the application program and is a function that is called first when the application program is started, so that the application program starts to run. In other embodiments, when the application is started, other functions may be executed before the main function of the application, for example, __ libc _ start _ main function exists in the executable program compiled by the gcc compiler, and the main function is called, namely, the function is executed before the main function. In this case, after the agent process creates a sub-process, the sub-process can load the application by calling the __ libc _ start _ main function of the application.
Wherein the address of the entry function is available from the compiled and linked executable program. The source code of the application program needs to be compiled by a compiler and linked by a linker to form an Executable program, and the Executable program is usually stored in an Executable and Linkable Format (ELF for short) file. The ELF file comprises compiled machine instruction codes, data, a symbol table, debugging information, character strings and the like. The ELF file generally stores these file information in the form of "segments" or "sections" according to different attributes. The dynasym field in the ELF file is mainly used for storing information related to the operating system, such as variable names, function names, and the like. The main function address in the dynasym field in the ELF file may be obtained by calling the dlsym function.
By default, when the source code is compiled into an executable file, the address of the main function is not exported into the dynasym segment, i.e., the address of the main function cannot be obtained by calling the dlsym function. In the embodiment of the application, the address of the main function can be exported to the dynasym section when the linker is linked by modifying the linker. The modification method is different for different linkers. Of course any other method of deriving the address of the main function may be used. The method for obtaining the address of the entry function is not limited in the embodiments of the present application.
Further, in some embodiments, before a sub-process created by the proxy process calls an entry function of a program, the name of the sub-process is modified to be the same as the name of the program. In the Linux system, by default, the name of the child process is the same as that of the parent process (here, the proxy process cinit), otherwise the process name shows an error. The name of the process can be modified specifically in the following way:
mode 1: the sub-process calls a system call function for modifying the process name. In a Linux system, a prctl function is a system call function, has high authority, and can be used for setting the name of a process. The child process may therefore request from the operating system kernel to call a prctl function, the name of which is set by executing the prctl function.
Mode 2: the subprocess acquires an address of a memory area used for storing the process name in the subprocess, and modifies a parameter value stored in the memory area corresponding to the address (i.e., modifies the process name into the name of the application program). In the embodiment of the present application, in the memory space of the sub-process, the name of the sub-process is stored in the area with the address argv [0], and if the parameter value stored in the area changes, the name of the sub-process also changes. Therefore, if the parameter value stored in the area addressed to argv [0] in the sub-process is modified to the name of the application program that needs to be started, the name of the sub-process can be made the same as the name of the application program. The sub-process created subsequently can modify the parameter value stored in the area with the address argv [0] in the sub-process, so that each sub-process can set its name without interfering with other sub-processes.
Further, in some embodiments, after the application is started, if the application name needs to be modified (for example, when a special name needs to be displayed in the user interface for the current application), that is, the process name of the application needs to be modified, the following method may be further used for modification: the process of the application program obtains the address of the memory area for storing the process name (the address of the memory area is the value of the variable argv [0 ]) from the starting parameter stored in the memory unique to the process, and modifies the parameter value stored in the memory area corresponding to the address (i.e. modifies the process name into the new name of the application program).
Further, in some embodiments, some environment variables are associated with a process and need to be reset when a new program is launched, and the specific environment variables that need to be reset may depend on the platform. In the embodiment of the application, after the agent process creates the sub-process, the sub-process may reset the environment variable used by the program corresponding to the sub-process, and the operation of resetting the environment variable by the sub-process may be performed before the entry function is called or when the environment variable needs to be modified. For example, a value of an environment variable is a file name stored in the system by the application, and obviously, a file corresponding to each application is different, and the environment variable needs to be reset for each application.
Further, in some embodiments, it is contemplated that certain resources that cannot be inherited may generate errors if inherited by a sub-process, such as resources like file descriptors. Therefore, in the embodiment of the application, before the agent process creates the sub-process, the resource which cannot be inherited by the sub-process can be closed by the agent process. Wherein the proxy process can determine which resources cannot be inherited by the child process. In some examples, it may be preset which resources cannot be inherited by the sub-process, and the proxy process is required to close or release these resources before creating the sub-process. In another example, the parent process of the child process may determine which resources cannot be inherited by the child process according to a preset rule, for example, when the parent process listens to a network port, it does not want the child process to listen to the port, because it is usually wrong when two processes simultaneously listen to the same port, and it needs to shut down the port after the parent process calls the fork function and before the child process runs.
It should be noted that if the program started by the agent process uses the exec function to start other programs (and all programs started thereafter), their memories cannot be shared. Therefore, wherever it is desirable that a child process share memory with its parent process, the child process and loader need to be created in the manner described above. Since the above-mentioned scheme is general, in order to make other programs of the system comply with the scheme, the embodiment of the present application may provide an auxiliary function to implement the above-mentioned scheme, so that other programs can call the function, and thus, each process that needs to use the above-mentioned scheme to save memory can use the function without writing a code for implementing the above-mentioned scheme for each process.
The following describes a specific implementation process of the above embodiment by taking the loading process of the application program a and the application program b as an example, with reference to fig. 3 and fig. 4.
As shown in fig. 3 and 4, when the Linux system is started, the Linux kernel allocates a unique memory space for the init process, and guides the init process to run. The agent process (cinit) is started after the init process is started, the agent process has a unique memory space, and the memory space is distributed by a Linux kernel when the init process starts the agent process. Since the agent process links the basic dynamic link library of the Linux system at the time of compiling, the dynamic link library is loaded into the memory.
In the process of loading the application program a, as shown in fig. 3, a proxy process (cinit) calls a fork function, and a child process a is created. In the process, as shown in fig. 4, Linux opens a new memory space in the memory for the sub-process a (i.e. the memory unique to a shown in the figure) to store data and code, and copies the contents in the proxy process to the new space. As shown in fig. 3, the subprocess a calls a dlopen function, and the input parameters include the file name of the dynamic link library (which is the same as the file name of the dynamic link library connected to the proxy process), so that the dynamic link library is opened in the subprocess a. By calling the dlopen function, the handle of the dynamically linked library returned by the dlopen function can be passed into a parameter in the dlsym function to obtain the address of the symbol in the dynamically linked library, using this address, the pointer to the corresponding function in the dynamically linked library can be obtained, and the corresponding function in the dynamically linked library is called. The sub-process a calls the main function of the application program a, thereby starting the application program a.
In the process of loading the application program b, as shown in fig. 3, the proxy process (cinit) calls the fork function, and creates a child process b. In the process, as shown in fig. 4, Linux opens a new memory space in the memory for the sub-process b (i.e. the memory unique to b shown in the figure) to store data and code, and copies the contents in the proxy process to the new space. As shown in fig. 3, the subprocess b calls a dlopen function, and the input parameters include the file name of the dynamic link library (which is the same as the file name of the dynamic link library connected to the proxy process), so that the dynamic link library is opened in the subprocess a. The sub-process b calls the main function of the application program b, thereby starting the application program b.
As can be seen from fig. 4, the exec function is not used when the sub-process a and the sub-process b start the application, but the entry function is called, and the dynamic link library opened by the application a and the application b has been loaded into the memory by the proxy process, so that the application a and the application b can share the memory of the dynamic link library without respectively storing a copy of the dynamic link library.
When an application calls a function in a dynamically linked library loaded by a proxy process, the data modified by the function may be stored in a memory space unique to the application (or the process to which the application corresponds). For example, if an application a (sub-process a) calls a method (function) in a dynamically linked library and data needs to be modified (e.g., a value of a variable) during execution of the method (function), the operating system stores the data in the unique memory space of the application a (sub-process a); if the application b (sub-process b) calls the method (function) in the dynamically linked library and the same name variable needs to be modified during the execution of the method (function), the operating system stores the variable in the unique memory space of the application b (sub-process b). In this way, the application program a and the application program b can share the dynamic link library, but the variables modified by calling the dynamic link library are stored in respective unique memory spaces, so that data collision is avoided.
Referring to fig. 5, the flow takes the above application a as an example, and describes the starting process of the application. The start-up procedure of application b is similar. As shown in fig. 5, when the application a needs to be started, the process may include:
block 501: the agent process determines the resources that cannot be inherited by the child process and closes these resources.
Block 502: the proxy process calls the fork function to create a sub-process a. In the process, the system allocates a memory space unique to the sub-process to the newly created sub-process, and the memory space is exclusively owned by the sub-process.
Block 503: and the subprocess a calls a prctl function, and the name of the subprocess a is modified into the name of the application program a by executing the function.
Block 504: the child process a resets a part of the environment variables, such as a variable value for a file name stored in the storage system.
Block 505: the subprocess a calls a dlopen function, and takes the name of the dynamic link library loaded to the memory by the agent process as an input parameter of the function, so that the dynamic link library is opened in the subprocess a by executing the function.
Block 506: and the subprocess a calls a dlsym function to obtain the main function address of the application program a.
Block 507: and the subprocess a calls the main function of the application program a according to the main function address of the application program a, so as to load the application program a.
In the above-mentioned flow, the sequence from block 503 to block 506 may be adjusted, which is not limited in this embodiment of the present application.
The specific implementation process of the above flow can be referred to the foregoing embodiments, and is not repeated here.
As can be seen from the above description, in the above embodiments of the present application, when an init process in the system is started, a proxy process is started, and when the proxy process is started, a dynamic link library linked by the proxy process is loaded into a memory; when a program needs to be loaded, the agent process creates a sub-process, and the sub-process loads the program by calling an entry function of the program, so that a plurality of programs loaded in the above way can share the memory occupied by the dynamic link library loaded by the agent process, and each program does not need to store a copy of the dynamic link library, thereby reducing the memory overhead of the dynamic link library.
Based on the same technical concept, the embodiment of the present application further provides an apparatus, which can implement the processes described in the foregoing embodiments.
Referring to fig. 6, a schematic structural diagram of an apparatus provided in an embodiment of the present application is shown. The apparatus may include: a starting module 601 and a process creating module 602, wherein:
a starting module 601, configured to start an agent process, where the agent process loads a dynamic link library linked to the agent process into a memory; a process creating module 602, configured to create a first sub-process, where the first sub-process loads the first program by calling an entry function of the first program; creating a second subprocess, wherein the second subprocess loads the second program by calling an entry function of the second program; and the first program and the second program share the memory occupied by the dynamic link library.
Optionally, the starting module 601 is a first process in the operating system, and the proxy process started by the starting module is used for creating a sub-process by proxy of the first process.
Optionally, the process creation module 602 is further configured to: before calling an entry function of the first program, opening a dynamic link library in the first subprocess by calling a function for opening the dynamic link library, wherein an input parameter of the function comprises a file name of the dynamic link library; and before calling the entry function of the second program, opening the dynamic link library in the second subprocess by calling a function for opening the dynamic link library, wherein the input parameter of the function comprises the file name of the dynamic link library.
Optionally, before the first sub-process created by the process creation module 602 calls the entry function of the first program, the name of the first sub-process is modified to be the same as the name of the first program; before the second sub-process created by the process creation module 602 calls the entry function of the second program, the name of the second sub-process is modified to be the same as the name of the second program.
Optionally, the process creation module 602 is further configured to: before the first sub-process is created, closing resources which cannot be inherited by the first sub-process; and closing the resource which cannot be inherited by the second sub-process before the second sub-process is created.
Optionally, before the first sub-process created by the process creation module 602 calls the entry function of the first program, resetting the environment variable used by the first program; the environment variable used by the second program is reset before the second sub-process created by the process creation module 602 calls the entry function of the second program.
Optionally, when the first program is compiled, an entry function address of the first program is exported into an executable file of the first program; before the first sub-process created by the process creation module calls the entry function of the first program, acquiring an entry function address of the first program according to the executable file of the first program; when the second program is compiled, the entry function address of the second program is exported to an executable file of the second program; and before the second sub-process created by the process creation module calls the entry function of the second program, acquiring the entry function address of the second program according to the executable file of the second program.
Optionally, the apparatus may further include a processing module (not shown in the figure), where the processing module is configured to store, after the first program is loaded, data modified by a function in the dynamically linked library called by the first program in a memory space unique to the first sub-process; and after the second program is loaded, storing data modified by the function in the dynamic link library called by the second program in the memory space unique to the second sub-process.
Based on the same technical concept, the present application also provides one or more computer-readable media, where instructions are stored on the readable media, and when the instructions are executed by one or more processors, the instructions cause the user equipment to execute the procedures described in the foregoing embodiments.
Based on the same technical concept, the embodiment of the present application further provides an apparatus 700, where the apparatus 700 can implement the processes described in the foregoing embodiments.
Fig. 7 illustrates an example apparatus 700, according to various embodiments apparatus 700 may comprise one or more processors 702, system control logic 701 coupled to at least one processor 702, non-volatile memory (NMV)/memory 704 coupled to system control logic 701, and network interface 706 coupled to system control logic 701.
The processor 702 may include one or more single-core or multi-core processors. The processor 702 may comprise any combination of general purpose processors or dedicated processors (e.g., image processors, application processor baseband processors, etc.).
System control logic 701 in one embodiment may comprise any suitable interface controllers to provide for any suitable interface to at least one of processors 702 and/or to any suitable device or component in communication with system control logic 701.
The system control logic 701 in one embodiment may include one or more memory controllers to provide an interface to the system memory 703. System memory 703 is used to load and store data and/or instructions. For example, corresponding to apparatus 700, in one embodiment, system memory 703 may include any suitable volatile memory.
NVM/memory 704 may include one or more tangible, non-transitory computer-readable media for storing data and/or instructions. For example, NVM/memory 704 may include any suitable non-volatile storage device, such as one or more Hard Disk Drives (HDDs), one or more Compact Disks (CDs), and/or one or more Digital Versatile Disks (DVDs).
NVM/memory 704 may include storage resources that are physically part of a device on which the system is installed or may be accessed, but not necessarily part of a device. For example, NVM/memory 704 may be network accessible via network interface 706.
System memory 703 and NVM/storage 704 may include copies of temporary or persistent instructions 710, respectively. The instructions 710 may include instructions that, when executed by at least one of the processors 702, cause the apparatus 700 to implement one or a combination of the methods described in fig. 2-5. In various embodiments, the instructions 710 or hardware, firmware, and/or software components may additionally/alternatively be disposed in the system control logic 701, the network interface 706, and/or the processor 702.
Network interface 706 may include a receiver to provide a wireless interface for apparatus 700 to communicate with one or more networks and/or any suitable device. The network interface 706 may include any suitable hardware and/or firmware. The network interface 706 may include multiple antennas to provide a multiple-input multiple-output wireless interface. In one embodiment, network interface 706 may include a network adapter, a wireless network adapter, a telephone modem, and/or a wireless modem.
In one embodiment, at least one of the processors 702 may be packaged together with logic for one or more controllers of system control logic. In one embodiment, at least one of the processors may be packaged together with logic for one or more controllers of system control logic to form a system in a package. In one embodiment, at least one of the processors may be integrated on the same die with logic for one or more controllers of system control logic. In one embodiment, at least one of the processors may be integrated on the same die with logic for one or more controllers of system control logic to form a system chip.
The device 700 may further include input/output devices 705,. Input/output devices 705 may include a user interface intended to enable a user to interact with device 700, may include a peripheral component interface designed to enable peripheral components to interact with the system, and/or may include sensors intended to determine environmental conditions and/or location information about device 700.
The present disclosure may include various example embodiments disclosed below.
In example embodiment 1, the method employed may be combined: starting an agent process, wherein the agent process loads a dynamic link library linked by the agent process to a memory; the agent process creates a first sub-process, and the first sub-process loads the first program by calling an entry function of the first program; the agent process creates a second sub-process, and the second sub-process loads the second program by calling an entry function of the second program; and the first program and the second program share the memory occupied by the dynamic link library.
In example embodiment 2, according to example embodiment 1, the proxy process is started by a first process in an operating system, and the proxy process is configured to proxy the first process to create a sub-process.
In example embodiment 3, according to example embodiments 1 to 2, further comprising: opening the dynamic link library in the first subprocess by calling a function for opening the dynamic link library, wherein the input parameter of the function comprises the file name of the dynamic link library; and/or, further comprising: and opening the dynamic link library in the second subprocess by calling a function for opening the dynamic link library, wherein the input parameter of the function comprises the file name of the dynamic link library.
In example embodiment 4, according to example embodiments 1 to 3, further comprising: modifying the name of the first sub-process to be the same as the name of the first program; and/or, further comprising: and modifying the name of the second subprocess to be the same as the name of the second program.
In example embodiment 5, according to example embodiment 4, the name of the child process is modified by: the subprocess calls a system call function for modifying the process name; or the subprocess acquires the address of the memory area used for storing the process name in the subprocess, and modifies the parameter value stored in the memory area corresponding to the address.
In example embodiment 6, according to example embodiments 1 to 5, before the creating, by the agent process, the first sub-process, the method further includes: closing a resource that cannot be inherited by the first sub-process; before the agent process creates the second sub-process, the method further includes: closing a resource that cannot be inherited by the second child process.
In example embodiment 7, according to example embodiments 1 to 6, further comprising: resetting an environment variable used by the first program; and/or, further comprising: resetting an environment variable used by the second program.
In example embodiment 8, according to example embodiments 1 to 7, further comprising: the first sub-process acquires an address of a memory area for storing a first sub-process name, and modifies a parameter value stored in the memory area corresponding to the address; and/or, further comprising: the second sub-process sends a request to the agent process; and the agent process acquires an address for storing the parameter of the second subprocess name according to the request and modifies the parameter value in the address.
In example embodiment 9, according to example embodiments 1 to 8, further comprising: storing data modified by a function in the dynamic link library called by the first program in a memory space unique to the first sub-process; and/or, further comprising: and storing data modified by the function in the dynamic link library called by the second program in the unique memory space of the second sub-process.
In example embodiment 10, according to example embodiments 1 to 9, when the first program is compiled, an entry function address of the first program is exported into an executable file of the first program; before the first subprocess calls the entry function of the first program, the entry function address of the first program is obtained according to the executable file of the first program; when the second program is compiled, the entry function address of the second program is exported to an executable file of the second program; and before the second subprocess calls the entry function of the second program, acquiring the entry function address of the second program according to the executable file of the second program.
The present disclosure may also include various example embodiments disclosed below.
In example embodiment 1, an apparatus may be combined, and the apparatus may include: the starting module is used for starting the agent process, and the agent process loads the dynamic link library linked by the agent process to the memory; the process creation module is used for creating a first subprocess, and the first subprocess loads the first program by calling an entry function of the first program; creating a second subprocess, wherein the second subprocess loads the second program by calling an entry function of the second program; and the first program and the second program share the memory occupied by the dynamic link library.
In example embodiment 2, according to example embodiment 1, the start module is a first process in an operating system, and the proxy process started by the start module is used to proxy the first process to create a sub-process.
In example embodiment 3, according to example embodiments 1-2, the process creation module is further configured to: opening the dynamic link library in the first subprocess by calling a function for opening the dynamic link library, wherein the input parameter of the function comprises the file name of the dynamic link library; and/or opening the dynamic link library in the second subprocess by calling a function for opening the dynamic link library, wherein the input parameter of the function comprises the file name of the dynamic link library.
In example embodiment 4, according to example embodiments 1 to 3, the first sub-process created by the process creation module modifies a name of the first sub-process to be the same as a name of the first program; and/or the second sub-process created by the process creation module modifies the name of the second sub-process to be the same as the name of the second program.
In example embodiment 5, according to example embodiments 1-4, the process creation module is further configured to: before the first sub-process is created, closing resources which cannot be inherited by the first sub-process; and closing the resource which cannot be inherited by the second sub-process before the second sub-process is created.
In example embodiment 6, according to example embodiments 1 to 5, the first sub-process created by the process creation module resets an environment variable used by the first program; and/or the second sub-process created by the process creation module resets the environment variable used by the second program.
In example embodiment 7, according to example embodiments 1 to 6, the method further includes storing, in the memory space unique to the first sub-process, data modified by a function in the dynamically linked library called by the first program; and/or storing data modified by the function in the dynamic link library called by the second program in the unique memory space of the second sub-process.
In example embodiment 8, according to example embodiments 1 to 7, when the first program is compiled, an entry function address of the first program is exported into an executable file of the first program; the first sub-process created by the process creation module acquires an entry function address of the first program according to the executable file of the first program; when the second program is compiled, the entry function address of the second program is exported to an executable file of the second program; and/or the second sub-process created by the process creation module acquires the entry function address of the second program according to the executable file of the second program.
The present disclosure may also include various example embodiments disclosed below.
In example embodiment 1, the computer-readable medium may be combined, which may include: one or more computer-readable media having instructions stored thereon, which when executed by one or more processors, cause a communication device to perform the method of any of claims 1-10.
The present disclosure may also include various example embodiments disclosed below.
In example embodiment 1, the apparatus may perform a merge, which may include: one or more processors; and one or more computer-readable media having instructions stored thereon that, when executed by the one or more processors, cause the apparatus to perform the method of any of claims 1-10.

Claims (20)

1. A process management method, comprising:
starting an agent process, wherein the agent process loads a dynamic link library linked by the agent process to a memory;
the agent process creates a first sub-process, and the first sub-process loads a first program by calling an entry function of the first program;
the agent process creates a second sub-process, and the second sub-process loads a second program by calling an entry function of the second program;
the first program and the second program share the memory occupied by the dynamic link library;
the agent process is started by an init process, the agent process has a unique memory space, the memory space is distributed by a Linux kernel when the init process starts the agent process, and the agent process is linked with the dynamic link library during compiling.
2. The method of claim 1, wherein the proxy process is initiated by a first process in an operating system, the proxy process for proxying the first process to create a child process.
3. The method of claim 1, further comprising: opening the dynamic link library in the first subprocess by calling a function for opening the dynamic link library, wherein the input parameter of the function comprises the file name of the dynamic link library; and/or
Further comprising: and opening the dynamic link library in the second subprocess by calling a function for opening the dynamic link library, wherein the input parameter of the function comprises the file name of the dynamic link library.
4. The method of claim 1, further comprising: modifying the name of the first sub-process to be the same as the name of the first program; and/or
Further comprising: and modifying the name of the second subprocess to be the same as the name of the second program.
5. The method of claim 4, wherein the name of the child process is modified by:
the subprocess calls a system call function for modifying the process name; or,
and the subprocess acquires the address of the memory area used for storing the process name in the subprocess, and modifies the parameter value stored in the memory area corresponding to the address.
6. The method of claim 1, wherein prior to the proxy process creating the first sub-process, further comprising: closing a resource that cannot be inherited by the first sub-process; and/or
Before the agent process creates the second sub-process, the method further includes: closing a resource that cannot be inherited by the second child process.
7. The method of claim 1, further comprising: resetting an environment variable used by the first program; and/or
Further comprising: resetting an environment variable used by the second program.
8. The method of claim 1, further comprising:
the first sub-process acquires an address of a memory area for storing a first sub-process name, and modifies a parameter value stored in the memory area corresponding to the address;
and/or, further comprising:
the second sub-process sends a request to the agent process;
and the agent process acquires an address for storing the parameter of the second subprocess name according to the request and modifies the parameter value in the address.
9. The method of claim 1, further comprising:
storing data modified by a function in the dynamic link library called by the first program in a memory space unique to the first sub-process; and/or
And storing data modified by the function in the dynamic link library called by the second program in the unique memory space of the second sub-process.
10. The method of any of claims 1-9, wherein an entry function address of the first program is exported into an executable file of the first program when the first program is compiled; before the first subprocess calls the entry function of the first program, the entry function address of the first program is obtained according to the executable file of the first program;
when the second program is compiled, the entry function address of the second program is exported to an executable file of the second program; and before the second subprocess calls the entry function of the second program, acquiring the entry function address of the second program according to the executable file of the second program.
11. A process management apparatus, comprising:
the starting module is used for starting the agent process, and the agent process loads the dynamic link library linked by the agent process to the memory;
the process creation module is used for creating a first subprocess by the proxy process, and the first subprocess loads the first program by calling an entry function of the first program; and
creating a second sub-process by the proxy process, the second sub-process loading a second program by calling an entry function of the second program;
the first program and the second program share the memory occupied by the dynamic link library;
the agent process is started by an init process, the agent process has a unique memory space, the memory space is distributed by a Linux kernel when the init process starts the agent process, and the agent process is linked with the dynamic link library during compiling.
12. The apparatus of claim 11, wherein the launch module is a first process in an operating system, and wherein the proxy process launched by the launch module is to proxy for the first process to create a child process.
13. The apparatus of claim 11, wherein the process creation module is further to: opening the dynamic link library in the first subprocess by calling a function for opening the dynamic link library, wherein the input parameter of the function comprises the file name of the dynamic link library; and/or
And opening the dynamic link library in the second subprocess by calling a function for opening the dynamic link library, wherein the input parameter of the function comprises the file name of the dynamic link library.
14. The apparatus of claim 11, wherein the first sub-process created by the process creation module modifies a name of the first sub-process to be the same as a name of the first program; and/or
The second sub-process created by the process creation module modifies the name of the second sub-process to be the same as the name of the second program.
15. The apparatus of claim 11, wherein the process creation module is further to: before the first sub-process is created, closing resources which cannot be inherited by the first sub-process; and
closing resources that cannot be inherited by the second sub-process prior to creating the second sub-process.
16. The apparatus of claim 11, wherein the first sub-process created by the process creation module resets an environment variable used by the first program before calling an entry function of the first program; and/or
And resetting the environment variable used by the second program before the second sub-process created by the process creation module calls the entry function of the second program.
17. The apparatus of claim 11, further comprising:
the processing module is used for storing data modified by a function in the dynamic link library called by the first program into a unique memory space of the first subprocess; and/or storing data modified by the function in the dynamic link library called by the second program in the unique memory space of the second sub-process.
18. The apparatus of any of claims 11 to 17, wherein an entry function address of the first program is exported into an executable file of the first program when the first program is compiled; the first sub-process created by the process creation module acquires an entry function address of the first program according to the executable file of the first program;
when the second program is compiled, the entry function address of the second program is exported to an executable file of the second program; and the second sub-process created by the process creation module acquires the entry function address of the second program according to the executable file of the second program.
19. A computer-readable medium having instructions stored thereon, which when executed by one or more processors, cause the processors to perform the method of any one of claims 1-10.
20. A process management apparatus, comprising:
one or more processors; and
a computer-readable medium having instructions stored thereon, which, when executed by the one or more processors, cause the apparatus to perform the method of any of claims 1-10.
CN201611078446.1A 2016-11-29 2016-11-29 Process management method and device Active CN108121594B (en)

Priority Applications (3)

Application Number Priority Date Filing Date Title
CN201611078446.1A CN108121594B (en) 2016-11-29 2016-11-29 Process management method and device
TW106126766A TW201820131A (en) 2016-11-29 2017-08-08 Process management method and apparatus
PCT/CN2017/111997 WO2018099292A1 (en) 2016-11-29 2017-11-21 Process management method and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611078446.1A CN108121594B (en) 2016-11-29 2016-11-29 Process management method and device

Publications (2)

Publication Number Publication Date
CN108121594A CN108121594A (en) 2018-06-05
CN108121594B true CN108121594B (en) 2020-10-20

Family

ID=62226976

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611078446.1A Active CN108121594B (en) 2016-11-29 2016-11-29 Process management method and device

Country Status (3)

Country Link
CN (1) CN108121594B (en)
TW (1) TW201820131A (en)
WO (1) WO2018099292A1 (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109086136A (en) * 2018-07-26 2018-12-25 广东浪潮大数据研究有限公司 A kind of request processing method and relevant apparatus of Samba software
CN109408147B (en) * 2018-10-22 2022-04-19 深圳市元征科技股份有限公司 Protocol determination method, system, device and readable storage medium
CN112083998B (en) * 2019-06-14 2024-05-17 中车株洲电力机车研究所有限公司 Dynamic configuration method and device for task parameters in RTP of VxWorks system
CN112256339B (en) * 2019-07-22 2023-11-03 百度在线网络技术(北京)有限公司 Multi-process management method, device, electronic equipment and storage medium
CN111083195B (en) * 2019-11-12 2022-09-13 烽火通信科技股份有限公司 Virtual single disk proxy system and method
CN113282380B (en) * 2020-02-18 2024-05-24 深圳信可通讯技术有限公司 Method, device and computer readable medium for calling multipath control interface
CN111596970B (en) * 2020-05-12 2023-04-28 广州市百果园信息技术有限公司 Method, device, equipment and storage medium for dynamic library delay loading
CN113377543A (en) * 2021-06-28 2021-09-10 上海商汤科技开发有限公司 Task processing system, electronic device, and storage medium
CN113360271B (en) * 2021-07-21 2025-02-07 深圳前海微众银行股份有限公司 Process management method, device, equipment, storage medium and program product
CN114020621B (en) * 2021-11-03 2025-09-30 展讯通信(天津)有限公司 Debugging method, electronic device and storage medium
CN114371843A (en) * 2021-12-14 2022-04-19 北京淘友天下科技发展有限公司 Task execution method, device, electronic equipment, storage medium and program product
CN114385261A (en) * 2021-12-23 2022-04-22 湖南小算科技信息有限公司 Method for loading program in process
CN114595462B (en) * 2022-02-15 2024-08-20 阿里云计算有限公司 Data processing method and device
CN114756243B (en) * 2022-05-05 2025-08-05 节卡机器人股份有限公司 Custom module control system, method, device and storage medium
CN115309523A (en) * 2022-07-28 2022-11-08 青岛云天励飞科技有限公司 Data processing method, device, electronic device and storage medium
CN115589503B (en) * 2022-10-28 2024-10-18 惠州市德赛西威汽车电子股份有限公司 Method, system, host and storage medium for realizing boot animation of vehicle-mounted host
CN119781973B (en) * 2024-12-18 2025-08-05 江苏卓易信息科技股份有限公司 A method for merging binaries to save firmware space

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8607013B2 (en) * 2007-10-30 2013-12-10 Vmware, Inc. Providing VMM access to guest virtual memory
CN101382953B (en) * 2008-09-19 2013-03-20 中兴通讯股份有限公司 Interface system for accessing file system in user space and file reading and writing method
CN101576912A (en) * 2009-06-03 2009-11-11 中兴通讯股份有限公司 System and reading and writing method for realizing asynchronous input and output interface of distributed file system
US9104504B2 (en) * 2013-03-13 2015-08-11 Dell Products Lp Systems and methods for embedded shared libraries in an executable image

Also Published As

Publication number Publication date
TW201820131A (en) 2018-06-01
WO2018099292A1 (en) 2018-06-07
CN108121594A (en) 2018-06-05

Similar Documents

Publication Publication Date Title
CN108121594B (en) Process management method and device
CN111475227B (en) Business plug-in loading implementation method and device and terminal equipment
CN107967139B (en) Hot updating method and device for game
US10019598B2 (en) Dynamic service discovery
CN110659031B (en) Application compilation method, device, electronic device and storage medium
CN101937356B (en) Method for compiling WebKit browser and device thereof
CN109614772B (en) Code conversion method and device based on application installation package file
CN111736913B (en) Class loading method and device
CN112668008B (en) Method for realizing dynamic system call hijacking based on LSM
CN111651169B (en) Block chain intelligent contract operation method and system based on web container
US20120227056A1 (en) Method and system for enabling access to functionality provided by resources outside of an operating system environment
CN110333872B (en) Application processing method, device, equipment and medium
CN108595192A (en) A kind of installation method and terminal device of application program
CN114077460A (en) Method, equipment and medium for calling Android dynamic library HAL interface by software operating system
CN110045998B (en) Method and device for loading dynamic library
JP2007510211A (en) Mapping dynamic link libraries on computer equipment
CN114880076B (en) Dynamic loading method and device for dynamic mapping file of user-mode virtual machine
US12050928B2 (en) Method and apparatus of providing a function as a service (faas) deployment of an application
CN111381816A (en) Application program acquisition method, device, equipment and storage medium
CN111045746B (en) Code expansion method and framework
CN113282363A (en) Method and device for optimizing hybrid APP
CN106775608B (en) Method and device for realizing independent system process
CN109947407B (en) Data acquisition method and device
CN114416219B (en) System function calling method, device, electronic equipment and readable medium
CN112612531A (en) Application program starting method and device, electronic equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20240621

Address after: Room 201, No. 9 Fengxiang East Street, Yangsong Town, Huairou District, Beijing

Patentee after: Youku Culture Technology (Beijing) Co.,Ltd.

Country or region after: China

Address before: Cayman Islands Grand Cayman capital building, a four storey No. 847 mailbox

Patentee before: ALIBABA GROUP HOLDING Ltd.

Country or region before: Cayman Islands