CN115756849A - Memory allocation method, device, equipment and medium in microkernel operating system - Google Patents
Memory allocation method, device, equipment and medium in microkernel operating system Download PDFInfo
- Publication number
- CN115756849A CN115756849A CN202211453630.5A CN202211453630A CN115756849A CN 115756849 A CN115756849 A CN 115756849A CN 202211453630 A CN202211453630 A CN 202211453630A CN 115756849 A CN115756849 A CN 115756849A
- Authority
- CN
- China
- Prior art keywords
- memory
- driver
- pool
- program
- application program
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Stored Programmes (AREA)
Abstract
The application provides a memory allocation method, device, equipment and medium in a microkernel operating system. In the method, when the application program process is initialized, the application program process establishes an interface through a memory pool of a kernel mode memory management program and a user mode memory management program in a driver program, and establishes the memory pool. When the memory needs to be allocated each time, the application program process calls a drive program according to the preset memory allocation capacity; and the driver thread allocates the memory from the memory pool according to the memory allocation interface of the user mode memory management program and the preset memory allocation capacity. According to the scheme, the memory pool is created when the application program process is initialized, and then the memory is allocated through the user mode memory management program located in the user space each time the memory is allocated, the memory does not need to enter the kernel space, and the memory allocation efficiency is effectively improved.
Description
Technical Field
The present application relates to the field of computers, and in particular, to a method, an apparatus, a device, and a medium for allocating memory in a microkernel operating system.
Background
The microkernel operating system is used as an operating system based on a microkernel architecture, and all functions are moved to a user space to be realized in a user-mode service process mode, so that strong isolation among service processes is ensured, and the microkernel operating system has high stability and reliability.
In the prior art, when an application program is run in a microkernel operating system, a memory is allocated to the application program process for many times. In the process of allocating the memory each time, the application program process sends a memory allocation request to the memory management process through the driver program process, and the memory management process allocates the memory. In the microkernel operating system, a memory management Process and a driver Process are located in a user space and belong to a user state, the driver Process sends a memory allocation request to the memory management Process in an Inter-Process Communication (IPC) mode, and the IPC spans the user space and the kernel space.
In summary, in the memory allocation method in the existing microkernel operating system, in each memory allocation process, a memory allocation request needs to be sent through an IPC, and the IPC needs to go from a user space to a kernel space and then to the user space, which results in low memory allocation efficiency.
Disclosure of Invention
The embodiment of the application provides a memory allocation method, a memory allocation device, memory allocation equipment and a memory allocation medium in a microkernel operating system, which are used for solving the problem of low memory allocation efficiency caused by the fact that in the existing memory allocation method in the microkernel operating system, in the process of allocating memory each time, a memory allocation request needs to be sent through IPC (inter-process control) which needs to go from a user space to a kernel space and then to the user space.
In a first aspect, an embodiment of the present application provides a memory allocation method in a microkernel operating system, which is applied to an electronic device installed with the microkernel operating system, where the microkernel operating system includes an application program, a driver, a user-mode memory management program, and a kernel-mode memory management program, and the method includes:
when an application program process corresponding to an application program is initialized, the application program process establishes a memory pool through the kernel mode memory management program and a memory pool establishing interface of the user mode memory management program in the driver program;
the application program process calls the driving program according to preset memory allocation capacity;
and the driver thread corresponding to the driver allocates the memory from the memory pool according to the preset memory allocation capacity and the memory allocation interface of the user mode memory management program.
In a specific embodiment, when an application program process corresponding to an application program is initialized, the application program process creates a memory pool through a memory pool creation interface of the kernel-mode memory management program and the user-mode memory management program in the driver, and the creating includes:
when the application program process is initialized, the application program process calls the driver program according to the capacity of a preset memory pool;
calling a memory pool creation interface of the user-mode memory management program by a driver thread corresponding to the driver according to the preset memory pool capacity;
and controlling the kernel-mode memory management program to create the memory pool by a user-mode memory management thread corresponding to the user-mode memory management program through a system call interface.
In a specific embodiment, allocating, by a driver thread corresponding to the driver, a memory from the memory pool according to the preset memory allocation capacity and a memory allocation interface of the user-mode memory management program includes:
and if the driver thread judges that the available memory capacity of the memory pool is greater than or equal to the preset memory allocation capacity, the driver thread calls the memory allocation interface to allocate the memory from the memory pool.
In a specific embodiment, allocating, by a driver thread process corresponding to the driver, a memory from the memory pool according to the preset memory allocation capacity and a memory allocation interface of the user-mode memory management program includes:
if the driver thread judges that the available memory capacity of the memory pool is smaller than the preset memory allocation capacity, the driver thread expands the memory pool through the memory pool creation interface and the kernel mode memory management program;
and calling the memory allocation interface by the driver thread, and allocating the memory from the expanded memory pool.
In one embodiment, the method further comprises:
and when the driver thread monitors that the unavailable memory capacity of the memory pool is zero, releasing the memory pool.
In one embodiment, the method further comprises:
and when the application program process calls the driver program, if the memory pool is released, the driver program thread creates the memory pool through the memory pool creation interface and the kernel mode memory management program.
In a second aspect, an embodiment of the present application provides an apparatus for allocating memory in a microkernel operating system, including:
the device comprises a creating module, a memory pool creating module and a memory pool creating module, wherein the creating module is used for creating a memory pool through a kernel mode memory management program and a memory pool creating interface of a user mode memory management program in a driver program by an application program process when the application program process corresponding to the application program is initialized;
the communication module is used for calling the driving program through the application program process according to the preset memory allocation capacity;
and the allocation module is used for allocating the memory from the memory pool through a driver thread corresponding to the driver according to the preset memory allocation capacity and the memory allocation interface of the user mode memory management program.
In a third aspect, an embodiment of the present application provides an electronic device, including:
a processor, a memory, a communication interface;
the memory is used for storing executable instructions of the processor;
wherein the processor is configured to execute the memory allocation method in the microkernel operating system according to any one of the first aspect by executing the executable instructions.
In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the memory allocation method in the microkernel operating system according to any one of the first aspect.
In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the computer program is used to implement the memory allocation method in the microkernel operating system according to any one of the first aspect.
According to the memory allocation method, device, equipment and medium in the microkernel operating system, when the application program process is initialized, the application program process creates an interface through the memory pool of the kernel-mode memory management program and the user-mode memory management program in the driver program, and creates the memory pool. When the memory needs to be allocated each time, the application program process calls a drive program according to the preset memory allocation capacity; and the driver thread allocates the memory from the memory pool according to the memory allocation interface of the user mode memory management program and the preset memory allocation capacity. According to the scheme, the memory pool is created when the application program process is initialized, and then the memory is allocated through the user mode memory management program located in the user space each time the memory is allocated, the memory does not need to enter the kernel space, and the memory allocation efficiency is effectively improved.
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 introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to these drawings without inventive exercise.
Fig. 1a is a schematic diagram illustrating a memory allocation process of a macro kernel operating system in the prior art provided in the present application;
FIG. 1b is a schematic diagram illustrating a memory allocation process of a microkernel operating system in the prior art according to the present application;
fig. 2a is a schematic flowchart illustrating a first embodiment of a memory allocation method in a microkernel operating system according to the present application;
FIG. 2b is a schematic diagram illustrating a memory allocation process of the microkernel operating system according to the present invention;
fig. 3 is a schematic flowchart illustrating a second embodiment of a memory allocation method in a microkernel operating system according to the present application;
fig. 4 is a schematic flowchart illustrating a third embodiment of a memory allocation method in a microkernel operating system according to the present application;
fig. 5 is a schematic flowchart illustrating a fourth embodiment of a method for allocating memory in a microkernel operating system according to the present application;
FIG. 6 is a schematic structural diagram illustrating an embodiment of a memory allocation apparatus in a microkernel operating system according to the present invention;
fig. 7 is a schematic structural diagram of an electronic device provided in the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments that can be made by one skilled in the art based on the embodiments in the present application in light of the present disclosure are within the scope of the present application.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims of the present application and in the above-described drawings (if any) are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the application described herein may be implemented in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
With the rapid development of science and technology, an operating system is also developed from a macro kernel operating system to a micro kernel operating system, and no matter the macro kernel operating system or the micro kernel operating system, when an application program is run, a memory is allocated to the application program for many times.
For a macro kernel operating system, for example, fig. 1a is a schematic diagram illustrating a memory allocation flow of a macro kernel operating system in the prior art provided in the present application; as shown in fig. 1a, in the macro kernel operating system, an application program process is located in a user space, and a driver program process and a memory management process are located in a kernel space, and when a memory is allocated, the application program process calls the driver program process through a system call interface, and then drives a function interface to call the memory management process through a corresponding function interface, so that the memory management process allocates the memory, and returns an execution result to the application program.
For the microkernel operating system, the driver is located in the user space, and the driver directly interacts with various hardware peripherals, and the hardware peripherals need to use physical addresses but cannot use virtual addresses when accessing the memory, so that the user-mode driver not only needs to know the virtual addresses of the memory to provide the memory for a Central Processing Unit (CPU) to access, but also needs to know the physical addresses of the memory to provide the memory for the peripheral to access. In addition, the hardware peripheral needs to use a section of memory continuous in the physical address space as a buffer, which requires the driver to allocate the physical memory continuous in the physical address space.
For example, fig. 1b is a schematic diagram illustrating a memory allocation process of a microkernel operating system in the prior art provided by the present application; as shown in fig. 1b, in the microkernel operating system, an application program process, a driver program process, and a memory management process are located in a user space, and in the process of allocating a memory each time, the application program process sends a memory allocation request to the memory management process through the driver program process, and the memory management process allocates the memory. In a microkernel operating system, a memory management Process and a driver Process are located in a user space and belong to a user state, the driver Process sends a memory allocation request to the memory management Process in an Inter-Process Communication (IPC) mode, and the IPC needs to go from the user space to the kernel space and then to the user space, so that the memory allocation efficiency is low.
In order to solve the problems in the prior art, the inventor finds that, in the process of researching a memory allocation method in a microkernel operating system, in order to improve the memory allocation efficiency, memory allocation can be completed in a user space by allocating memory without passing through a kernel space. When the application program process is initialized, the application program process establishes an interface through a memory pool of a kernel mode memory management program and a user mode memory management program in a driver program, and establishes a memory pool. And then, when the memory is allocated to the application program every time, the application program process calls the driving program according to the preset memory allocation capacity. The driver process allocates the memory from the memory pool according to the preset memory allocation capacity and the memory allocation interface of the user mode memory management program, and the memory allocation efficiency is effectively improved. Based on the inventive concept, the memory allocation scheme in the microkernel operating system is designed.
The main execution body of the memory allocation method in the microkernel operating system in the application can be a smart phone terminal, and can also be a device such as a tablet computer or a computer which can run the microkernel operating system.
An application scenario of the memory allocation method in the microkernel operating system provided by the present application is described below.
For example, in the application scenario, after a user powers on a smartphone terminal, when the user opens an application program, an application program process of the application program is initialized, and the application program process creates an interface through a kernel-mode memory management program and a memory pool of a user-mode memory management program in a driver, and creates a memory pool corresponding to the application program.
And then the user clicks the screen in the process of using the application program, and the application program process needs to be allocated with a memory to store click data, so the application program process calls the driving program. And the driver thread allocates the memory from the memory pool according to the memory allocation interface of the user mode memory management program and the preset memory allocation capacity.
After the allocated memory is used up, the memory can be released to the memory pool, and when the memory is allocated next time, the memory is still allocated from the memory pool.
It should be noted that the above scenario is only an example of an application scenario provided in the embodiment of the present application, and the embodiment of the present application does not limit actual forms of various devices included in the scenario, nor limits an interaction manner in the devices, and in a specific application of a scheme, the scenario may be set according to actual requirements.
The technical solution of the present application will be described in detail below with reference to specific examples. It should be noted that the following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
Fig. 2a is a schematic flowchart of a first embodiment of a method for allocating memory in a microkernel operating system according to the present application, and this application embodiment describes a situation that a corresponding memory pool is created when an application program process is initialized, and then memory is allocated from the memory pool by a user mode memory management program located in a user space when the application program process is allocated with memory. The method in this embodiment may be implemented by software, hardware, or a combination of software and hardware. As shown in fig. 2a, the method for allocating memory in the microkernel operating system specifically includes the following steps:
s201: when an application program process corresponding to an application program is initialized, the application program process establishes an interface through a memory pool of a kernel mode memory management program and a user mode memory management program in a driver program, and establishes a memory pool.
In this step, the microkernel operating system includes an application program, a driver, a user mode memory manager, and a kernel mode memory manager. In order to improve the memory allocation efficiency, it is necessary to create a memory pool corresponding to an application program process when the application program process is initialized. And the application program process establishes an interface through a memory pool of a kernel mode memory management program and a user mode memory management program in the driver program, and establishes a memory pool.
In the microkernel operating system, an application program process and a driver program thread corresponding to a driver program are positioned in a user space, the driver program comprises a user mode memory management program, and the user mode memory management program is compiled into a lib file and is compiled into a program together with the driver program. And the kernel mode memory management process corresponding to the kernel mode memory management program is positioned in the kernel space. The application program process creates an interface through a memory pool of a user mode memory management program in a driver program, calls a system call interface, controls a kernel mode memory management program to allocate a memory from a physical memory of a system, and maps the memory into an address space of the application program to complete the creation of the memory pool.
S202: and calling the driving program by the application program process according to the preset memory allocation capacity.
In this step, after the memory pool corresponding to the application program process is created, when the application program process needs to use a memory, that is, when the memory is allocated, a driver is called according to a preset memory allocation capacity.
It should be noted that the preset memory allocation capacity may be set in the execution subject of the present application by the user, or may be generated by the application program process. The preset memory allocation capacity may also be 20 bytes, 70 bytes, or 400 bytes, and the embodiment of the present application does not limit the preset memory allocation capacity, and may be determined according to an actual situation.
S203: and the driver thread corresponding to the driver allocates the memory from the memory pool according to the preset memory allocation capacity and the memory allocation interface of the user mode memory management program.
In this step, after the application program process calls the driver program, the driver program thread calls the memory allocation interface of the user-mode memory management program according to the preset memory allocation capacity, so that the user-mode memory management program allocates the memory from the memory pool according to the preset memory allocation capacity, and the allocated memory capacity is the same as the preset memory allocation capacity.
For example, fig. 2b is a schematic diagram illustrating a memory allocation process of a microkernel operating system according to the present application; as shown in fig. 2b, in the microkernel operating system, an application program process and a driver program thread are located in a user space, the driver program thread includes a user mode memory management thread, and the kernel mode memory management process is located in a kernel space. When the application program process is initialized, the application program process creates an interface through a memory pool of a user mode memory management program in a driver program, calls a kernel mode memory management process to complete the creation of the memory pool, and the kernel mode memory management process returns the creation result to the application program process. In the process of allocating the memory each time, the application program process calls the driver. And the driver thread allocates the memory from the memory pool according to the memory allocation interface of the user mode memory management program.
It should be noted that the interface name in the user mode memory management program may be the same as the interface name in the kernel mode memory management program in the Linux system, so that the driver in the kernel space of the Linux system is conveniently transplanted to the user space.
In the memory allocation method in the microkernel operating system provided in this embodiment, when an application program process is initialized, a memory pool corresponding to the application program process is created. And when the memory is allocated, the application program process calls a driver program, and the driver program thread allocates the memory from the memory pool according to the memory allocation interface of the user mode memory management program. Compared with the prior art that the memory allocation request is sent through the IPC from the user space to the kernel space and then to the user space in the process of allocating the memory each time, the memory allocation method and the device can be completed in the user space when the memory is allocated each time, and the memory allocation efficiency is effectively improved.
Fig. 3 is a schematic flow diagram of a second embodiment of a memory allocation method in a microkernel operating system according to the present application, where, on the basis of the foregoing embodiments, the embodiment of the present application describes a situation in which an application program process calls a driver, and the driver thread calls a memory pool creation interface of a user-mode memory management program, so as to control a kernel-mode memory management program to create a memory pool through the system call interface. As shown in fig. 3, the method for allocating memory in the microkernel operating system specifically includes the following steps:
s301: and when the application program process is initialized, the application program process calls the driving program according to the preset memory pool capacity.
In this step, in order to improve the efficiency of memory allocation, when the application program process is initialized, the memory pool corresponding to the application program is created. And calling the driving program by the application program process according to the preset memory pool capacity.
The preset memory pool capacity may be set by the user in the execution body of the application, or may be generated by the application program process. The preset memory allocation capacity may also be 400 bytes, 700 bytes, or 4000 bytes, and the preset memory pool capacity is not limited in the embodiment of the present application, and may be determined according to an actual situation.
S302: and calling a memory pool creation interface of the user mode memory management program by the driver thread according to the capacity of the memory pool.
In this step, after the application program process calls the driver, since the driver includes the user-mode memory manager, the driver thread calls the memory pool creation interface of the user-mode memory manager according to the preset memory pool capacity.
S303: and controlling the kernel mode memory management program to establish a memory pool by the user mode memory management thread corresponding to the user mode memory management program through a system call interface.
In this step, after the driver thread calls the memory pool creation interface of the user mode memory management program, the program corresponding to the memory pool creation interface is operated, and the user mode memory management thread corresponding to the user mode memory management program calls the system call interface, so that the kernel mode memory management program can be controlled to create the memory pool, and the capacity of the memory pool is the same as the preset memory pool capacity.
According to the memory allocation method in the microkernel operating system, when the application program process is initialized, the application program process creates the memory pool through the kernel-mode memory management program and the memory pool creation interface of the user-mode memory management program in the driver, so that the memory is allocated from the memory pool in the subsequent memory allocation process, and the memory allocation efficiency is effectively improved. In addition, each application program process corresponds to an independent memory pool, and the memory is allocated from the memory pool during memory allocation, so that compared with the prior art that each application program process allocates the memory from the same physical memory, the scheme reduces the coupling of the application program processes, reduces the probability of misusing the memories allocated by other application programs, and improves the safety.
Fig. 4 is a flowchart of a third embodiment of a memory allocation method in a microkernel operating system according to the present application, where on the basis of the foregoing embodiment, the embodiment of the present application describes a situation that a driver thread allocates a memory according to whether an available memory capacity of a memory pool is smaller than a preset memory allocation capacity. As shown in fig. 4, the method for allocating memory in the microkernel operating system specifically includes the following steps:
s401: and calling the driving program by the application program process according to the preset memory allocation capacity.
It should be noted that this step is similar to step S202 in the first embodiment, and is not repeated herein.
S402: the driver thread judges whether the available memory capacity of the memory pool is smaller than the preset memory allocation capacity; if the driver thread determines that the available memory capacity of the memory pool is greater than or equal to the preset memory allocation capacity, executing step S403; if the driver thread determines that the available memory capacity of the memory pool is smaller than the preset memory allocation capacity, step S404 is executed.
S403: and calling a memory allocation interface by the driver thread to allocate the memory from the memory pool.
In this step, after the application program process calls the driver, since a situation that the available memory capacity in the memory pool is smaller than the preset memory allocation capacity and the memory cannot be allocated from the current memory pool may occur, the driver thread is required to determine whether the available memory capacity of the memory pool is smaller than the preset memory allocation capacity.
If the driver thread judges that the available memory capacity of the memory pool is larger than or equal to the preset memory allocation capacity, which indicates that the available memory capacity in the current memory pool can meet the allocation requirement, the driver thread calls a memory allocation interface of the user-mode memory management program to allocate the memory from the memory pool.
S404: the driver thread expands the memory pool through the memory pool creation interface and the kernel mode memory management program.
S405: and calling a memory allocation interface by the driver thread, and allocating the memory from the expanded memory pool.
In the above steps, if the driver thread determines that the available memory capacity of the memory pool is smaller than the preset memory allocation capacity, it indicates that the available memory capacity in the current memory pool cannot meet the allocation requirement, and the driver thread needs to create an interface through the memory pool and perform a kernel-mode memory management program to expand the memory pool. And creating an interface through a memory pool of a user mode memory management program in the driver, calling a system call interface, controlling the kernel mode memory management program to redistribute the memory from the physical memory of the system, and mapping the memory to the address space of the application program to complete the capacity expansion of the memory pool.
And then the driver thread calls a memory allocation interface of the user mode memory management program to allocate the memory from the expanded memory pool.
In the memory allocation method in the microkernel operating system provided in this embodiment, when the available memory capacity of the memory pool is greater than or equal to the preset memory allocation capacity, the memory is directly allocated to the application program process from the memory pool. When the available memory capacity of the memory pool is smaller than the preset memory allocation capacity, the memory pool is expanded, and then the memory is allocated for the application program process from the expanded memory pool, so that the application program process can be allocated to the memory.
Fig. 5 is a flowchart illustrating a fourth embodiment of a memory allocation method in a microkernel operating system according to the present application, where, based on the foregoing embodiments, when the unavailable memory capacity of the memory pool is zero, the memory pool is released, and after the memory pool is released, when a memory needs to be allocated to an application process, the memory pool is created again. As shown in fig. 5, the method for allocating memory in the microkernel operating system specifically includes the following steps:
s501: and when the driver thread monitors that the unavailable memory capacity of the memory pool is zero, releasing the memory pool.
In this step, in the running process of the driver thread, the driver thread may also monitor the unavailable capacity of the memory pool corresponding to the application program process, and if the driver thread monitors that the unavailable memory capacity of the memory pool is zero, in order to ensure that the memory pools corresponding to other application program processes can be created, the memory pools corresponding to the application program processes need to be released.
S502: when the application program process calls the driver program, if the memory pool is released, the driver program thread creates an interface and a kernel mode memory management program through the memory pool to create the memory pool.
In this step, after the driver thread releases the memory pool, in order to ensure that the memory can be allocated when the application program process needs to be allocated, when the application program process calls the driver, if the memory pool is released, the driver thread creates an interface through the memory pool, and creates the memory pool through the kernel-mode memory management program. Subsequent driver threads may allocate memory from the re-created memory pool according to the memory allocation interface of the user-mode memory manager.
In the memory allocation method in the microkernel operating system provided in this embodiment, the memory pool is released by setting the unavailable memory capacity in the memory pool to zero, so that it is ensured that the memory pool corresponding to the other application program process can be created. When the application program process calls the driver program, if the memory pool is released, the memory pool is created again, the application program process can be distributed to the memory, and the normal operation of the application program process is ensured.
The following are embodiments of the apparatus of the present application that may be used to perform embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method of the present application.
Fig. 6 is a schematic structural diagram of an embodiment of a memory allocation apparatus in a microkernel operating system according to the present application. As shown in fig. 6, the memory allocation apparatus 60 in the microkernel operating system includes:
the creating module 61 is configured to create a memory pool by the application program process through a memory pool creating interface of a kernel-mode memory management program and a user-mode memory management program in a driver when the application program process corresponding to the application program is initialized;
the communication module 62 is configured to invoke the driver according to a preset memory allocation capacity through the application program process;
and the allocating module 63 is configured to allocate the memory from the memory pool through a driver thread corresponding to the driver according to the preset memory allocation capacity and the memory allocation interface of the user-mode memory management program.
Further, the creating module 61 is specifically configured to:
when the application program process is initialized, the communication module 62 enables the application program process to call the driver program according to the preset memory pool capacity;
calling a memory pool creation interface of the user-mode memory management program by a driver thread corresponding to the driver according to the preset memory pool capacity;
and the user mode memory management thread corresponding to the user mode memory management program controls the kernel mode memory management program to create the memory pool through a system call interface.
Further, the allocating module 63 is specifically configured to:
and if the driver thread judges that the available memory capacity of the memory pool is greater than or equal to the preset memory allocation capacity, the driver thread calls the memory allocation interface to allocate the memory from the memory pool.
Further, the allocating module 63 is specifically configured to:
if the driver thread judges that the available memory capacity of the memory pool is smaller than the preset memory allocation capacity, the driver thread expands the memory pool through the memory pool creation interface and the kernel mode memory management program;
and the driver thread calls the memory allocation interface to allocate the memory from the expanded memory pool.
A releasing module 64, configured to release the memory pool when the driver thread monitors that the unavailable memory capacity of the memory pool is zero.
Further, the creating module 61 is specifically configured to:
and when the application program process calls the driver program, if the memory pool is released, the driver program thread creates the memory pool through the memory pool creation interface and the kernel mode memory management program.
The memory allocation apparatus in the microkernel operating system provided in this embodiment is configured to execute the technical solution in any one of the method embodiments, and the implementation principle and the technical effect are similar, and are not described herein again.
Fig. 7 is a schematic structural diagram of an electronic device provided in the present application. As shown in fig. 7, the electronic apparatus 70 includes:
a processor 71, a memory 72, and a communication interface 73;
the memory 72 is used for storing executable instructions of the processor 71;
wherein the processor 71 is configured to perform the technical solution of any of the preceding method embodiments via executing the executable instructions.
Alternatively, the memory 72 may be separate or integrated with the processor 71.
Optionally, when the memory 72 is a device independent from the processor 71, the electronic device 70 may further include:
the bus 74, the memory 72 and the communication interface 73 are connected with the processor 71 through the bus 74 and communicate with each other, and the communication interface 73 is used for communicating with other devices.
Alternatively, the communication interface 73 may be implemented by a transceiver. The communication interface is used for realizing communication between the database access device and other equipment (such as a client, a read-write library and a read-only library). The memory may comprise Random Access Memory (RAM) and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The bus 74 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The processor may be a general-purpose processor, including a central processing unit CPU, a Network Processor (NP), and the like; but also a digital signal processor DSP, an application specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic device, discrete gate or transistor logic, discrete hardware components.
The server is configured to execute the technical solution in any of the foregoing method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
The embodiment of the present application further provides a readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the technical solutions provided by any of the foregoing method embodiments.
The embodiment of the present application further provides a computer program product, which includes a computer program, and the computer program is used for implementing the technical solution provided by any of the foregoing method embodiments when being executed by a processor.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.
Claims (10)
1. A memory allocation method in a microkernel operating system is applied to an electronic device provided with the microkernel operating system, wherein the microkernel operating system comprises an application program, a driver program, a user mode memory management program and a kernel mode memory management program, and the method comprises the following steps:
when an application program process corresponding to an application program is initialized, the application program process creates a memory pool through the kernel-mode memory management program and a memory pool creation interface of the user-mode memory management program in the driver;
the application program process calls the driving program according to preset memory allocation capacity;
and the driver thread corresponding to the driver allocates the memory from the memory pool according to the preset memory allocation capacity and the memory allocation interface of the user mode memory management program.
2. The method according to claim 1, wherein when an application program process corresponding to an application program is initialized, the application program process creates a memory pool through a memory pool creation interface of the kernel-mode memory management program and the user-mode memory management program in the driver, and the creating the memory pool includes:
when the application program process is initialized, the application program process calls the driver program according to the capacity of a preset memory pool;
calling a memory pool creation interface of the user-mode memory management program by a driver thread corresponding to the driver according to the preset memory pool capacity;
and controlling the kernel-mode memory management program to create the memory pool by a user-mode memory management thread corresponding to the user-mode memory management program through a system call interface.
3. The method according to claim 1, wherein allocating memory from the memory pool by a driver thread corresponding to the driver according to the preset memory allocation capacity and a memory allocation interface of the user-mode memory management program comprises:
and if the driver thread judges that the available memory capacity of the memory pool is greater than or equal to the preset memory allocation capacity, the driver thread calls the memory allocation interface to allocate the memory from the memory pool.
4. The method according to claim 1, wherein allocating memory from the memory pool by a driver thread corresponding to the driver according to the preset memory allocation capacity and a memory allocation interface of the user-mode memory management program comprises:
if the driver thread judges that the available memory capacity of the memory pool is smaller than the preset memory allocation capacity, the driver thread expands the memory pool through the memory pool creation interface and the kernel mode memory management program;
and calling the memory allocation interface by the driver thread, and allocating the memory from the expanded memory pool.
5. The method according to any one of claims 1 to 4, further comprising:
and when the driver thread monitors that the unavailable memory capacity of the memory pool is zero, releasing the memory pool.
6. The method of claim 5, further comprising:
and when the application program process calls the driver program, if the memory pool is released, the driver program thread creates the memory pool through the memory pool creation interface and the kernel mode memory management program.
7. An apparatus for allocating memory in a microkernel operating system, comprising:
the device comprises a creating module, a memory pool creating module and a memory pool creating module, wherein the creating module is used for creating a memory pool through a kernel mode memory management program and a memory pool creating interface of a user mode memory management program in a driver program by an application program process when the application program process corresponding to the application program is initialized;
the communication module is used for calling the driving program through the application program process according to the preset memory allocation capacity;
and the allocation module is used for allocating the memory from the memory pool through a driver thread corresponding to the driver according to the preset memory allocation capacity and the memory allocation interface of the user-mode memory management program.
8. An electronic device, comprising:
a processor, a memory, a communication interface;
the memory is used for storing executable instructions of the processor;
wherein the processor is configured to perform the method of memory allocation in a microkernel operating system of any of claims 1 to 6 via execution of the executable instructions.
9. A readable storage medium on which a computer program is stored, the computer program, when executed by a processor, implementing the method of memory allocation in a microkernel operating system as claimed in any one of claims 1 to 6.
10. A computer program product comprising a computer program which, when executed by a processor, is operable to carry out the method of memory allocation in a microkernel operating system as claimed in any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211453630.5A CN115756849A (en) | 2022-11-21 | 2022-11-21 | Memory allocation method, device, equipment and medium in microkernel operating system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211453630.5A CN115756849A (en) | 2022-11-21 | 2022-11-21 | Memory allocation method, device, equipment and medium in microkernel operating system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115756849A true CN115756849A (en) | 2023-03-07 |
Family
ID=85333209
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211453630.5A Pending CN115756849A (en) | 2022-11-21 | 2022-11-21 | Memory allocation method, device, equipment and medium in microkernel operating system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115756849A (en) |
-
2022
- 2022-11-21 CN CN202211453630.5A patent/CN115756849A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN100541600C (en) | The dynamic multiple display configuration | |
KR101401523B1 (en) | A coarse-grained sharing gpu scheduling method and apparatus among virtual machines | |
US6985976B1 (en) | System, method, and computer program product for memory management for defining class lists and node lists for allocation and deallocation of memory blocks | |
US7962926B2 (en) | Method, system, and program storage device for generating a retry message when a thread in a real-time application is unavailable to process a request to utilize the real-time application | |
US9063805B2 (en) | Method and system for enabling access to functionality provided by resources outside of an operating system environment | |
CN110162397B (en) | Resource allocation method, device and system | |
CN110750336B (en) | OpenStack virtual machine memory hot-expanding method | |
US9176713B2 (en) | Method, apparatus and program storage device that provides a user mode device interface | |
CN111078367A (en) | Request processing method and device, electronic equipment and storage medium | |
CN110069336A (en) | Memory source distribution method, distributor, chip and storage device | |
CN113407247A (en) | Dual-system starting method based on multi-core processor | |
CN115904761B (en) | System on chip, vehicle and video processing unit virtualization method | |
CN111143072A (en) | User mode program memory allocation method, system and related components | |
CN115421787A (en) | Instruction execution method, apparatus, device, system, program product, and medium | |
CN105677481A (en) | Method and system for processing data and electronic equipment | |
KR101532397B1 (en) | Method for managing a memory of a computer system, memory management unit and computer system | |
US9088569B2 (en) | Managing access to a shared resource using client access credentials | |
CN115756849A (en) | Memory allocation method, device, equipment and medium in microkernel operating system | |
CN112162818A (en) | Virtual memory allocation method and device, electronic equipment and storage medium | |
CN116414561A (en) | Resource scheduling method, device, electronic equipment and storage medium | |
CN109634721B (en) | Method and related device for starting communication between virtual machine and host | |
CN117670645A (en) | Method and device for limiting container video memory, electronic equipment and storage medium | |
CN111737013B (en) | Chip resource management method and device, storage medium and system chip | |
CN115964167A (en) | Resource pooling method, apparatus, device, medium, and product for heterogeneous computing platforms | |
CN115629809A (en) | Data processing method and device, electronic equipment and computer readable 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 |