CN108628676A - A kind of memory management device and method towards multiple nucleus system - Google Patents

A kind of memory management device and method towards multiple nucleus system Download PDF

Info

Publication number
CN108628676A
CN108628676A CN201710157945.8A CN201710157945A CN108628676A CN 108628676 A CN108628676 A CN 108628676A CN 201710157945 A CN201710157945 A CN 201710157945A CN 108628676 A CN108628676 A CN 108628676A
Authority
CN
China
Prior art keywords
memory
privately owned
global
management module
area
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
CN201710157945.8A
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.)
Harbin Talent Information Technology Co Ltd
Original Assignee
Harbin Talent Information Technology 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 Harbin Talent Information Technology Co Ltd filed Critical Harbin Talent Information Technology Co Ltd
Priority to CN201710157945.8A priority Critical patent/CN108628676A/en
Publication of CN108628676A publication Critical patent/CN108628676A/en
Pending legal-status Critical Current

Links

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
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/0284Multiple user address space allocation, e.g. using different base addresses
    • 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/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/526Mutual exclusion algorithms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5011Pool

Abstract

The present invention provides a kind of memory management device and method towards multiple nucleus system, including privately owned memory management module, fair synchronization control module and global memory's management module;Privately owned memory management module manages privately owned memory field, is mainly used for the application of fritter memory, and a privately owned memory field is answered in each verification, is designed using without lockization, and the expense of lock is avoided;Fair synchronization control module ensures that multiple cores when asking for memory to global memory's management module, can accomplish fair synchronization;Global memory's management module, area of management global memory are privately owned memory management module service, are responsible for the application of bulk memory, and in Out of Memory, memory acquisition is carried out to system.The present invention without lockization and memory block buffer technology, is used cooperatively justice synchronization and mutex algorithm, ensures the efficiency of internal storage access and the fairness of contention for resource using privately owned.Fair synchronization mechanism is added, avoids the injustice of memory source competition between core, while ensureing internal storage access efficiency.

Description

A kind of memory management device and method towards multiple nucleus system
Technical field
The present invention relates to multi-core processor memory management technology field more particularly to a kind of memory pipes towards multiple nucleus system Manage device and method.
Background technology
Multi-core processor can be regarded as multiple general CPU and some functional components being integrated in shape in chip piece At a system on chip.Memory Management Subsystem is the basis for ensureing whole system normal work, is the normal of other modules Work the guarantee that provides the foundation.In the management of monokaryon Installed System Memory, need to pay close attention to memory fragmentation, the problems such as allocative efficiency, and Multi-core internal memory management in, also relate to some different from monokaryon memory management the problem of, as shared buffer memory failure, exclusive reference, Internuclear fragment etc..
Existing maturation EMS memory management process, such as Jemalloc, Ptmalloc, Tcmalloc, they are considered more It is versatility.When using these management methods in multinuclear multitask system, with increasing for number of tasks, the efficiency of management method It will accordingly reduce.Although Tcmalloc improves to some extent in this respect, it inevitably will appear another problem:Multitask Between fight for resource fairness.Existing memory management device can be indicated with reduced form shown in FIG. 1.Memory is made For public resource, in order to ensure correctness that resource accesses, multiple tasks to resource access should mutual exclusion progress, either Ptmalloc or Tcmalloc will finally ensure mutually exclusive operation.Since the wake-up of blocked task has randomness, extreme In the case of, if some task frequently carries out internal memory operation, and operating system only responds this task, other etc. Wait for that the task of Memory Allocation will block always.Which forms a kind of " starvation " phenomenon, multitask work evolves into single task Work, the efficiency of multiple nucleus system just reduce.
Invention content
It is fair the present invention also aims to provide a kind of efficient Memory Allocation towards multiple nucleus system and internuclear memory The EMS memory management process of competition.
In order to solve the above technical problems, the present invention provides a kind of memory management device towards multiple nucleus system, including private There are memory management module, fair synchronization control module and global memory's management module;
The privately owned memory management module, manages privately owned memory field, is mainly used for the application of fritter memory, and each verification answers one A privately owned memory field is designed using without lockization, avoids the expense of lock;
The fair synchronization control module ensures that multiple cores when asking for memory to global memory's management module, can be accomplished Justice is synchronous;
Global memory's management module, area of management global memory are privately owned memory management module service, are responsible for bulk memory Application, in Out of Memory, to system carry out memory acquisition.
A kind of EMS memory management process towards multiple nucleus system of the present invention, includes the following steps:
A privately owned memory field is distributed on S1, each core, on core when task storage allocation, first from privately owned Memory Allocation memory, such as The free block that the memory block that fruit needs is more than the memory fields 2K or privately owned is inadequate, then turns to global memory's directorial area application memory point Match, otherwise, arrives step S4;
S2, all cores share an area of global memory, and fair synchronous protection is added in area of global memory, ensure task competition money Source is fair;
It is if S3, global memory's area's memory are enough, suitable memory headroom is wholesale to privately owned memory field, otherwise, to system Memory headroom is carried out to ask for;
The memory address that S4, return are applied;
Memory discharges process:
Corresponding Tag labels can all be added on every piece of memory, indicate the source of current memory, if coming from privately owned memory field, Memory block is then restored to privately owned memory field, otherwise, is returned to area of global memory, transfers to the memory headroom in area of global memory, then Determine whether it is returned in system.
One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:
In multi-core internal memory management method, internal storage access efficiency is improved, is the mesh that numerous EMS memory management process are pursued jointly Mark.Mainly multiple nucleus system Memory Management is optimized in terms of three at present:First, use privatization to design as possible, It reduces the shared data amount of each core of processor or reduces the access of shared data;Second, it is operated to shared data When, it avoids that influence of the lock to system performance can be reduced in this way using lock as possible;Third, from improvement multiple nucleus system overall performance Angle set out, to improve overall performance, it is necessary to be optimized to the monokaryon performance of each processor core, for monokaryon Speech, it should improve the access ability to oneself private data as possible.It is designed without lockization by privately owned, memory contention can be reduced and opened Pin adds certain memory block cache policy, can make the competition cost reduction of lock.
The present invention internally deposits into row differentiated control, using privately owned without lockization and memory block buffer technology, with the use of public affairs Flat synchronization and mutex algorithm ensures the efficiency of internal storage access and the fairness of contention for resource.In small memory application, avoid as possible The use of lock;In big memory application, control is synchronized with low granularity lock, while fair synchronization mechanism is added, avoid core Between the injustice that competes of memory source, while ensureing internal storage access efficiency.
Description of the drawings
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention, for those of ordinary skill in the art, without having to pay creative labor, also It can be obtain other attached drawings according to these attached drawings.
Fig. 1 is the memory management mounted cast figure towards multiple nucleus system.
Fig. 2 is global memory's area's organization chart.
Fig. 3 is fair synchronization and mutex algorithm flow chart.
Fig. 4 is privately owned memory field organization chart.
Specific implementation mode
In order to better understand the above technical scheme, in conjunction with appended figures and specific embodiments to upper Technical solution is stated to be described in detail.
As Figure 1-Figure 4, a kind of memory management device towards multiple nucleus system described in the present embodiment, including it is privately owned interior Deposit management module, fair synchronization control module and global memory's management module;
The privately owned memory management module, manages privately owned memory field, is mainly used for the application of fritter memory, and each verification answers one A privately owned memory field is designed using without lockization, avoids the expense of lock;
The fair synchronization control module ensures that multiple cores when asking for memory to global memory's management module, can be accomplished Justice is synchronous;
Global memory's management module, area of management global memory are privately owned memory management module service, are responsible for bulk memory Application, in Out of Memory, to system carry out memory acquisition.
A kind of EMS memory management process towards multiple nucleus system described in the present embodiment, includes the following steps:
A privately owned memory field is distributed on S1, each core, on core when task storage allocation, first from privately owned Memory Allocation memory, such as The free block that the memory block that fruit needs is more than the memory fields 2K or privately owned is inadequate, then turns to global memory's directorial area application memory point Match, otherwise, arrives step S4;
S2, all cores share an area of global memory, and fair synchronous protection is added in area of global memory, ensure task competition money Source is fair;
It is if S3, global memory's area's memory are enough, suitable memory headroom is wholesale to privately owned memory field, otherwise, to system Memory headroom is carried out to ask for;
The memory address that S4, return are applied;
Memory discharges process:
Corresponding Tag labels can all be added on every piece of memory, indicate the source of current memory, if coming from privately owned memory field, Memory block is then restored to privately owned memory field, otherwise, is returned to area of global memory, transfers to the memory headroom in area of global memory, then Determine whether it is returned in system.
More specifically:
(1)Global memory's management module
Global memory's management module is mainly used for managing area of global memory, and attached drawing 3 is the organization chart in area of global memory.It is global Based on buddy algorithm, per sub-distribution and releasing memory block is all as unit of 2 power, can accelerate the conjunction of memory for memory field And and separating rate.Available partner's memory block of single section may cannot be satisfied user's present application needs, therefore in the overall situation Multiple sections are arranged in memory field, while setting up a section range mark Range, represent currently can storage allocation maximum section Index subscript.It carries out repeatedly attempting distribution in accordance with the following steps in Memory Allocation, after only all attempting failure, ability calling system Interface reduces the expense with system interaction, and steps are as follows for Memory Allocation:
1)The section first indicated from Range carries out Memory Allocation, is allocated successfully, and returns to memory address, unsuccessful, executes step 2).
2)From [0, Range) section in searched whether available memory block, find, return memory address, otherwise, Execute step 3).
3)A new section is extended, Range adds one, Memory Allocation is carried out from new section, if distribution is unsuccessful, Then arrive step 4).
4)Calling system interface carries out Memory Allocation.
Global memory's area's memory allocation algorithm is implemented as follows:
Area of global memory mainly marks from memory block when recycling memory and obtains related release information in Tag, according to these letters Breath determines that memory block returns to system and is still discharged into respective segments, if memory block is returned in respective segments, mainly Using the release process of buddy algorithm, such as recycling size isFree block when, if order record chained list in exist's It should with partner's merged block be then that size is by partner's free blockFree block, if order record chained list in there is alsoPartner's free block, and continue with its partner's merged block beFree block, and so on, until that cannot merge Until.The algorithm of Memory recycle is realized as follows.
(2)Fair synchronization control module
Due to privately owned memory field and area of global memory, in interactive process, there are exclusive references, and area of global memory is for privately owned memory It is a kind of critical resource, in the case where number of tasks is excessive for area, in fact it could happen that " starvation " phenomenon.Therefore, in order to ensure appoint The fairness that critical resource is fought between the correctness and multitask of flow of being engaged in needs correctly fair synchronization and mutex and calculates Method.The effect of fair synchronization control module is ensuring that fair exclusive reference of the multitask to critical resource, without one A task occupies critical resource always, other tasks block always the case where waiting wakes up.It is main logical in fair mutually exclusive algorithm A priority groups group and task status token variable state are crossed to control the fairness to critical resource access, algorithm It is as follows to execute flow:
1)After current task enters fair synchronization zone, 2 states oneself will be switched to first, indicates entry into the initial segment, then read Current group values.
2)If task wants to enter into critical zone, the state of task needs and group is differed or current task It is identical as the state of other all tasks, to ensure that the state of each task is synchronous.
3)It needs mutual exclusion to carry out the access of critical zone, is locked before accessing, unlocked after accessing.
4)After accessing critical zone, the value for changing current group is needed, the task that other belong to group is enable to be held Row permission.
5)The state of current task is set to 3 states, to indicate no longer to need to access critical resource.
Being implemented as follows for fair mutually exclusive algorithm is shown.
(3) privately owned memory management module
Privately owned memory management module mainly manages privately owned memory field.If current number of tasks is excessive, while going to area of global memory Competitive resource inherently increases mutual exclusion expense.It is influenced caused by mutual exclusion to reduce, is every using privately owned without lockization thought A core sets up the privately owned memory field of oneself.Free memory block can be cached to improve allocative efficiency in privately owned memory field, But in order to avoid too many memory is occupied, largest block is dimensioned to 2KB, this can also meet the memory of major applications Application needs.If necessary to bigger memory block, can be applied by area of global memory.Attached drawing 4 is privately owned memory field tissue Structure chart.
Specific allocation step is as follows:
1)When user applies for memory, if memory size is more than 2KB, directly applied to area of global memory, at this point, interior The tag of counterfoil can be marked as area of global memory, if memory size is less than 2KB, execute step 2).
2)The corresponding block array indexing subscript of memory block is calculated, checks whether the idle chain of current block is empty.If For sky, 4 are thened follow the steps), otherwise arrive step 3).
3)It takes out a free cells from the memory headroom that the idle chain is directed toward to use to user, and in free cells Label tag is privately owned memory field, records the block array index currently distributed and memory block position, changes counter structure Occupied free block total amount chunk_used in BulkArray is added the free block in one, Head to occupy by the field information of body It counts held and adds one, if first free block pointer free is directed toward next free memory unit and is set without free cells For NULL, and the memory headroom that current idle chain is directed toward is articulated to expires in chain.
4)Plot location space is obtained from area of global memory, this block space is cut into the identical internal storage location of size, is write from memory Recognizing has 32 internal storage locations, but the space distributed from area of global memory might have fragment in a large amount of, by these extra fragments Space is also divided into internal storage location together, further decreases fragment problems in memory.Pass through static linked list between unit and unit Tissue is carried out, and changes the unit total amount in Head and counts hold, on the free block total amount chunk_total of BulkArray In addition active cell total amount counts, one is finally distributed from current free block and is labeled as privately owned memory to user, and by tag Area records the block array index currently distributed and memory block position.
Memory Allocation is implemented as follows.
Privately owned memory field memory release steps are as follows:
1)Label information is got from the memory of release, judges whether memory comes from privately owned memory field by label information, such as Fruit is not privately owned memory field distribution, then arrives step 5), otherwise arrive step 2).
2)The block array index recorded when by distributing and memory block position, the affiliated block of positioning current memory and head Position illustrates that the memory block in current memory space is fully occupied if head free pointer free is NULL, discharges now After memory block, need entire memory headroom being articulated on idle chain from chain has been expired.
3)Corresponding construction body field information is adjusted, the free block usage count held of Head is subtracted one, the quilt of BulkArray It occupies free block total amount chunk_used and subtracts one.
4)If the memory block in current memory space is all idle, and remaining free memory block sum is more than collapse threshold The current Head memory headrooms being directed toward then are returned to area of global memory by chunk_thresd.
5)The memory block of address directions is given back to area of global memory.
The above described is only a preferred embodiment of the present invention, be not intended to limit the present invention in any form, though So the present invention has been disclosed as a preferred embodiment, and however, it is not intended to limit the invention, any technology people for being familiar with this profession Member, without departing from the scope of the present invention, when the technology contents using the disclosure above make a little change or modification For the equivalent embodiment of equivalent variations, as long as being the content without departing from technical solution of the present invention, according to the technical essence of the invention To any simple modification, equivalent change and modification made by above example, in the range of still falling within technical solution of the present invention.

Claims (2)

1. a kind of memory management device towards multiple nucleus system, which is characterized in that synchronous including privately owned memory management module, justice Control module and global memory's management module;
The privately owned memory management module, manages privately owned memory field, is mainly used for the application of fritter memory, and each verification answers one A privately owned memory field is designed using without lockization, avoids the expense of lock;
The fair synchronization control module ensures that multiple cores when asking for memory to global memory's management module, can be accomplished Justice is synchronous;
Global memory's management module, area of management global memory are privately owned memory management module service, are responsible for bulk memory Application, in Out of Memory, to system carry out memory acquisition.
2. a kind of EMS memory management process towards multiple nucleus system, which is characterized in that include the following steps:
A privately owned memory field is distributed on S1, each core, on core when task storage allocation, first from privately owned Memory Allocation memory, such as The free block that the memory block that fruit needs is more than the memory fields 2K or privately owned is inadequate, then turns to global memory's directorial area application memory point Match, otherwise, arrives step S4;
S2, all cores share an area of global memory, and fair synchronous protection is added in area of global memory, ensure task competition money Source is fair;
It is if S3, global memory's area's memory are enough, suitable memory headroom is wholesale to privately owned memory field, otherwise, to system Memory headroom is carried out to ask for;
The memory address that S4, return are applied;
Memory discharges process:
Corresponding Tag labels can all be added on every piece of memory, indicate the source of current memory, if coming from privately owned memory field, Memory block is then restored to privately owned memory field, otherwise, is returned to area of global memory, transfers to the memory headroom in area of global memory, then Determine whether it is returned in system.
CN201710157945.8A 2017-03-16 2017-03-16 A kind of memory management device and method towards multiple nucleus system Pending CN108628676A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710157945.8A CN108628676A (en) 2017-03-16 2017-03-16 A kind of memory management device and method towards multiple nucleus system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710157945.8A CN108628676A (en) 2017-03-16 2017-03-16 A kind of memory management device and method towards multiple nucleus system

Publications (1)

Publication Number Publication Date
CN108628676A true CN108628676A (en) 2018-10-09

Family

ID=63686836

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710157945.8A Pending CN108628676A (en) 2017-03-16 2017-03-16 A kind of memory management device and method towards multiple nucleus system

Country Status (1)

Country Link
CN (1) CN108628676A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287127A (en) * 2019-05-14 2019-09-27 江苏大学 A kind of Nonvolatile memory management method and system that more granularity multicores are expansible
CN115114192A (en) * 2021-03-23 2022-09-27 北京灵汐科技有限公司 Memory interface, functional core, many-core system and memory data access method

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101246466A (en) * 2007-11-29 2008-08-20 华为技术有限公司 Management method and device for sharing internal memory in multi-core system
CN102571580A (en) * 2011-12-31 2012-07-11 曙光信息产业股份有限公司 Data receiving method and computer
US8479155B2 (en) * 2009-06-15 2013-07-02 Microsoft Corporation Hypergraph implementation
CN103353851A (en) * 2013-07-01 2013-10-16 华为技术有限公司 Method and equipment for managing tasks
CN103885569A (en) * 2014-04-11 2014-06-25 珠海全志科技股份有限公司 Management method and device of memories

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101246466A (en) * 2007-11-29 2008-08-20 华为技术有限公司 Management method and device for sharing internal memory in multi-core system
US8479155B2 (en) * 2009-06-15 2013-07-02 Microsoft Corporation Hypergraph implementation
CN102571580A (en) * 2011-12-31 2012-07-11 曙光信息产业股份有限公司 Data receiving method and computer
CN103353851A (en) * 2013-07-01 2013-10-16 华为技术有限公司 Method and equipment for managing tasks
CN103885569A (en) * 2014-04-11 2014-06-25 珠海全志科技股份有限公司 Management method and device of memories

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287127A (en) * 2019-05-14 2019-09-27 江苏大学 A kind of Nonvolatile memory management method and system that more granularity multicores are expansible
CN115114192A (en) * 2021-03-23 2022-09-27 北京灵汐科技有限公司 Memory interface, functional core, many-core system and memory data access method

Similar Documents

Publication Publication Date Title
Karlin et al. Competitive snoopy caching
CN110226157A (en) Dynamic memory for reducing row buffering conflict remaps
US9098462B1 (en) Communications via shared memory
CN104346317B (en) Shared resource access method and device
US8645627B2 (en) Memory bus write prioritization
CN101566977B (en) Method, device and system of processor accessing shared data
CN104699631A (en) Storage device and fetching method for multilayered cooperation and sharing in GPDSP (General-Purpose Digital Signal Processor)
US20060047919A1 (en) Atomic read/write support in a multi-module memory configuration
CN106575264A (en) On-demand shareability conversion in a heterogeneous shared virtual memory
CN102298539A (en) Method and system for scheduling shared resources subjected to distributed parallel treatment
US8495302B2 (en) Selecting a target number of pages for allocation to a partition
US9063794B2 (en) Multi-threaded processor context switching with multi-level cache
CN112148665B (en) Cache allocation method and device
EP2710481B1 (en) Decentralized allocation of resources and interconnect structures to support the execution of instruction sequences by a plurality of engines
CN103827842A (en) Writing message to controller memory space
CN103164278A (en) Real-time dynamic memory manager achieving method for multi-core processor
EP2800008A1 (en) Method and system for multiprocessors to share memory
CN110727517A (en) Memory allocation method and device based on partition design
CN105302489B (en) A kind of remote embedded accumulator system of heterogeneous polynuclear and method
CN108628676A (en) A kind of memory management device and method towards multiple nucleus system
CN105718242A (en) Processing method and system for supporting software and hardware data consistency in multi-core DSP (Digital Signal Processing)
US9032158B2 (en) Method, system and apparatus for identifying a cache line
CN101196833B (en) Method and apparatus for memory utilization
CN107203890A (en) Credential data distribution method, apparatus and system
US8738833B2 (en) Collaborative bus arbitration multiplex architecture and method of arbitration of data access based on the architecture

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20181009

RJ01 Rejection of invention patent application after publication