CN113485835B - Method, system, equipment and medium for realizing memory sharing under multiple scenes - Google Patents

Method, system, equipment and medium for realizing memory sharing under multiple scenes Download PDF

Info

Publication number
CN113485835B
CN113485835B CN202110797337.XA CN202110797337A CN113485835B CN 113485835 B CN113485835 B CN 113485835B CN 202110797337 A CN202110797337 A CN 202110797337A CN 113485835 B CN113485835 B CN 113485835B
Authority
CN
China
Prior art keywords
memory
target operation
operation scene
amount
occupied
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110797337.XA
Other languages
Chinese (zh)
Other versions
CN113485835A (en
Inventor
胡伟
胡圣
彭学斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Trendit Co ltd
Original Assignee
Shenzhen Trendit 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 Shenzhen Trendit Co ltd filed Critical Shenzhen Trendit Co ltd
Priority to CN202110797337.XA priority Critical patent/CN113485835B/en
Publication of CN113485835A publication Critical patent/CN113485835A/en
Application granted granted Critical
Publication of CN113485835B publication Critical patent/CN113485835B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • 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/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • GPHYSICS
    • G07CHECKING-DEVICES
    • G07GREGISTERING THE RECEIPT OF CASH, VALUABLES, OR TOKENS
    • G07G1/00Cash registers
    • G07G1/12Cash registers electronically operated

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Memory System (AREA)

Abstract

The application provides a method for realizing shared memory, which is applied to memory allocation under multiple scenes in a POS machine; the method comprises the following steps: determining a first memory usage amount of a first target operation scene; dividing the first occupied memory amount into a first preset amount of heap memory; the heap memory is a memory called by a second target operation scene; when a memory application request of the second target operation scene is acquired, judging whether the first target operation scene is in a suspended state; the memory application request comprises a second memory usage amount corresponding to the second target operation scene; if so, calling the heap memory with the same amount as the second occupied memory to execute the second target operation scene. By the method for sharing the memory under multiple scenes, the memory applied by the large block can be effectively utilized, and when the large block memory is not required to be used, the memory can be flexibly allocated to other places for application and release.

Description

Method, system, equipment and medium for realizing memory sharing under multiple scenes
Technical Field
The present application relates to the field of POS application technologies, and in particular, to a method, a system, a device, and a medium for implementing shared memory in multiple scenarios.
Background
In recent years, the incoming call sign POS machine has the characteristics of strong functions, code scanning and scanned functions, support of a 4G module, an HTTPS protocol and the like, is cheaper than the traditional POS machine, is widely popular in the market, and is frequently innovative in delivery quantity.
The characteristics of lower cost and stronger function are the electric tag POS, but the electric tag POS is difficult to develop products. The main control chip with lower cost and less memory space, such as an MH1902T chip manufactured by the beijing mega news constantly reaches microelectronics company, the memory space is only 128K, when the camera is opened to scan codes, the camera decoding library needs to occupy 70K of memory, and other programs are very easy to crash because the memory space cannot be applied.
In order to solve the above problems, there are 2 general schemes at present. One is to use a main control chip with a larger memory space, but the price cost will also increase. One is the use mutual exclusion of the large-block memory, and the method can ensure that the large-block memory can be completely applied, and other programs can also use the large-block memory, but the flexibility of the use of the memory is not enough based on exclusive memory allocation, so that the use condition of multiple scenes cannot be met, and especially, the mutual calling of the multiple scenes cannot be realized under the condition of small memory space.
Disclosure of Invention
In view of the above, the present application is provided to provide a method, system, device and medium for implementing shared memory in multiple scenarios, which overcomes or at least partially solves the above problems, and includes:
a method for realizing memory sharing is applied to memory sharing under multiple operation scenes in a POS machine;
the method comprises the following steps:
determining a first memory usage amount of a first target operation scene;
dividing the first occupied memory amount into a first preset amount of heap memory; the heap memory is a memory called by a second target operation scene;
when a memory application request of the second target operation scene is acquired, judging whether the first target operation scene is in a suspended state; the memory application request comprises a second memory usage amount corresponding to the second target operation scene;
if so, calling the heap memory with the same amount as the second occupied memory to execute the second target operation scene.
Further, the method also comprises the following steps:
and establishing a corresponding relation between the target operation scene and the required memory.
Further, the step of establishing a corresponding relationship between the target operation scene and the required memory includes:
and establishing a corresponding relation of the required memory capacity corresponding to the operation of the target operation scene according to the data associated with the operation scene and/or the occupied memory amount of the calling library.
Further, the step of dividing the first amount of memory occupied into the heap memory of the first preset amount includes:
converting the physical address corresponding to the first memory occupation amount into a logic address;
and grouping the logic addresses according to a preset grouping rule to obtain a first preset number of heap memories.
Further, the method also comprises the following steps:
when a memory application request of the second target operation scene is acquired, judging whether the first target operation scene is in a suspended state;
if not, determining the second memory usage amount of a second target operation scene;
judging whether the residual static memory is larger than the second memory occupied amount or not according to the second memory occupied amount;
if yes, dividing the second occupied memory amount into a second preset amount of heap memories;
when a memory application request of the third target operation scene is acquired, judging whether the first target operation scene and/or the second target operation scene are in a suspension state; wherein the memory application request includes a third amount of memory occupied corresponding to the third target operation scenario;
if so, calling the heap memory with the same amount as the third occupied memory to execute the third target operation scene.
Further, the method also comprises the following steps:
judging whether the remaining static memory is larger than the second occupied memory amount according to the second occupied memory amount;
and if not, suspending the second target operation scene.
Further, the method also comprises the following steps:
when a memory application request of the third target operation scene is acquired, judging whether the first target operation scene and/or the second target operation scene are in a suspension state;
if not, determining the third memory usage amount of a third target operation scene;
judging whether the remaining static memory is larger than the third memory usage amount according to the third memory usage amount;
if so, dividing the third occupied memory amount into a third preset number of heap memories, and calling the heap memories equal to the third occupied memory amount to execute the third target operation scene; otherwise, suspending the third target operation scene.
A shared memory implementation system is applied to memory allocation under multiple scenes in a POS machine;
the system comprises:
the first determining module is used for determining a first memory usage amount of a first target operation scene;
a first conversion module, configured to divide the first memory usage into a first preset number of heap memories; the heap memory is a memory called by a second target operation scene;
the first judgment module is used for judging whether the first target operation scene is in a suspension state or not when the memory application request of the second target operation scene is acquired; the memory application request comprises a second memory usage amount corresponding to the second target operation scene;
if so, calling the heap memory with the same amount as the second occupied memory to execute the second target operation scene.
An apparatus comprising a processor, a memory and a computer program stored on the memory and capable of running on the processor, the computer program, when executed by the processor, implementing the steps of the shared memory implementation method as described above.
A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the steps of the method for implementing a shared memory as described above.
The application has the following advantages:
in the embodiment of the application, a first memory usage amount of a first target operation scene is determined; dividing the first occupied memory amount into a first preset amount of heap memory; when a memory application request of the second target operation scene is acquired, judging whether the first target operation scene is in a suspended state; if so, calling the heap memory with the same amount as the second occupied memory to execute the second target operation scene. By the method for sharing the memory under multiple scenes, the memory applied by the large block can be effectively utilized, and when the large block memory is not required to be used, the memory can be flexibly allocated to other places for application and release.
Drawings
In order to more clearly illustrate the technical solutions of the present application, the drawings needed to be used in the description of the present application will be briefly introduced below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive labor.
Fig. 1 is a flowchart illustrating steps of a method for implementing a shared memory according to an embodiment of the present disclosure;
FIG. 2 is a flow chart of a memory allocation method in the prior art;
fig. 3 is a schematic structural diagram of an implementation system for sharing a memory according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, the present application is described in further detail with reference to the accompanying drawings and the detailed description. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that, in any embodiment of the present invention, because the memory capacity is small, when the system is started, the system data occupies a certain capacity of the memory, and this part of the memory belongs to the exclusive resource for the system to use, so as to support the normal startup, initialization and operation of the system, and the remaining available memory space is allocated to other functions for use; the method has the advantages that the multi-scene application is realized through dynamic sharing type memory allocation.
Referring to fig. 1, a method for implementing a shared memory according to an embodiment of the present application is shown; the method is applied to memory allocation under multiple scenes in the POS machine;
the method comprises the following steps:
s100, determining a first memory occupation amount of a first target operation scene;
s200, dividing the first occupied memory amount into a first preset amount of heap memories; the heap memory is a memory called by a second target operation scene;
s300, when a memory application request of the second target operation scene is acquired, judging whether the first target operation scene is in a suspended state; the memory application request comprises a second memory usage amount corresponding to the second target operation scene;
if so, calling the heap memory with the same amount as the second occupied memory to execute the second target operation scene.
In the embodiment of the present application, a first memory usage amount of a first target operation scenario is determined; dividing the first occupied memory amount into a first preset amount of heap memory; when a memory application request of the second target operation scene is acquired, judging whether the first target operation scene is in a suspended state; if so, calling the heap memory with the same amount as the second occupied memory to execute the second target operation scene. By the method for sharing the memory under multiple scenes, the memory applied by the large block can be effectively utilized, and when the large block memory is not required to be used, the memory can be flexibly allocated to other places for application and release.
Next, a method for implementing a shared memory in the present exemplary embodiment will be further described.
Determining a first amount of memory occupied by the first target operation scenario in step S100.
In an embodiment of the present invention, a specific process before the "determining the first occupied memory amount of the first target operation scenario" in step S100 may be further described with reference to the following description.
And establishing a corresponding relation between the first target operation scene and the required memory. Counting used space capacity and unused available space capacity in the current physical memory; and determining the residual space capacity data according to the available space capacity.
Further, the step of establishing a corresponding relationship between the first target operation scene and the required memory includes: and establishing a corresponding relation of the memory capacity required by the first target operation scene when the first target operation scene operates according to the size of the first target operation scene, the data associated with the operation scene and/or the first memory occupied amount of the call library.
In an embodiment of the present invention, a specific process of "determining the first occupied memory amount of the first target operation scenario" in step S100 may be further described with reference to the following description.
And according to the size of the first target operation scene, and the data associated with the operation scene and/or the first occupied memory amount of the call library. Calculating the required operation space capacity data according to the capacity of the space occupied by the associated data and/or the call library when the target operation scene operates, wherein the required operation space capacity data comprises the following steps: and calculating the capacity data of the running space required by the program during running according to the size of the occupied space when the program is started and the program and/or a calling library associated with the program.
It should be noted that, in the present application, by acquiring the remaining space in the memory space, the unused available space is first calculated, so as to facilitate memory allocation management; the capacity data is the space size.
As an example, the current physical memory is counted for used space and unused space, for example, when the MH1903S chip is used as the memory of the POS machine, the memory space is 640K, and if the system is started to occupy 20K, the remaining space is 620K, which can be statically allocated and thus converted into heap memory.
In step S200, the first occupied memory amount is divided into a first preset amount of heap memory.
In an embodiment of the invention, a specific process of "dividing the first occupied memory amount into the heap memories of the first preset amount" in step S200 may be further described with reference to the following description.
Dividing the first occupied memory amount into a first preset amount of heap memory; the heap memory is a memory called by a second target operation scene;
converting the physical address corresponding to the first memory occupation amount into a logical address according to the following steps; and grouping the logic addresses according to a preset grouping rule to obtain a first preset number of heap memories. The access to the memory space during the program operation is carried out based on the address of the memory, and the management of the memory space can be realized through the offset of the logical address.
In an embodiment of the present invention, as described in step S300, when a memory application request of the second target operation scenario is acquired, and whether the first target operation scenario is in a suspended state is determined, where the memory application request includes a second amount of occupied memory corresponding to the second target operation scenario; if so, calling the heap memory with the same amount as the second occupied memory to execute the second target operation scene.
In an embodiment of the present invention, the method further includes: when a first memory application request of the second target operation scene is acquired, judging whether the first target operation scene is in a suspended state; if not, determining the second memory usage amount of a second target operation scene;
judging whether the residual static memory is larger than the second memory occupied amount or not according to the second memory occupied amount; if yes, dividing the second occupied memory amount into a second preset amount of heap memories; when a memory application request of the third target operation scene is acquired, judging whether the first target operation scene and/or the second target operation scene are in a suspension state; wherein the memory application request includes a third amount of memory occupied corresponding to the third target operation scenario; if so, calling the heap memory with the same amount as the third occupied memory to execute the third target operation scene.
In an embodiment of the present invention, the method further includes: judging whether the remaining static memory is larger than the second occupied memory amount according to the second occupied memory amount; and if not, suspending the second target operation scene.
In the above embodiment, when the allocated heap memory is not occupied and other scenes need to operate, dividing a space from the currently allocated heap memory, if the current heap memory space is insufficient, determining whether the remaining space meets the requirement of multi-scene operation, if so, performing static application correspondingly, converting the applied memory into the heap memory, and executing the scene to be operated; if the target scene to be operated cannot be met without the residual memory, suspending, and operating the scene to be operated after the current target scene releases enough space.
In an embodiment of the present invention, the method further includes: when a memory application request of the third target operation scene is acquired, judging whether the first target operation scene and/or the second target operation scene are in a suspension state; if not, determining the third memory usage amount of a third target operation scene;
judging whether the remaining static memory is larger than the third memory usage amount according to the third memory usage amount; if so, dividing the third occupied memory amount into a third preset number of heap memories, and calling the heap memories equal to the third occupied memory amount to execute the third target operation scene; otherwise, suspending the third target operation scene.
As an example, for example, a large amount of memory space is made into a heap memory which can be dynamically applied and released in advance, the space required for operation is calculated according to the size of a program and/or a call library (data) associated with a program or a function module to be operated, and M memory blocks are separated from N memory blocks, the space capacity of the M memory blocks is not less than the required operation space to ensure operation thereof, and M is not greater than N to ensure that enough memory blocks can be allocated, for example, when a camera is turned on, the camera needs to call a decoding library, and the decoding library needs to use 70K of memory; at this time, a space not less than 70K is allocated from the heap memory according to the calculated 70K, and is used for the camera to call the decoding bank, for example, 4K is used as one memory block, 600K space in the static space can be divided, 600K/4K is 120 memory blocks (i.e., N is 120), when 70K is allocated, 4K 18 is needed, 72K is needed, i.e., M is 18, and at this time, the space of 72K can satisfy the space occupied by the 70K bank.
As an example, when the operation scene needs to add new call data, calculating the size of the needed new space according to the size of the new call data; according to the size of the newly-increased space, correspondingly and dynamically allocating the number of the required memory blocks; wherein the number of the required memory blocks is not more than N-M; for example, when the camera is opened, the camera needs to call a decoding library, the decoding library needs to use a memory of 70K, and when other auxiliary scenes need to be called at the same time, a space is continuously allocated from the heap memory; the memory allocation is realized according to the operation condition of the functional module or the program while the normal operation of each functional module is ensured, so that enough memory is ensured to support the multi-scene operation.
And when the target operation scene exits, releasing the memory blocks occupied by the current program in operation, and returning the released memory blocks to the memory heap. For example, when a certain operation scenario exits and the large memory occupied by the certain operation scenario is not needed to be used, the large memory is recovered, and the recovered memory block is used as an unused memory block and can be allocated to be used for the operation of other scenarios. For example, when the camera is not opened and a memory is required to be applied in other places, the required memory space is applied in the set heap memory, and multiple applications can be allowed to occur due to the application of a specific memory size, that is, the memory sharing under multiple scenes is satisfied.
As an example, referring to fig. 2, a memory allocation method in the prior art is provided, specifically, when a memory is applied for use, whether a large memory is used is determined. If not, large memory can be directly allocated for use. If the memory is in use, the application fails and the memory cannot be allocated. In the present application, when a large memory of a certain function is not needed, for example, when the camera is not opened. When memories need to be applied in other places, the required memory spaces are respectively applied in the set heap memories, and multiple applications can be allowed to occur due to the application of a specific memory size, namely, the memory sharing under multiple scenes is met.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
Referring to fig. 3, a system for implementing a shared memory according to an embodiment of the present application is shown; the system is applied to memory allocation under multiple scenes in the POS machine;
the method specifically comprises the following steps:
a first determining module 100, configured to determine a first occupied memory amount of a first target operation scenario;
a first conversion module 200, configured to divide the first amount of occupied memory into a first preset number of heap memories; the heap memory is a memory called by a second target operation scene;
a first determining module 300, configured to determine whether the first target operation scene is in a suspended state when the memory application request of the second target operation scene is acquired; the memory application request comprises a second memory usage amount corresponding to the second target operation scene;
if so, calling the heap memory with the same amount as the second occupied memory to execute the second target operation scene.
In an embodiment of the present invention, the system further includes a relationship establishing module, configured to establish a corresponding relationship between the first target operation scenario and the required memory.
In an embodiment of the present invention, the relationship establishing module includes: and the relation submodule is used for establishing a corresponding relation of the first target operation scene and the corresponding required memory capacity when the first target operation scene operates according to the size of the first target operation scene, the data associated with the operation scene and/or the first occupied memory amount of the call library.
In an embodiment of the present invention, the first conversion module 200 includes:
the address conversion submodule is used for converting the physical address corresponding to the first occupied memory amount into a logic address;
and the grouping submodule is used for grouping the logic addresses according to a preset grouping rule to obtain a first preset number of heap memories.
In an embodiment of the present invention, further comprising,
a first determining module 100, configured to determine whether the first target operation scene is in a suspended state when the memory application request of the second target operation scene is acquired; if not, determining the second memory usage amount of a second target operation scene;
the first detection submodule is used for judging whether the remaining static memory is larger than the second occupied memory amount or not according to the second occupied memory amount; if yes, dividing the second occupied memory amount into a second preset amount of heap memories;
the second judging module is used for judging whether the first target operation scene and/or the second target operation scene are in a suspension state or not when the memory application request of the third target operation scene is acquired; wherein the memory application request includes a third amount of memory occupied corresponding to the third target operation scenario; if so, calling the heap memory with the same amount as the third occupied memory to execute the third target operation scene.
In an embodiment of the present invention, the first detection submodule is further configured to determine, according to the second amount of occupied memory, whether the remaining static memory is larger than the second amount of occupied memory; and if not, suspending the second target operation scene.
In an embodiment of the present invention, the second determining module is further configured to determine whether the first target operation scene and/or the second target operation scene is in a suspended state when the memory application request of the third target operation scene is obtained; if not, determining the third memory usage amount of a third target operation scene;
a second detection submodule, configured to determine, according to the third amount of memory occupied, whether a remaining static memory is larger than the third amount of memory occupied; if so, dividing the third occupied memory amount into a third preset number of heap memories, and calling the heap memories equal to the third occupied memory amount to execute the third target operation scene; otherwise, suspending the third target operation scene.
Referring to fig. 4, a computer device for implementing a method for sharing a memory according to the present invention is shown, which may specifically include the following:
the computer device 12 described above is embodied in the form of a general purpose computing device, and the components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 and the processing unit 16.
Bus 18 represents one or more of any of several types of bus 18 structures, including a memory bus 18 or memory controller, a peripheral bus 18, an accelerated graphics port, and a processor or local bus 18 using any of a variety of bus 18 architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus 18, micro-channel architecture (MAC) bus 18, enhanced ISA bus 18, audio Video Electronics Standards Association (VESA) local bus 18, and Peripheral Component Interconnect (PCI) bus 18.
Computer device 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by computer device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)30 and/or cache memory 32. Computer device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (commonly referred to as "hard drives"). Although not shown in FIG. 4, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. The memory may include at least one program product having a set (e.g., at least one) of program modules 42, with the program modules 42 configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules 42, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
Computer device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, camera, etc.), with one or more devices that enable a healthcare worker to interact with computer device 12, and/or with any devices (e.g., network card, modem, etc.) that enable computer device 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 22. Also, computer device 12 may communicate with one or more networks (e.g., a Local Area Network (LAN)), a Wide Area Network (WAN), and/or a public network (e.g., the Internet) via network adapter 20. As shown, the network adapter 20 communicates with the other modules of the computer device 12 via the bus 18. It should be appreciated that although not shown in FIG. 4, other hardware and/or software modules may be used in conjunction with computer device 12, including but not limited to: microcode, device drivers, redundant processing units 16, external disk drive arrays, RAID systems, tape drives, and data backup storage systems 34, etc.
The processing unit 16 executes programs stored in the system memory 28 to execute various functional applications and data processing, for example, to implement the method for implementing the shared memory provided by the embodiment of the present invention.
That is, the processing unit 16 implements, when executing the program,: acquiring the residual space in the memory space; dividing the residual space into heap memories containing N memory blocks; acquiring data of the program and capacity data of an operation space required by calling the data when the program operates; and distributing M memory blocks from the N memory blocks according to the required operating space.
In an embodiment of the present invention, the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for implementing the shared memory as provided in all embodiments of the present application:
that is, the program when executed by the processor implements: acquiring the residual space in the memory space; dividing the residual space into heap memories containing N memory blocks; acquiring data of the program and capacity data of an operation space required by calling the data when the program operates; and allocating M memory blocks from the N memory blocks according to the capacity data.
Any combination of one or more computer-readable media may be employed. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPOM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the healthcare worker computer, partly on the healthcare worker computer, as a stand-alone software package, partly on the healthcare worker computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the healthcare worker's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider). The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
While preferred embodiments of the present application have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the true scope of the embodiments of the application.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The method, the system, the device and the medium for implementing the shared memory under multiple scenes provided by the application are introduced in detail, a specific example is applied in the text to explain the principle and the implementation mode of the application, and the description of the embodiment is only used for helping to understand the method and the core idea of the application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (9)

1. A method for realizing memory sharing is characterized in that the method is applied to memory sharing under multiple operation scenes in a POS machine;
the method comprises the following steps:
determining a first memory usage amount of a first target operation scene;
dividing the first amount of occupied memory into a first preset amount of heap memory, including: converting the physical address corresponding to the first memory occupation amount into a logic address; grouping the logic addresses according to a preset grouping rule to obtain a first preset number of heap memories, wherein the heap memories are memories called by a second target operation scene;
when a memory application request of the second target operation scene is acquired, judging whether the first target operation scene is in a suspended state; the memory application request comprises a second memory usage amount corresponding to the second target operation scene;
if so, calling the heap memory with the same amount as the second occupied memory to execute the second target operation scene.
2. The method of claim 1, further comprising:
and establishing a corresponding relation between the target operation scene and the required memory.
3. The method according to claim 2, wherein the step of establishing the corresponding relationship between the target operation scenario and the required memory comprises:
and establishing a corresponding relation of the required memory capacity corresponding to the operation of the target operation scene according to the data associated with the operation scene and/or the occupied memory amount of the calling library.
4. The method of claim 1, further comprising:
when a memory application request of the second target operation scene is acquired, judging whether the first target operation scene is in a suspended state;
if not, determining the second memory usage amount of a second target operation scene;
judging whether the residual static memory is larger than the second memory occupied amount or not according to the second memory occupied amount;
if yes, dividing the second occupied memory amount into a second preset amount of heap memories;
when a memory application request of a third target operation scene is acquired, judging whether the first target operation scene and/or the second target operation scene are in a suspension state or not; wherein the memory application request includes a third amount of memory occupied corresponding to the third target operation scenario;
if so, calling the heap memory with the same amount as the third occupied memory to execute the third target operation scene.
5. The method of claim 1, further comprising:
judging whether the residual static memory is larger than the second memory occupied amount or not according to the second memory occupied amount;
and if not, suspending the second target operation scene.
6. The method of claim 1, further comprising:
when a memory application request of a third target operation scene is acquired, judging whether the first target operation scene and/or the second target operation scene are in a suspension state or not;
if not, determining a third memory usage amount of a third target operation scene;
judging whether the remaining static memory is larger than the third memory usage amount according to the third memory usage amount;
if so, dividing the third occupied memory amount into a third preset number of heap memories, and calling the heap memories equal to the third occupied memory amount to execute the third target operation scene; otherwise, suspending the third target operation scene.
7. A shared memory implementation system is characterized in that the system is applied to memory allocation under multiple scenes in a POS machine;
the system comprises:
the first determining module is used for determining a first memory usage amount of a first target operation scene;
a first conversion module, configured to divide the first memory usage into a first preset number of heap memories; the heap memory is a memory called by a second target operation scene; wherein the first conversion module comprises: the address conversion submodule is used for converting the physical address corresponding to the first occupied memory amount into a logic address; the grouping submodule is used for grouping the logic addresses according to a preset grouping rule to obtain a first preset number of heap memories;
the first judgment module is used for judging whether the first target operation scene is in a suspension state or not when the memory application request of the second target operation scene is acquired; the memory application request comprises a second memory usage amount corresponding to the second target operation scene;
if so, calling the heap memory with the same amount as the second occupied memory to execute the second target operation scene.
8. A computer device implementing a method of sharing memory, comprising a processor, a memory, and a computer program stored on the memory and capable of running on the processor, the computer program, when executed by the processor, implementing the method of any of claims 1 to 6.
9. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 6.
CN202110797337.XA 2021-07-14 2021-07-14 Method, system, equipment and medium for realizing memory sharing under multiple scenes Active CN113485835B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110797337.XA CN113485835B (en) 2021-07-14 2021-07-14 Method, system, equipment and medium for realizing memory sharing under multiple scenes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110797337.XA CN113485835B (en) 2021-07-14 2021-07-14 Method, system, equipment and medium for realizing memory sharing under multiple scenes

Publications (2)

Publication Number Publication Date
CN113485835A CN113485835A (en) 2021-10-08
CN113485835B true CN113485835B (en) 2022-04-22

Family

ID=77939282

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110797337.XA Active CN113485835B (en) 2021-07-14 2021-07-14 Method, system, equipment and medium for realizing memory sharing under multiple scenes

Country Status (1)

Country Link
CN (1) CN113485835B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113900829B (en) * 2021-12-10 2022-04-12 深圳比特微电子科技有限公司 Memory management method for device, memory management device and computing system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104461913A (en) * 2013-09-24 2015-03-25 大陆汽车有限责任公司 Management of memory
CN106547617A (en) * 2015-09-18 2017-03-29 李鹤 A kind of EMS memory management process and system using analysis-feedback-tuning pattern
CN106855845A (en) * 2015-12-09 2017-06-16 北京信威通信技术股份有限公司 The Memory Allocation management system and embedded chip of heap space
CN107357656A (en) * 2017-06-27 2017-11-17 努比亚技术有限公司 A kind of memory allocation method, mobile terminal and computer-readable recording medium
CN109376022A (en) * 2018-09-29 2019-02-22 中国科学技术大学 It is a kind of promoted Halide language multiple nucleus system execution efficiency threading model implementation method
CN112685333A (en) * 2020-12-28 2021-04-20 上海创功通讯技术有限公司 Heap memory management method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120047495A1 (en) * 2010-08-18 2012-02-23 Microsoft Corporation Execution environment support for reactive programming
CN105893269B (en) * 2016-03-31 2018-08-21 武汉虹信技术服务有限责任公司 EMS memory management process under a kind of linux system
US10901828B2 (en) * 2017-10-26 2021-01-26 Board Of Regents, The University Of Texas System Freeguard: a faster secure heap allocator

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104461913A (en) * 2013-09-24 2015-03-25 大陆汽车有限责任公司 Management of memory
CN106547617A (en) * 2015-09-18 2017-03-29 李鹤 A kind of EMS memory management process and system using analysis-feedback-tuning pattern
CN106855845A (en) * 2015-12-09 2017-06-16 北京信威通信技术股份有限公司 The Memory Allocation management system and embedded chip of heap space
CN107357656A (en) * 2017-06-27 2017-11-17 努比亚技术有限公司 A kind of memory allocation method, mobile terminal and computer-readable recording medium
CN109376022A (en) * 2018-09-29 2019-02-22 中国科学技术大学 It is a kind of promoted Halide language multiple nucleus system execution efficiency threading model implementation method
CN112685333A (en) * 2020-12-28 2021-04-20 上海创功通讯技术有限公司 Heap memory management method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
动态内存分配器研究综述;刘翔;《计算机学报》;20181031;全文 *

Also Published As

Publication number Publication date
CN113485835A (en) 2021-10-08

Similar Documents

Publication Publication Date Title
CN100390740C (en) Method and system for allocating entitled processor cycles for preempted virtual processors
CN111090628A (en) Data processing method and device, storage medium and electronic equipment
US7600093B2 (en) Device, method and computer program product for multi-level address translation
CN110865888A (en) Resource loading method and device, server and storage medium
CN105183565A (en) Computer and service quality control method and device
US11275618B2 (en) Method, device and medium for allocating resource based on type of PCI device
CN101681297A (en) Arrangements for memory allocation
CN111459678A (en) Resource scheduling method and device, storage medium and electronic equipment
US20220229701A1 (en) Dynamic allocation of computing resources
CN113485835B (en) Method, system, equipment and medium for realizing memory sharing under multiple scenes
CN115904761A (en) System on chip, vehicle and video processing unit virtualization method
US20180052700A1 (en) Facilitation of guest application display from host operating system
CN109697166B (en) Test data preparation method and related device
CN109558210B (en) Method and system for virtual machine to apply GPU (graphics processing Unit) equipment of host
CN116886626A (en) Service data flow limiting method and device, computer equipment and storage medium
CN115098272A (en) GPU resource scheduling method, scheduler, electronic device and storage medium
CN113312184A (en) Service data processing method and related equipment
CN114253704A (en) Method and device for allocating resources
CN111008074B (en) File processing method, device, equipment and medium
CN113835862B (en) Task processing method and device
CN117742957A (en) Memory allocation method, memory allocation device, electronic equipment and storage medium
CN116599917B (en) Network port determining method, device, equipment and storage medium
CN112488293B (en) Method and device for operating deep learning network
CN111897484B (en) Data storage method and device, electronic equipment and storage medium
CN111930566A (en) Data backup method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant