CN115543600A - Memory space management method and memory space management device - Google Patents

Memory space management method and memory space management device Download PDF

Info

Publication number
CN115543600A
CN115543600A CN202110742761.4A CN202110742761A CN115543600A CN 115543600 A CN115543600 A CN 115543600A CN 202110742761 A CN202110742761 A CN 202110742761A CN 115543600 A CN115543600 A CN 115543600A
Authority
CN
China
Prior art keywords
memory
application
file system
file
system instance
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110742761.4A
Other languages
Chinese (zh)
Inventor
薛春
潘日维
梁宇
李志鹏
邱歌
钱璟
易见
李家欣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN202110742761.4A priority Critical patent/CN115543600A/en
Publication of CN115543600A publication Critical patent/CN115543600A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/122File system administration, e.g. details of archiving or snapshots using management policies

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a memory space management method and a memory space management device, which can effectively improve the safety of using a user-mode memory file system while reducing the performance overhead. The method comprises the following steps: when a first process of a first application is started, allocating a first memory for the first application according to an application identifier of the first application, wherein the first memory has the application identifier of the first application, and the application identifier is used for indicating that the first memory is exclusive for the first application; mapping the first memory to an address space of a first process of the first application, wherein the first memory is initialized to be a first file system instance; when a first process of the first application accesses a first file path, if the first file path is a cache path, the access is directed to the first file system instance.

Description

Memory space management method and memory space management device
Technical Field
The present application relates to the field of terminal storage, and in particular, to a memory space management method and a space management device.
Background
The read-write input/output (I/O) amount of the cache files of a plurality of applications on the terminal equipment occupies more than 80% of the I/O amount of the whole read-write, the sizes of the cache files are small, and the loss of a plurality of cache files cannot affect the operation of the applications, so that the method is very suitable for storing data by using a memory file system. However, the conventional memory file system depends on the implementation of the kernel, and needs to frequently trigger the system call to enter the kernel, which brings great software overhead, so that the memory file system in a user mode can be used to store the cache file, which can effectively avoid the time overhead of the system call, improve the read-write I/O speed of the cache file, and improve the user experience. However, currently, a user-mode file system (FUSE) commercially used in a terminal device is only available, and the file system still needs to enter a kernel mode through system call, which brings performance overhead. Or a Persistent Memory File System (PMFS) may be considered, but the system may not provide good security for the private data of the user due to lack of a protection mechanism suitable for the application environment of the terminal device.
Therefore, a memory space management method is needed to solve the problem that the memory file system lacks a protection mechanism of an application environment and cannot provide good security for private data of a user.
Disclosure of Invention
The application provides a memory space management method and a space management device, which can effectively improve the security of using a user-mode memory file system while reducing the performance overhead.
In a first aspect, a method for managing a memory space is provided, including: when a first process of a first application is started, allocating a first memory for the first application according to an application identifier of the first application, wherein the first memory has the application identifier of the first application, and the application identifier is used for indicating that the first memory is exclusive to the first application; mapping the first memory to an address space of a first process of the first application, wherein the first memory is initialized to be a first file system instance; when the first process of the first application accesses a first file path, if the first file path is a cache path, the access is directed to the first file system instance.
In this embodiment of the present application, the terminal device may allocate different memories to a plurality of applications, respectively, so as to create, read, and write files in the memories corresponding to the applications, where the terminal device may record a plurality of memory addresses, where each memory may correspond to an instance of a file system, that is, the terminal device may respectively construct and obtain a plurality of complete user-mode memory file systems on the memories, so as to implement file management directly in the memories, effectively improve read-write performance, and because each memory corresponds to a unique application ID, the applications are isolated from each other, thereby avoiding mutual snooping between the applications, and further improving security of using the user-mode memory file systems.
With reference to the first aspect, in some implementations of the first aspect, before the allocating the first memory for the first application according to the application identifier of the first application, the method further includes: determining whether to allocate a memory for the first application for the first time; if the memory is allocated for the first application for the first time, setting the size of the first memory as a first value, wherein the first value is a preset value; the allocating a first memory for the first application according to the application identifier of the first application further includes: acquiring authority information of the first application, wherein the authority information is used for expressing the read-write authority of the first application; and setting the read-write permission of the first memory based on the permission information of the first application.
With reference to the first aspect, in certain implementations of the first aspect, the method further includes: if the memory is not allocated to the first application for the first time, determining the number of times of allocating the memory to the first application; setting the size of the first memory to a second value, the second value being determined according to the number of times.
With reference to the first aspect, in certain implementations of the first aspect, the second value is a product of the number of times and the first value.
With reference to the first aspect, in certain implementations of the first aspect, the method further includes: when a second process of the first application is started, if a first memory corresponding to an application identifier of the first application is already allocated, mapping the first memory to an address space of the second process; when the second process accesses a second file path, if the second file path is a cache path, directing the access to the first file system instance.
With reference to the first aspect, in certain implementations of the first aspect, the method further includes: and under the condition that the first memory is insufficient, allocating a second memory to the first application, wherein the size of the second memory is larger than that of the first memory.
With reference to the first aspect, in some implementation manners of the first aspect, the allocating a second memory for the first application further includes: copying the data in the first memory to the second memory; and recovering the first memory.
With reference to the first aspect, in certain implementations of the first aspect, the accessing includes at least one of creating, reading, or writing a file.
With reference to the first aspect, in some implementations of the first aspect, before the starting the first process of the first application, the method further includes: creating a daemon process, wherein the daemon process is used for managing at least one file system instance, and the at least one file system instance comprises the first file system instance; starting the daemon process, and acquiring authority information of at least one application through the daemon process, wherein the at least one application comprises the first application; and creating and initializing an address of at least one memory by using the daemon, wherein the at least one memory comprises the first memory.
In a second aspect, an apparatus for managing memory space is provided, including: the device comprises a distribution module and a processing module; the allocation module is configured to, when a first process of a first application is started, allocate a first memory for the first application according to an application identifier of the first application, where the first memory has the application identifier of the first application, and the application identifier is used to indicate that the first memory is exclusive to the first application; a processing module, configured to map the first memory to an address space of a first process of the first application, where the first memory is initialized to a first file system instance; when the first process of the first application accesses a first file path, if the first file path is a cache path, directing the access to the first file system instance.
With reference to the second aspect, in some implementations of the second aspect, the processing module is configured to: determining whether to allocate a memory for the first application for the first time; if the memory is allocated for the first application for the first time, setting the size of the first memory as a first numerical value, wherein the first numerical value is a preset value; acquiring authority information of the first application, wherein the authority information is used for expressing the read-write authority of the first application; and setting the read-write permission of the first memory based on the permission information of the first application.
With reference to the second aspect, in some implementations of the second aspect, the processing module is configured to: if the memory is not allocated for the first application for the first time, determining the number of times of allocating the memory for the first application; setting the size of the first memory to a second value, the second value being determined according to the number of times.
With reference to the second aspect, in some implementations of the second aspect, the second numerical value is a product of the number of times and the first numerical value.
With reference to the second aspect, in some implementations of the second aspect, the processing module is configured to: when a second process of the first application is started, if a first memory corresponding to an application identifier of the first application is already allocated, mapping the first memory to an address space of the second process; when the second process accesses a second file path, if the second file path is a cache path, the access is directed to the first file system instance.
With reference to the second aspect, in some implementations of the second aspect, the allocating module is configured to: and under the condition that the first memory is insufficient, allocating a second memory to the first application, wherein the size of the second memory is larger than that of the first memory.
With reference to the second aspect, in some implementations of the second aspect, the processing module is configured to: copying the data in the first memory to the second memory; and recovering the first memory.
With reference to the second aspect, in some implementations of the second aspect, the accessing includes at least one of creating, reading, or writing a file.
With reference to the second aspect, in some implementations of the second aspect, the processing module is configured to: creating a daemon process, wherein the daemon process is used for managing at least one file system example, and the at least one file system example comprises the first file system example; starting the daemon process, and acquiring authority information of at least one application through the daemon process, wherein the at least one application comprises the first application; and creating and initializing an address of at least one memory by using the daemon, wherein the at least one memory comprises the first memory.
In a third aspect, there is provided another memory space management apparatus, including a processor, coupled to a storage, and configured to execute instructions in the storage to implement the method in any one of the possible implementation manners of the first aspect. Optionally, the apparatus further comprises a memory. Optionally, the apparatus further comprises a communication interface, the processor being coupled to the communication interface.
In a fourth aspect, a processor is provided, comprising: input circuit, output circuit and processing circuit. The processing circuit is configured to receive a signal via the input circuit and transmit a signal via the output circuit, such that the processor performs the method of any one of the possible implementations of the first aspect.
In a specific implementation process, the processor may be a chip, the input circuit may be an input pin, the output circuit may be an output pin, and the processing circuit may be a transistor, a gate circuit, a flip-flop, various logic circuits, and the like. The input signal received by the input circuit may be received and input by, for example and without limitation, a receiver, the signal output by the output circuit may be output to and transmitted by a transmitter, for example and without limitation, and the input circuit and the output circuit may be the same circuit that functions as the input circuit and the output circuit, respectively, at different times. The embodiment of the present application does not limit the specific implementation manner of the processor and various circuits.
In a fifth aspect, a processing apparatus is provided that includes a processor and a memory. The processor is configured to read instructions stored in the memory, and may receive a signal via the receiver and transmit a signal via the transmitter to perform the method of any one of the possible implementations of the first aspect.
Optionally, there are one or more processors and one or more memories.
Alternatively, the memory may be integrated with the processor, or provided separately from the processor.
In a specific implementation process, the memory may be a non-transient memory, such as a Read Only Memory (ROM), which may be integrated on the same chip as the processor, or may be separately disposed on different chips.
The processing means in the above fifth aspect may be a chip, the processor may be implemented by hardware or may be implemented by software, and when implemented by hardware, the processor may be a logic circuit, an integrated circuit, or the like; when implemented in software, the processor may be a general-purpose processor implemented by reading software code stored in a memory, which may be integrated with the processor, located external to the processor, or stand-alone.
In a sixth aspect, there is provided a computer program product comprising: computer program (also called code, or instructions), which when executed, causes a computer to perform the method of any of the possible implementations of the first aspect described above.
In a seventh aspect, a computer-readable storage medium is provided, which stores a computer program (which may also be referred to as code or instructions) that, when executed on a computer, causes the computer to perform the method in any one of the above-mentioned possible implementation manners of the first aspect.
Drawings
Fig. 1 is a schematic system architecture diagram of a terminal device according to an embodiment of the present application;
fig. 2 is a schematic diagram of another terminal device provided in the embodiment of the present application;
fig. 3 is a schematic flowchart of a memory space management method according to an embodiment of the present application;
fig. 4 is a schematic block diagram of another terminal device provided in the present embodiment;
fig. 5 is a schematic diagram of a user-mode memory file system structure according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a node table provided in an embodiment of the present application;
FIG. 7 is a schematic diagram of a spatial pool provided by an embodiment of the present application;
fig. 8 is a schematic diagram illustrating a comparison between performance of a user-mode memory file system and performance of an existing memory file system according to an embodiment of the present application;
fig. 9 is a schematic block diagram of a memory space management apparatus according to an embodiment of the present application;
fig. 10 is a schematic block diagram of another memory space management apparatus according to an embodiment of the present application.
Detailed Description
The technical solution in the present application will be described below with reference to the accompanying drawings.
Before describing the method and apparatus provided by the embodiments of the present application, the following description is made.
First, in the embodiments shown below, terms and english abbreviations such as reference data or differential data are exemplary examples given for convenience of description, and should not limit the present application in any way. This application does not exclude the possibility of defining other terms in existing or future protocols that may fulfil the same or similar functions.
Second, the first, second and various numerical numbering in the embodiments shown below are merely for convenience of description and are not intended to limit the scope of the embodiments of the present application.
Third, "at least one" means one or more, "a plurality" means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone, wherein A and B can be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of the singular or plural items. For example, at least one (one) of a, b, and c, may represent: a, or b, or c, or a and b, or a and c, or b and c, or a, b and c, wherein a, b and c can be single or multiple.
The application is applicable to a storage device capable of performing read-write operation, such as a mobile phone (mobile phone), a tablet computer, a notebook computer, a palm computer, a Mobile Internet Device (MID), a wearable device, a Virtual Reality (VR) device, an Augmented Reality (AR) device, a wireless terminal in industrial control (industrial control), a wireless terminal in self driving (self driving), a wireless terminal in remote surgery (remote medical supply), a wireless terminal in smart grid (smart grid), a wireless terminal in transportation safety (transportation safety), a wireless terminal in smart city (smart city), a wireless terminal in smart home (smart home), a Personal Digital Assistant (PDA), and the like, and the application is not limited to the embodiments.
In order to make the purpose and technical solutions of the present application clearer and more intuitive, the method and apparatus provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of and not restrictive on the broad application.
Exemplarily, fig. 1 is a schematic diagram of a system architecture of a terminal device according to an embodiment of the present application.
As shown in fig. 1, the terminal device includes a processor 110, a transceiver 120, and a display unit 170. The display unit 170 may include a display screen, among others.
Optionally, the terminal device may further include a memory 130. The processor 110, the transceiver 120, and the memory 130 may communicate with each other via internal connection paths to transfer control and/or data signals, the memory 130 may be used to store a computer program, and the processor 110 may be used to call and run the computer program from the memory 130.
Optionally, the terminal device may further include an antenna 140 for transmitting the wireless signal output from the transceiver 120.
The processor 110 and the memory 130 may be combined into a processing device, and more generally, are independent components, and the processor 110 is configured to execute the program codes stored in the memory 130 to realize the functions. In particular implementations, the memory 130 may be integrated into the processor 110 or may be separate from the processor 110.
In addition, in order to make the functions of the terminal device more complete, the terminal device may further include one or more of the input unit 160, the audio circuit 180, the camera 190, the sensor 101, and the like, and the audio circuit may further include a speaker 182, a microphone 184, and the like.
Optionally, the terminal device may further include a power supply 150 for supplying power to various devices or circuits in the terminal device.
It is understood that the operations and/or functions of the respective modules in the terminal device shown in fig. 1 are respectively for implementing the corresponding flows in the following method embodiments. Specifically, reference may be made to the description of the method embodiments described below, and a detailed description is appropriately omitted herein to avoid redundancy.
It will be appreciated that the processor 110 in the terminal device shown in fig. 1 may include one or more processing units, such as: the processor 110 may include an Application Processor (AP), a modem processor, a Graphics Processing Unit (GPU), an Image Signal Processor (ISP), a controller, a video codec, a Digital Signal Processor (DSP), a baseband processor, and/or a neural-Network Processing Unit (NPU), etc. The different processing units may be separate devices or may be integrated into one or more processors.
A memory may also be provided in processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that have just been used or recycled by the processor 110. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory. Avoiding repeated accesses reduces the latency of the processor 110, thereby increasing the efficiency of the system.
In some embodiments, processor 110 may include one or more interfaces. The interface may include an integrated circuit (I2C) interface, an integrated circuit built-in audio (I2S) interface, a Pulse Code Modulation (PCM) interface, a universal asynchronous receiver/transmitter (UART) interface, a mobile industry processor interface (mobile industry processor interface, MIPI), a general-purpose-input/output (GPIO) interface, a Subscriber Identity Module (SIM) interface, and/or a Universal Serial Bus (USB) interface, etc.
The I2C interface is a bidirectional synchronous serial bus including a serial data line (SDA) and a Serial Clock Line (SCL). In some embodiments, processor 110 may include multiple sets of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 190, etc. through different I2C bus interfaces, respectively. For example: the processor 110 may be coupled to the touch sensor 180K through an I2C interface, so that the processor 110 and the touch sensor 180K communicate through an I2C bus interface, thereby implementing a touch function of the terminal device.
The I2S interface may be used for audio communication. In some embodiments, processor 110 may include multiple sets of I2S buses. The processor 110 may be coupled to the audio circuit 180 via an I2S bus, enabling communication between the processor 110 and the audio circuit 180. In some embodiments, the audio circuit 180 may transmit the audio signal to the transceiver 120 through the I2S interface, so as to implement a function of answering a voice call through a bluetooth headset.
The PCM interface may also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, audio circuitry 180 and transceiver 120 may be coupled by a PCM bus interface. In some embodiments, the audio circuit 180 may also transmit the audio signal to the transceiver 120 through the PCM interface, so as to implement the function of answering a voice call through a bluetooth headset. Both the I2S interface and the PCM interface may be used for audio communication.
The UART interface is a universal serial data bus used for asynchronous communications. The bus may be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, a UART interface is typically used to connect the processor 110 and the transceiver 120. For example: the processor 110 communicates with the bluetooth module in the transceiver 120 through the UART interface to implement the bluetooth function. In some embodiments, the audio circuit 180 may transmit the audio signal to the transceiver 120 through the UART interface, so as to realize the function of playing music through the bluetooth headset.
The MIPI interface may be used to connect the processor 110 with peripheral devices such as the display unit 170, the camera 190, and the like. The MIPI interface includes a Camera Serial Interface (CSI), a Display Serial Interface (DSI), and the like. In some embodiments, processor 110 and camera 190 communicate via a CSI interface to implement the capture function of the terminal device. The processor 110 and the display unit 170 communicate through a DSI interface to implement a display function of the terminal device.
The GPIO interface may be configured by software. The GPIO interface may be configured as a control signal and may also be configured as a data signal. In some embodiments, a GPIO interface may be used to connect the processor 110 with the camera 190, the display unit 170, the transceiver 120, the audio mode circuit 180, the sensor 101, and the like. The GPIO interface may also be configured as an I2C interface, I2S interface, UART interface, MIPI interface, and the like.
It should be understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is only an exemplary illustration, and does not form a limitation on the structure of the terminal device. In other embodiments of the present application, the terminal device may also adopt different interface connection manners or a combination of multiple interface connection manners in the foregoing embodiments.
It will be appreciated that the power supply 150 shown in fig. 1 is used to power the processor 110, memory 130, display unit 170, camera 190, input unit 160, transceiver 120, and the like.
The antenna 140 is used to transmit and receive electromagnetic wave signals. Each antenna in a terminal device may be used to cover a single or multiple communication bands. Different antennas can also be multiplexed to improve the utilization of the antennas. For example: the antenna 140 may be multiplexed as a diversity antenna for a wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
The transceiver 120 may provide solutions for wireless communication applied to the terminal device, including Wireless Local Area Networks (WLANs) (e.g., wireless fidelity (Wi-Fi) networks), bluetooth (BT), global Navigation Satellite System (GNSS), frequency Modulation (FM), near Field Communication (NFC), infrared (IR), and the like. The transceiver 120 may be one or more devices that integrate at least one communication processing module. The transceiver 120 receives electromagnetic waves via the antenna 140, performs frequency modulation and filtering processing on electromagnetic wave signals, and transmits the processed signals to the processor 110. Transceiver 120 may also receive signals to be transmitted from processor 110, frequency modulate them, amplify them, and convert them to electromagnetic radiation via antenna 140.
In some embodiments, the antenna 140 and the transceiver 120 of the end device are coupled such that the end device can communicate with the network and other devices via wireless communication techniques. The wireless communication technology may include global system for mobile communications (GSM), general Packet Radio Service (GPRS), code division multiple access (code division multiple access, CDMA), wideband Code Division Multiple Access (WCDMA), time-division code division multiple access (time-division code division multiple access, TD-SCDMA), long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and/or IR technologies, etc. The GNSS may include a Global Positioning System (GPS), a global navigation satellite system (GLONASS), a beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS), and/or a Satellite Based Augmentation System (SBAS).
The terminal device implements a display function through the GPU, the display unit 170, and the application processor, etc. The GPU is a microprocessor for image processing, and is connected to the display unit 170 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
The display unit 170 is used to display images, videos, and the like. The display unit 170 includes a display panel. The display panel may be a Liquid Crystal Display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (active-matrix organic light-emitting diode, AMOLED), a flexible light-emitting diode (FLED), a miniature, a Micro-oeld, a quantum dot light-emitting diode (QLED), or the like. In some embodiments, the terminal device may include 1 or N display units 170, N being a positive integer greater than 1.
The terminal device may implement a photographing function through the ISP, the camera 190, the video codec, the GPU, the display unit 170, the application processor, and the like.
The ISP is used to process the data fed back by the camera 190. For example, when a video is recorded, the camera is turned on, light is transmitted to the camera photosensitive element through the lens, an optical signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converting into an image visible to naked eyes. The ISP can also carry out algorithm optimization on noise, brightness and skin color of the image. The ISP can also optimize parameters such as exposure, color temperature and the like of a shooting scene. In some embodiments, the ISP may be provided in camera 190.
The camera 190 is used to capture still images or video. The object generates an optical image through the lens and projects the optical image to the photosensitive element. The photosensitive element may be a Charge Coupled Device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The light sensing element converts the optical signal into an electrical signal, which is then passed to the ISP where it is converted into a digital image signal. And the ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV and other formats. In some embodiments, the terminal device may include 1 or N cameras 190, N being a positive integer greater than 1.
The digital signal processor is used for processing digital signals, and can process other digital signals besides digital image signals. For example, when the terminal device selects a frequency point, the digital signal processor is used for performing fourier transform or the like on the frequency point energy.
Video codecs are used to compress or decompress digital video. The terminal device may support one or more video codecs. Thus, the terminal device can play or record videos in various encoding formats, such as: moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, and the like.
The NPU is a neural-network (NN) computing processor that processes input information quickly by using a biological neural network structure, for example, by using a transfer mode between neurons of a human brain, and can also learn by itself continuously. The NPU can realize applications such as intelligent cognition of the terminal equipment, for example: image recognition, face recognition, speech recognition, text understanding, and the like.
Memory 130 may be used to store computer-executable program code, which includes instructions. The memory 130 may include a program storage area and a data storage area. The storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required by at least one function, and the like. The storage data area can store data (such as audio data, phone book and the like) created in the use process of the terminal equipment. Further, the memory 130 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (UFS), and the like. The processor 110 executes various functional applications of the terminal device and data processing by executing instructions stored in the memory 130 and/or instructions stored in a memory provided in the processor.
The terminal device may implement audio functions via audio circuitry 180, speaker 182, microphone 184, and an application processor, among other things. Such as music playing, recording, etc.
The audio circuit 180 is used to convert digital audio information into an analog audio signal output and also to convert an analog audio input into a digital audio signal. The audio circuit 180 may also be used to encode and decode audio signals. In some embodiments, the audio circuit 180 may be disposed in the processor 110, or some functional blocks of the audio circuit 180 may be disposed in the processor 110.
The speaker 182, also called a "horn", is used to convert electrical audio signals into sound signals. The terminal device can listen to music through the speaker 182, or listen to a handsfree call.
The microphone 184, also referred to as a "microphone", converts sound signals into electrical signals. When making a call or sending voice information, the user may input a voice signal into the microphone 184 by speaking near the microphone 184. The terminal device may be provided with at least one microphone 184. In other embodiments, the terminal device may be provided with two microphones 184, so as to implement a noise reduction function in addition to collecting sound signals. In other embodiments, the terminal device may further include three, four or more microphones 184 to collect a sound signal, reduce noise, identify a sound source, and implement a directional recording function.
1. File system
The software mechanism in the operating system that is responsible for managing and storing file information is called a file management system, referred to as a file system for short. From a system perspective, a file system is a system that organizes and allocates space of a file storage device, is responsible for file storage, and protects and retrieves stored files. In particular, it is responsible for creating files for the user, storing, reading, modifying, dumping files, controlling access to files, revoking files when the user is no longer in use, etc.
2. Kernel mode)
The operating system program is run, and the hardware is operated, wherein a Central Processing Unit (CPU) can access all data of the memory, including peripheral devices such as a hard disk, a network card, and the like, and the CPU can also switch from one program to another program.
3. User state (user mode)
When the user program is operated, only the memory can be accessed in a limited way, the peripheral equipment is not allowed to be accessed, and the CPU resource can be seized by other high-authority programs.
The read-write quantity of the cache file applied to the terminal device occupies a part of the considerable read-write quantity of the whole terminal device, the size of the cache file applied to the terminal device is small, and the loss of the cache file does not affect the operation of the application, so that the terminal device is very suitable for storing data by using a memory file system. Therefore, the user-mode memory file system can be used for storing the cache file, the time expenditure of system calling can be avoided, the read-write I/O speed of the cache file is obviously improved, and the user experience is improved.
In one implementation, system calls and the traditional Linux I/O stack can be effectively bypassed using the traditional user mode file system, resulting in a higher I/O speed than the traditional memory file system. However, currently, a user-mode file system for terminal equipment only includes FUSE, and the file system includes a kernel module (FUSE) and a user space daemon (daemon), for example, in Linux, access to a file is performed uniformly through a kernel interface provided by a VFS layer, so that when a process (called user) accesses a file system implemented by daemon, access to the VFS is still required, and when the VFS receives an access request of the user process for the file and determines that the file belongs to a certain user-mode file system, the request is handed over to a kernel module named FUSE. Then, the fuse converts the request into a protocol format agreed with the daemon process and transmits the converted request to the daemon process. Therefore, the user-mode file system still needs to enter the kernel mode through system call, which brings performance overhead.
In another implementation, a file system PMFS for persistent memory may be utilized, but the system lacks a protection mechanism suitable for the application environment of the terminal device, and thus cannot provide good security for the private data of the user.
In view of this, according to the memory space management method provided in the embodiment of the present application, addresses of memories may be mapped to address spaces of corresponding applications, each memory corresponds to an instance of a file system, that is, a complete user-mode memory file system may be constructed on one memory, so that reading and writing of a cache file are migrated to the user-mode memory file system, the overall file reading and writing speed is improved, and software overhead caused by system call is reduced.
Fig. 2 is a schematic diagram of a terminal device 200 provided in an embodiment of the present application. As shown in fig. 2, the terminal apparatus 200 has disposed therein: the file system instance refers to that a complete file system can be constructed on one internal memory so that the application can carry out read-write operation in the corresponding internal memory. For example, the application 1 may perform read and write operations in the memory 1, and other applications are similar, which are not described herein again to avoid repetition.
It should be understood that the terminal device provided in the embodiment of the present application may be installed with different operating systems, such as an android operating system (android operating system), an independent operating system (ISO), and the like, which is not limited in this application.
Fig. 3 is a schematic flow chart of a memory space management method 300 according to an embodiment of the present application. The method 300 may be applied to the terminal device 200 shown in fig. 2, and may also be applied to other devices, which is not limited in this embodiment. As shown in fig. 3, the method 300 includes the following steps:
s301, when a first process of a first application is started, a first memory is allocated to the first application according to the application identifier of the first application.
It should be understood that the first memory has an application identifier of the first application, and the application identifier is used for indicating that the first memory is exclusive to the first application.
S302, map the first memory to an address space of a first process of the first application, where the first memory is initialized to a first file system instance.
S303, when the first process of the first application accesses the first file path, if the first file path is a cache path, directing the access to the first file system instance.
In the same way, when starting the first process of the second application, the terminal device may also allocate a third memory to the second application according to the application identifier of the second application, map the third memory to the address space of the second process of the second application, initialize the third memory to the second file system instance, and when the first process of the second application accesses the third file path, if the terminal device determines that the third file path is the cache path, direct the access to the second file system instance.
It should be understood that, the third memory is different from the first memory, and the third memory has an application identifier of the second application, where the application identifier is used to indicate that the third memory is exclusive to the second application.
Optionally, the terminal device may allocate a public memory to the application in addition to allocating the first memory and the second memory to the first application and the second application, respectively.
It should be understood that the public memory may be configured to store a plurality of files, where the plurality of files are respectively used to record the application identifiers and the read-write permission information of the first application, the second application, and the other plurality of applications, that is, the public memory is a memory shared by the first application, the second application, and the other plurality of applications.
In this embodiment of the present application, the terminal device may allocate different memories to a plurality of applications, respectively, so as to create, read, and write files in the memories corresponding to the applications, where the terminal device may record a plurality of memory addresses, where each memory may correspond to an instance of a file system, that is, the terminal device may respectively construct and obtain a plurality of complete user-mode memory file systems on the memories, so as to implement file management directly in the memories, effectively improve read-write performance, and because each memory corresponds to a unique application ID, the applications are isolated from each other, thereby avoiding mutual snooping between the applications, and further improving security of using the user-mode memory file systems.
As an optional embodiment, before allocating the first memory to the first application, the terminal device may further obtain the permission information of the first application, and set the read-write permission of the first memory based on the permission information of the first application.
It should be understood that the above-mentioned authority information is used to represent read and write authority information of the first application.
For example, if the first application can only perform a read operation on the first memory, the terminal device may set the read-write permission of the first memory to be read only, and in addition, the read-write and write-only situations are similar to the above embodiments, and are not described herein again to avoid repetition.
Optionally, before allocating the first memory to the first application, the terminal device may further determine whether to allocate the memory to the first application for the first time, and further determine the size of the memory allocated to the target application.
In a first situation, the terminal device determines to allocate a memory for the first application for the first time, and may set the size of the first memory to a first value when the memory space is sufficient, where the first value is a preset value.
Optionally, in a first situation, the terminal device may further allocate, according to the size of the memory actually required by the first application, a first memory with a first value to the first application under the condition that the memory space is sufficient, where the first value may be the same as the value of the memory actually required by the first application, that is, allocate a private memory according to the memory requirement of the first application, and may effectively save the memory space on the premise of meeting the use requirement of the first application.
In a second case, if the terminal device determines that the memory is not allocated for the first application for the first time, the terminal device may determine the number of times the memory is allocated for the first application, and may set the size of the first memory to a second value when the memory space is sufficient, where the second value may be determined according to the number of times, and the second value may be a product of the number of times and the first value.
Optionally, in a second case, the terminal device may further set the size of the first memory to a second value when it is determined that the number of times of allocating the memory to the first application is greater than or equal to a preset number of times.
It should be understood that, if the terminal device does not allocate the memory for the first application for the first time, or the number of times of allocating the memory for the target application is greater than or equal to the preset number of times, it may be considered that the probability that the first application needs a larger private memory is higher, so that the terminal device may increase the size of the memory allocated for the target application according to the increase of the allocation number of times of the memory when the memory space is sufficient, so as to improve the efficiency of allocating the memory for the first application.
As an optional embodiment, when the second process of the first application is started, if the first memory corresponding to the application identifier of the first application is already allocated, the terminal device may map the first memory to an address space of the second process; and when the second process accesses the second file path, if the second file path is a cache path, the terminal device may direct the access to the first file system instance.
It should be understood that other processes of the first application may reuse the first memory of the first process of the first application, that is, physical addresses of the same memory may be mapped to address spaces of different processes of the same application, where the address spaces are virtual addresses, so that, to ensure that the processes of the first application are used, the terminal device may destroy the first memory after all processes of the first application are destroyed.
Optionally, the terminal device may also allocate a second memory to the first application when the first memory is insufficient, map an address of the second memory to an address space of a first process and/or an address space of a second process of the first application, copy data in the first memory to the second memory, and recycle the first memory, so that the first application performs a read-write operation on the cache file in the second memory, where an identifier of the second memory is the same as an identifier of the first memory.
It should be understood that the above access includes at least one of creation, reading, or writing to a file.
It should be understood that, besides the memory allocation on demand and the memory allocation according to the allocation times provided in the foregoing embodiments, other memory allocation policies may also be used, which is not limited in this application.
Before allocating the memory for the target application, the terminal device may further create a daemon process, where the daemon process is configured to manage the file system instance, start the daemon process, and obtain permission information of at least one application through the daemon process, where the at least one application includes the first application and the second application, and creates and initializes an address of at least one memory by using the daemon process, and the at least one memory includes the first memory, the second memory, and a third memory.
Illustratively, the daemon process may be UCProc, the terminal device may create the UCProc process in the init process when android starts by modifying codes of An Open Source Project (AOSP) of an android source code, and obtain read-write permission conditions of each application through a data/system/packages.
The method 300 is described in detail below with reference to a terminal device by taking an android system as an example.
Fig. 4 is a schematic block diagram of another terminal device provided in this embodiment, and as shown in fig. 4, the terminal device has three parts, and in the first part, a plurality of application processes are shown, such as a process of application 1, a process of application 2, \ 8230;, a process of application N, and a structure of a file system constructed by file system instance 1, including a superblock, a node table, and a space pool, are shown.
The second part shows the daemon UCProc, which can record multiple memory addresses and multiple file system instances, file system instance 1 and file system instance 2, \\ 8230, and file system instance N, through the space manager, as shown in fig. 4.
The third part shows a plurality of memories corresponding to the plurality of memory addresses, memory 1, memory 2, \ 8230;, and memory N, where each memory corresponds to a file system instance, as shown in fig. 4, where memory 1 corresponds to file system instance 1, memory 2 corresponds to file system instance 2, and memory N corresponds to file system instance N, the file system instance may construct a complete file system on the corresponding memory, and the structure of the file system is shown in the first part.
Corresponding to the above S201, when the process of the application 1 is the first process of the first application, and when the process of the application 1 is started, the application 1 may send a request message to an inter-process addressing (IPC) manager through a communication mechanism binder, where the request message is used to apply for the memory, so that the application 1 caches a file, and the IPC manager receives and parses the request message to obtain an identifier of the application 1, read-write permission information, size information of an application private memory, and information about whether the application private memory is initially applied for the private memory, and then notifies the process UCProc, and the process UCProc allocates a memory (i.e., the first memory or the second memory) for the application 1 through an anonymous shared memory (Ashmem) based on the identifier of the application 1 in the request message, the read-write permission information, the size information of the application private memory, and information about whether the application private memory is initially applied for the private memory.
Exemplarily, the process UCProc may transmit authority information of a memory, address information of the memory (i.e., address information of the first memory or address information of the second memory) and address information of the public memory to the IPC Manager, and the IPC Manager may package the authority information of the memory, the address information of the memory and the address information of the public memory, and send the data packet to the process of the application 1 applying for the private memory by using an android binder mechanism, where the IPC Manager may obtain a function of a current Service Manager by using a default Service Manager function, and then the IPC Manager may further obtain related operations of the binder by inheriting an IInterface class, a bpnterface class and a bnnterface class.
It should be understood that the present application may also use communication mechanisms of other processes besides the binder, and the present application is not limited thereto.
Optionally, the terminal device may determine whether to allocate the memory for the application 1 for the first time, and further allocate private memories of different sizes for the application 1.
For example, if the terminal device determines to allocate the memory for the application 1 for the first time, the terminal device may allocate a first private memory with a size of a first value X to the application 1.
If the terminal device determines that the memory is not allocated to the application 1 for the first time, the terminal device may obtain the number N of times that the memory is allocated to the application 1, and allocate, based on the number of times, a second memory having a second numerical value N X to the application 1.
Optionally, in the case of determining to allocate the memory for the first time, the terminal device may also allocate, according to the size of the memory actually requested by the application 1, the memory with the same size for the application 1.
An application 1 may receive a data packet from the process UCProc, unpack the data packet, obtain address information of a memory allocated to the application 1, map an address of the memory into an address space of a process of the current application 1, and initialize the address to obtain a user-mode memory file system corresponding to the memory, fig. 5 illustrates a schematic diagram of a user-mode memory file system structure provided in an embodiment of the present application, that is, a structure of the file system illustrated in the first part of fig. 4, as illustrated in fig. 5, the structure of the file system includes a super block, a node table, a space pool, a data segment, and the like, where the super block is used to record general information of the file system, such as a size of a private memory space corresponding to the application, or a size of a remaining memory space of the private memory, and the like, the node table is used to manage a node, the space pool is used to manage metadata of file data, and the data segment is used to manage a directory entry and conventional file data.
Fig. 6 is a schematic diagram of the node table provided in the embodiment of the present application, and as shown in fig. 6, the node table includes a node table lock and node table information, where the node table information includes a node ID and a node address, where the node ID and the node address are in one-to-one correspondence, such as the node ID 1 Corresponding node 1 Address, node ID 2 Corresponding node 2 Address \8230;, node ID N Corresponding node N An address.
Fig. 7 is a schematic diagram of the space pool provided in the embodiment of the present application, and as shown in fig. 7, the space pool includes a space pool lock and space pool information, where the space pool information includes sub-allocators, and the sub-allocators correspond to valid blocks and bitmaps, such as sub-allocators 1 Distributor for distributing liquid 2 8230code, sub-distributor N Corresponding to the respective valid block and bitmap.
In the embodiment of the present application, the on-demand allocation is used in the cache file space management, which indicates that the user-mode file system needs to have a dynamic expansion characteristic, so as to separate the metadata from the file data as shown in fig. 5, so that the terminal device can copy data in different areas at one time during capacity expansion, thereby reducing the overhead caused by the expansion and reconstruction of the file system.
It should be understood that the structure of the user-mode file system in the memory may also be in other different designs, which is not limited in this application.
Optionally, on the basis of the above steps, if the application 1 has a target file (i.e., a first file) to be cached, the terminal device may determine a path of the target file, and write the target file into the memory allocated to the application 1 when determining that the path is the path of the cache file of the application 1, so as to improve the read-write performance of the cache file.
For example, when the terminal device accesses the target file, the cache path of the target file may be identified first, the location of the path is distinguished, and the name of the corresponding application is identified, and then, when it is determined that the cache path of the target file is the path of the cache file corresponding to the application 1, the terminal device may select the interface of the user-mode memory file system provided by the application, that is, the terminal device may direct the access to the file system instance (i.e., in the first file system instance) in the memory corresponding to the application 1.
Optionally, under the condition that the target file is written into the memory corresponding to the application 1, the terminal device may directly perform a read operation on the target file in the memory corresponding to the application 1, without triggering a kernel, thereby reducing software overhead, improving read-write I/O speed of the target file, and improving user experience.
Exemplarily, if the path saved by the target file is the path of the corresponding cache file of the application 1, the terminal device may receive the file descriptor FD, and may select an interface according to the value of the file descriptor, for example, in case of FD > = UCFS _ FD _ BASE, the terminal device may select an interface of the user-mode memory file system constructed on the private memory provided in the present application, otherwise, perform write management on the target file through a conventional memory file system, such as Ramfs, by using a native C library interface.
Figure BDA0003141871530000131
In the embodiment of the application, due to the use of the user-mode memory file system, the problem that the access speed of the conventional file system based on the flash memory is slower than that of the memory due to media is solved, and the problem that excessive software overhead is caused by frequent system calls of the conventional memory file system based on the kernel is solved. In addition, when the file data is read and written, the corresponding interface can be oriented according to the characteristics of the file, and the reading and writing performance of the file is greatly improved.
It should be understood that, the sequence numbers of the above processes do not imply any order of execution, and the order of execution of the processes should be determined by their functions and inherent logic, and should not limit the implementation process of the embodiments of the present application in any way.
In the embodiments provided in the present application, the method provided in the embodiments of the present application is introduced from the perspective of the terminal device as an execution subject. In order to implement the functions in the methods provided by the embodiments of the present application, the storage may include a hardware structure and/or a software module, and the functions are implemented in the form of a hardware structure, a software module, or a hardware structure and a software module. Whether any of the above-described functions is implemented as a hardware structure, a software module, or a hardware structure plus a software module depends upon the particular application and design constraints imposed on the technical solution.
The space management apparatus for caching files provided in the embodiment of the present application will be described in detail below with reference to fig. 9 and fig. 10.
Fig. 9 shows a memory space management apparatus 900 according to an embodiment of the present application, including: an allocation module 901 and a processing module 902.
Wherein, the allocating module 901 is configured to: when a first process of a first application is started, allocating a first memory for the first application according to an application identifier of the first application, wherein the first memory has the application identifier of the first application, and the application identifier is used for indicating that the first memory is exclusive for the first application; the processing module 902 is configured to: mapping the first memory to an address space of a first process of the first application, wherein the first memory is initialized to be a first file system instance; when the first process of the first application accesses a first file path, if the first file path is a cache path, directing the access to the first file system instance.
Optionally, the processing module 902 is configured to: determining whether to allocate a memory for the first application for the first time; if the memory is allocated for the first application for the first time, setting the size of the first memory as a first value, wherein the first value is a preset value; acquiring authority information of the first application, wherein the authority information is used for expressing the read-write authority of the first application; and setting the read-write permission of the first memory based on the permission information of the first application.
Optionally, the processing module 902 is configured to: if the first application is not allocated with the memory for the first time, determining the number of times of allocating the memory for the first application; setting the size of the first memory to a second value, the second value being determined according to the number of times.
Optionally, the second value is a product of the number and the first value.
Optionally, the processing module 902 is configured to: when a second process of the first application is started, if a first memory corresponding to an application identifier of the first application is already allocated, mapping the first memory to an address space of the second process; when the second process accesses a second file path, if the second file path is a cache path, directing the access to the first file system instance.
Optionally, the allocating module 901 is configured to: and under the condition that the first memory is insufficient, allocating a second memory to the first application, wherein the size of the second memory is larger than that of the first memory.
Optionally, the processing module 902 is configured to: copying the data in the first memory to the second memory; and recovering the first memory.
Optionally, the accessing includes at least one of creating, reading, or writing the file.
Optionally, the processing module 902 is configured to: creating a daemon process, wherein the daemon process is used for managing at least one file system instance, and the at least one file system instance comprises the first file system instance; starting the daemon process, and acquiring authority information of at least one application through the daemon process, wherein the at least one application comprises the first application; and creating and initializing an address of at least one memory by using the daemon, wherein the at least one memory comprises the first memory.
It should be appreciated that the apparatus 900 herein is embodied in the form of functional modules. The term module, as used herein, may refer to an Application Specific Integrated Circuit (ASIC), an electronic circuit, a processor (e.g., a shared, dedicated, or group processor), and memory that execute one or more software or firmware programs, a combinational logic circuit, and/or other suitable components that support the described functionality. In an optional example, it may be understood by those skilled in the art that the apparatus 900 may be specifically a terminal device in the foregoing embodiment, or functions of the terminal device in the foregoing embodiment may be integrated in the apparatus 900, and the apparatus 900 may be configured to execute each procedure and/or step corresponding to the terminal device in the foregoing method embodiment, and details are not described here again to avoid repetition.
The device 900 has the function of implementing the corresponding steps executed by the terminal equipment in the method; the above functions may be implemented by hardware, or may be implemented by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the functions described above.
In an embodiment of the present application, the apparatus 900 in fig. 9 may also be a chip or a chip system, for example: system on chip (SoC).
Fig. 10 illustrates another memory space management apparatus 1000 according to an embodiment of the present application. The apparatus 1000 comprises: a processor 1001, a memory 1002, a communication interface 1003, and a bus 1004. The memory 1002 is used for storing instructions, and the processor 1001 is used for executing the instructions stored in the memory 1002. The processor 1001, the memory 1002, and the communication interface 1003 realize communication connection with each other through a bus 1004.
Wherein the processor 1001 is configured to: when a first process of a first application is started, allocating a first memory for the first application according to an application identifier of the first application, wherein the first memory has the application identifier of the first application, and the application identifier is used for indicating that the first memory is exclusive to the first application; mapping the first memory to an address space of a first process of the first application, wherein the first memory is initialized to be a first file system instance; when the first process of the first application accesses a first file path, if the first file path is a cache path, the access is directed to the first file system instance.
Optionally, the processor 1001 is configured to: determining whether to allocate a memory for the first application for the first time; if the memory is allocated for the first application for the first time, setting the size of the first memory as a first numerical value, wherein the first numerical value is a preset value; acquiring authority information of the first application, wherein the authority information is used for expressing the read-write authority of the first application; and setting the read-write permission of the first memory based on the permission information of the first application.
Optionally, the processor 1001 is configured to: if the memory is not allocated for the first application for the first time, determining the number of times of allocating the memory for the first application; setting the size of the first memory to a second value, the second value being determined according to the number of times.
Optionally, the second value is a product of the number and the first value.
Optionally, the processor 1001 is configured to: when a second process of the first application is started, if a first memory corresponding to an application identifier of the first application is already allocated, mapping the first memory to an address space of the second process; when the second process accesses a second file path, if the second file path is a cache path, directing the access to the first file system instance.
Optionally, the processor 1001 is configured to: and under the condition that the first memory is insufficient, allocating a second memory to the first application, wherein the size of the second memory is larger than that of the first memory.
Optionally, the processor 1001 is configured to: copying the data in the first memory to the second memory; and recovering the first memory.
Optionally, the accessing includes at least one of creating, reading, or writing the file.
Optionally, the processor 1001 is configured to: creating a daemon process, wherein the daemon process is used for managing at least one file system example, and the at least one file system example comprises the first file system example; starting the daemon process, and acquiring authority information of at least one application through the daemon process, wherein the at least one application comprises the first application; and creating and initializing an address of at least one memory by using the daemon, wherein the at least one memory comprises the first memory.
It should be understood that the apparatus 1000 may be embodied as the terminal device in the foregoing embodiment, or the functions of the terminal device in the foregoing embodiment may be integrated in the apparatus 1000, and the apparatus 1000 may be configured to execute each step and/or flow corresponding to the terminal device in the foregoing method embodiment. The memory 1002 may optionally include both read-only memory and random access memory, and provides instructions and data to the processor. The portion of memory may also include non-volatile random access memory. For example, the memory may also store device type information. The processor 1001 may be configured to execute the instructions stored in the memory, and when the processor executes the instructions, the processor may perform the steps and/or processes corresponding to the storage device in the method embodiment described above.
It should be understood that, in the embodiments of the present application, the processor may be a Central Processing Unit (CPU), and the processor may also be other general processors, digital Signal Processors (DSPs), application Specific Integrated Circuits (ASICs), field Programmable Gate Arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or by instructions in the form of software. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in a processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor executes instructions in the memory, in combination with hardware thereof, to perform the steps of the above-described method. To avoid repetition, it is not described in detail here.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a portable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, an optical disk, or other various media capable of storing program codes.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (21)

1. A memory space management method is characterized by comprising the following steps:
when a first process of a first application is started, allocating a first memory for the first application according to an application identifier of the first application, wherein the first memory has the application identifier of the first application, and the application identifier is used for indicating that the first memory is exclusive to the first application;
mapping the first memory to an address space of a first process of the first application, the first memory being initialized to a first file system instance;
when a first process of the first application accesses a first file path, if the first file path is a cache path, the access is directed to the first file system instance.
2. The method of claim 1, wherein before the allocating the first memory for the first application according to the application identifier of the first application, the method further comprises:
determining whether to allocate a memory for the first application for the first time;
if the memory is allocated to the first application for the first time, setting the size of the first memory as a first numerical value, wherein the first numerical value is a preset value;
the allocating a first memory for the first application according to the application identifier of the first application further includes:
acquiring authority information of the first application, wherein the authority information is used for expressing the read-write authority of the first application;
and setting the read-write permission of the first memory based on the permission information of the first application.
3. The method of claim 2, further comprising:
if the first application is not allocated with the memory for the first time, determining the number of times of allocating the memory for the first application;
and setting the size of the first memory as a second numerical value, wherein the second numerical value is determined according to the times.
4. The method of claim 3, wherein the second value is a product of the degree and the first value.
5. The method according to any one of claims 1 to 4, further comprising:
when a second process of the first application is started, if a first memory corresponding to an application identifier of the first application is already allocated, mapping the first memory to an address space of the second process;
and when the second process accesses a second file path, if the second file path is a cache path, directing the access to the first file system instance.
6. The method according to any one of claims 1 to 5, further comprising:
and under the condition that the first memory is insufficient, allocating a second memory to the first application, wherein the size of the second memory is larger than that of the first memory.
7. The method of claim 6, wherein allocating the second memory for the first application further comprises:
copying the data in the first memory to the second memory;
and recovering the first memory.
8. The method of any of claims 1 to 7, wherein the access comprises at least one of creation, reading, or writing to a file.
9. The method according to any of claims 1 to 8, wherein prior to the launching of the first process of the first application, the method further comprises:
creating a daemon process, the daemon process being used for managing at least one file system instance, the at least one file system instance comprising the first file system instance;
starting the daemon process, and acquiring authority information of at least one application through the daemon process, wherein the at least one application comprises the first application;
and creating and initializing an address of at least one memory by using the daemon process, wherein the at least one memory comprises the first memory.
10. A memory space management apparatus, comprising:
the allocation module is configured to allocate a first memory for a first application according to an application identifier of the first application when a first process of the first application is started, where the first memory has the application identifier of the first application, and the application identifier is used to indicate that the first memory is exclusive to the first application;
a processing module, configured to map the first memory to an address space of a first process of the first application, where the first memory is initialized to a first file system instance;
when a first process of the first application accesses a first file path, if the first file path is a cache path, directing the access to the first file system instance.
11. The apparatus of claim 10, wherein the processing module is configured to:
determining whether to allocate a memory for the first application for the first time;
if the memory is allocated to the first application for the first time, setting the size of the first memory as a first numerical value, wherein the first numerical value is a preset value;
acquiring authority information of the first application, wherein the authority information is used for expressing the read-write authority of the first application;
and setting the read-write permission of the first memory based on the permission information of the first application.
12. The apparatus of claim 11, wherein the processing module is configured to:
if the memory is not allocated to the first application for the first time, determining the number of times of allocating the memory to the first application;
and setting the size of the first memory to be a second value, wherein the second value is determined according to the times.
13. The apparatus of claim 12, wherein the second value is a product of the degree and the first value.
14. The apparatus of any one of claims 10 to 13, wherein the processing module is configured to:
when a second process of the first application is started, if a first memory corresponding to an application identifier of the first application is already allocated, mapping the first memory to an address space of the second process;
when the second process accesses a second file path, if the second file path is a cache path, the access is directed to the first file system instance.
15. The apparatus of any one of claims 10 to 14, wherein the assignment module is configured to:
and under the condition that the first memory is insufficient, allocating a second memory to the first application, wherein the size of the second memory is larger than that of the first memory.
16. The apparatus of claim 15, wherein the processing module is configured to:
copying the data in the first memory to the second memory;
and recovering the first memory.
17. The apparatus of any of claims 10 to 16, wherein the access comprises at least one of creation, reading, or writing to a file.
18. The apparatus of any one of claims 10 to 17, wherein the processing module is configured to:
creating a daemon process, the daemon process being used for managing at least one file system instance, the at least one file system instance comprising the first file system instance;
starting the daemon process, and acquiring authority information of at least one application through the daemon process, wherein the at least one application comprises the first application;
and creating and initializing an address of at least one memory by using the daemon process, wherein the at least one memory comprises the first memory.
19. A memory space management apparatus, comprising: a processor coupled with a memory for storing a computer program that, when invoked by the processor, causes the apparatus to perform the method of any of claims 1 to 9.
20. A computer-readable storage medium for storing a computer program comprising instructions for implementing the method of any one of claims 1 to 9.
21. A computer program product comprising computer program code which, when run on a computer, causes the computer to carry out the method according to any one of claims 1 to 9.
CN202110742761.4A 2021-06-30 2021-06-30 Memory space management method and memory space management device Pending CN115543600A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110742761.4A CN115543600A (en) 2021-06-30 2021-06-30 Memory space management method and memory space management device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110742761.4A CN115543600A (en) 2021-06-30 2021-06-30 Memory space management method and memory space management device

Publications (1)

Publication Number Publication Date
CN115543600A true CN115543600A (en) 2022-12-30

Family

ID=84722931

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110742761.4A Pending CN115543600A (en) 2021-06-30 2021-06-30 Memory space management method and memory space management device

Country Status (1)

Country Link
CN (1) CN115543600A (en)

Similar Documents

Publication Publication Date Title
EP4002108B1 (en) Application start method and electronic device
WO2021258809A1 (en) Data synchronization method, electronic device, and computer readable storage medium
CN111371849A (en) Data processing method and electronic equipment
WO2021104259A1 (en) Method and terminal for data sharing between fast application and native application
CN111382087A (en) Memory management method and electronic equipment
CN114461375B (en) Memory resource management method and electronic equipment
CN114461588A (en) Method for adjusting pre-reading window and electronic equipment
CN114726950A (en) Opening method and device of camera module
WO2022166619A1 (en) Qr code recognition method and related apparatus
WO2024021995A1 (en) Memory access method and apparatus
CN115309547B (en) Method and device for processing asynchronous binder call
WO2022042245A1 (en) Method for determining physical address, and chip system
CN117130541A (en) Storage space configuration method and related equipment
CN115729684B (en) Input/output request processing method and electronic equipment
CN114461589B (en) Method for reading compressed file, file system and electronic equipment
CN115543600A (en) Memory space management method and memory space management device
CN113849194A (en) Burning method and terminal equipment
CN113950033B (en) Data transmission method and equipment
CN112783418B (en) Method for storing application program data and mobile terminal
WO2024041219A1 (en) Memory management method, electronic device, chip system, and readable storage medium
CN113760192A (en) Data reading method, data reading apparatus, storage medium, and program product
CN113704209B (en) Data sharing method, electronic device and storage medium
CN116993619B (en) Image processing method and related equipment
WO2024027544A1 (en) Memory management method and electronic device
WO2024032430A1 (en) Memory management method and electronic device

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