KR101391957B1 - Method for scheduling resource block in wireless communicatoin system and apparatus thereof - Google Patents

Method for scheduling resource block in wireless communicatoin system and apparatus thereof Download PDF

Info

Publication number
KR101391957B1
KR101391957B1 KR1020120048288A KR20120048288A KR101391957B1 KR 101391957 B1 KR101391957 B1 KR 101391957B1 KR 1020120048288 A KR1020120048288 A KR 1020120048288A KR 20120048288 A KR20120048288 A KR 20120048288A KR 101391957 B1 KR101391957 B1 KR 101391957B1
Authority
KR
South Korea
Prior art keywords
memory block
memory
block
index
allocated
Prior art date
Application number
KR1020120048288A
Other languages
Korean (ko)
Other versions
KR20130124840A (en
Inventor
박택순
홍근선
Original Assignee
주식회사 대명엔터프라이즈
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 주식회사 대명엔터프라이즈 filed Critical 주식회사 대명엔터프라이즈
Priority to KR1020120048288A priority Critical patent/KR101391957B1/en
Publication of KR20130124840A publication Critical patent/KR20130124840A/en
Application granted granted Critical
Publication of KR101391957B1 publication Critical patent/KR101391957B1/en

Links

Images

Classifications

    • 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/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0844Multiple simultaneous or quasi-simultaneous cache accessing
    • G06F12/0846Cache with multiple tag or data arrays being simultaneously accessible
    • 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
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/06Addressing a physical block of locations, e.g. base addressing, module addressing, memory dedication

Abstract

메모리 할당 방법 및 해제 방법을 포함하는 효율적인 메모리 관리 방법이 개시된다.
이 방법은 메모리 할당기가 메모리를 관리하는 방법으로서, 응용 프로그램에게 할당할 전체 메모리 블록을 초기화하는 단계; 응용 프로그램으로부터 할당 요청된 블록을 상기 전체 메모리 블록에서 할당하고, 상기 응용 프로그램으로부터 해제 요청된 블록을 상기 전체 메모리 블록에서 회수하는 단계; 및 상기 전체 메모리 블록을 반환하는 단계를 포함하며, 상기 전체 메모리 블록을 헤드 인덱스-여기서 헤드 인덱스는 상기 전체 메모리 블록 중에서 할당된 메모리 블록들 중 상기 전체 메모리 블록의 가장 끝 부분에 위치한 메모리 블록의 다음 블록의 위치를 가리킴-와 테일 인덱스-여기서 테일 인덱스는 상기 전체 메모리 블록 중에서 할당된 메모리 블록들 중 상기 전체 메모리 블록의 가장 처음 부분에 위치한 메모리 블록의 위치를 가리킴-를 사용하여 관리하며, 상기 헤드 인덱스와 테일 인덱스는 0부터 시작하여 증가하여 상기 전체 메모리 블록의 끝 부분에서 다시 0으로 설정되는 것을 특징으로 한다.
An efficient memory management method including a memory allocation method and a release method is disclosed.
The method includes the steps of initializing an entire memory block to be allocated to an application program, Allocating a block requested to be allocated from an application program in the entire memory block and recovering a block requested to be released from the application program in the entire memory block; And returning the entire memory block, wherein the head index of the entire memory block, where the head index is the next memory block located at the end of the entire memory block among the memory blocks allocated among the entire memory blocks, And a tail index, wherein the tail index indicates a position of a memory block located at the beginning of the entire memory block among the memory blocks allocated among the entire memory blocks, The index and the tail index are incremented from 0 and set to 0 at the end of the entire memory block.

Description

메모리 할당 방법 및 해제 방법을 포함하는 효율적인 메모리 관리 방법{METHOD FOR SCHEDULING RESOURCE BLOCK IN WIRELESS COMMUNICATOIN SYSTEM AND APPARATUS THEREOF}BACKGROUND OF THE INVENTION 1. Field of the Invention [0001] The present invention relates to a memory management method,

본 발명은 메모리 할당 방법 및 해제 방법을 포함하는 효율적인 메모리 관리 방법에 관한 것이다.The present invention relates to an efficient memory management method including a memory allocation method and a release method.

영상 처리 시스템은 영상 데이터를 목적에 따라 가공하게 되는데 이 과정에서 각각의 영상 데이터를 담아둘 메모리를 필요로 하게 된다. The image processing system processes the image data according to the purpose. In this process, a memory for storing the image data is required.

일반적으로 데이터를 가공하기 위한 메모리는 프로그래밍 언어에 내장된 메모리 할당기로부터 제공받고(메모리 할당), 필요한 가공을 마치면 할당기에 반환된다(메모리 해제). 이 때, 영상처리 시스템의 특성상 위 과정, 즉 메모리 할당 및 해제 과정이 지속적으로 빈번하게 일어나게 되는데, 이러한 경우 단편화 문제를 수반하게 된다. 여기서, 단편화 문제란 할당하는 메모리 블록의 크기가 불규칙할 경우 시스템이 필요로 하는 메모리 양보다 더 많은 양의 메모리와 CPU 자원을 운영체제가 소모하는 현상을 말한다. In general, the memory to process the data is provided by the memory allocator built in the programming language (memory allocation), and is returned to the allocator when the necessary processing is completed (memory release). In this case, due to the characteristics of the image processing system, the above process, that is, the process of allocating and releasing the memory, is continuously and frequently performed. Here, the fragmentation problem refers to the phenomenon that the operating system consumes more memory and CPU resources than the amount of memory required by the system if the size of the allocated memory block is irregular.

이러한 문제를 해결하기 위하여 잘 알려진 방법으로 메모리 풀(Memory Pool)이 있다. 메모리 풀은 사용할 메모리 블록의 크기를 수 개의 일정한 크기로 미리 정해놓고 사용함으로써 단편화 현상을 회피할 수 있도록 하는 것이다. To solve this problem, there is a well-known memory pool. The memory pool is designed to avoid the fragmentation phenomenon by preliminarily setting the size of a memory block to be used in a predetermined size.

그러나, 영상 데이터는 화질/해상도/압축 방법 등에 따라 그 크기가 천차만별이라 메모리풀을 적용하기가 매우 어렵다는 문제점이 있다.However, there is a problem that it is very difficult to apply the memory pool because the size of the image data varies depending on the image quality / resolution / compression method and the like.

따라서, 메모리 할당과 해제가 비교적 순차적인 특성을 갖는 영상 처리 시스템에서 프로그래밍 언어에 내장된 메모리 할당기가 메모리를 효율적으로 관리하는 방법이 요구된다.Therefore, there is a need for a method for efficient memory management by a memory allocator built in a programming language in an image processing system having a characteristic that memory allocation and release are relatively sequential.

본 발명이 이루고자 하는 기술적 과제는 단편화 현상을 해결함으로써 메모리의 실사용량 예측이 쉽고, 메모리 자원과 CPU 자원을 효율적으로 사용할 수 있는 메모리 할당 방법 및 해제 방법을 포함하는 효율적인 메모리 관리 방법을 제공하는 것이다.An object of the present invention is to provide an efficient memory management method including a memory allocation method and a cancellation method which can easily predict a real capacity of a memory by solving the fragmentation phenomenon, and efficiently use memory resources and CPU resources.

본 발명의 한 특징에 따른 메모리 관리 방법은,According to an aspect of the present invention,

메모리 할당기가 메모리를 관리하는 방법으로서, 응용 프로그램에게 할당할 전체 메모리 블록을 초기화하는 단계; 응용 프로그램으로부터 할당 요청된 블록을 상기 전체 메모리 블록에서 할당하고, 상기 응용 프로그램으로부터 해제 요청된 블록을 상기 전체 메모리 블록에서 회수하는 단계; 및 상기 전체 메모리 블록을 반환하는 단계를 포함하며, 상기 전체 메모리 블록을 헤드 인덱스-여기서 헤드 인덱스는 상기 전체 메모리 블록 중에서 할당된 메모리 블록들 중 상기 전체 메모리 블록의 가장 끝 부분에 위치한 메모리 블록의 다음 블록의 위치를 가리킴-와 테일 인덱스-여기서 테일 인덱스는 상기 전체 메모리 블록 중에서 할당된 메모리 블록들 중 상기 전체 메모리 블록의 가장 처음 부분에 위치한 메모리 블록의 위치를 가리킴-를 사용하여 관리하며, 상기 헤드 인덱스와 테일 인덱스는 상기 전체 메모리 블록의 시작 위치부터 증가하여 상기 전체 메모리 블록의 끝 위치에서 다시 상기 시작 위치로 설정되는 것을 특징으로 한다.CLAIMS What is claimed is: 1. A method for a memory allocator to manage memory, comprising: initializing an entire memory block to be allocated to an application program; Allocating a block requested to be allocated from an application program in the entire memory block and recovering a block requested to be released from the application program in the entire memory block; And returning the entire memory block, wherein the head index of the entire memory block, where the head index is the next memory block located at the end of the entire memory block among the memory blocks allocated among the entire memory blocks, And a tail index, wherein the tail index indicates a position of a memory block located at the beginning of the entire memory block among the memory blocks allocated among the entire memory blocks, The index and the tail index are set to the start position again from the end position of the entire memory block, starting from the start position of the entire memory block.

여기서, 상기 초기화하는 단계는, 프로그래밍 언어 또는 운영체제로부터 상기 전체 메모리 블록을 할당받는 단계; 및 상기 헤드 인덱스와 상기 테일 인덱스를 상기 시작 위치로 설정하는 단계를 포함한다.The initializing may include: allocating the entire memory block from a programming language or an operating system; And setting the head index and the tail index to the start position.

또한, 상기 메모리 할당기는 상기 할당 요청된 블록 할당시 메타 정보를 포함하여 할당하는 것을 특징으로 한다.In addition, the memory allocator may allocate meta information when the block allocation is requested.

또한, 상기 메타 정보는 할당된 블록임을 나타내는 사용중 표식과 할당된 메모리 블록의 크기를 나타내는 정보를 포함하는 것을 특징으로 한다.In addition, the meta information includes a busy mark indicating that the block is allocated and information indicating the size of the allocated memory block.

또한, 상기 사용중 표식은 할당되는 메모리 블록의 첫 번째 바이트에 기재되며, "*"인 것을 특징으로 한다.Also, the in-use mark is written in the first byte of the allocated memory block and is "* ".

또한, 상기 사용중 표식이 '0'으로 기재되는 경우 해당 메모리 블록이 회수된 것을 나타내는 것을 특징으로 한다.In addition, when the in-use mark is written as '0', it indicates that the corresponding memory block is recovered.

또한, 상기 메타 정보 중 할당된 메모리 블록의 크기를 나타내는 정보는 할당된 메모리 블록의 처음 부분과 마지막 부분에 각각 기록되는 것을 특징으로 한다.The information indicating the size of the allocated memory block among the meta information is recorded at the beginning and the end of the allocated memory block, respectively.

또한, 상기 할당 요청된 블록에 대해 상기 헤드 인덱스 이후부터 상기 전체 메모리 블록의 끝 부분까지의 할당 가능한 여유량(이하 "종단 여유량"이라 함)으로 할당이 어려운 경우 상기 종단 여유량에 대해 회수 처리하고, 상기 전체 메모리 블록의 처음 부분부터 할당하는 것을 특징으로 한다.In addition, if it is difficult to allocate an allocation allowable amount (hereinafter referred to as "end spare capacity") from the head index to the end of the entire memory block to the allocation requested block, And allocates the memory block from the beginning of the entire memory block.

또한, 상기 전체 메모리 블록에서 회수하는 단계에서, 상기 헤드 인덱스 이전 위치의 메모리 블록이 회수되는 경우 상기 헤드 인덱스가 회수되는 메모리 블록을 가리키도록 이동되는 것을 특징으로 한다.In addition, in the recovering step in the entire memory block, when the memory block at the position before the head index is retrieved, the head index is moved to point to the memory block from which the head index is retrieved.

또한, 상기 헤드 인덱스 이전에 다수의 회수된 메모리 블록이 존재하는 경우 상기 헤드 인덱스가 상기 다수의 회수된 메모리 블록의 처음 부분의 메모리 블록을 가리키도록 이동되는 것을 특징으로 한다.In addition, when there are a plurality of recovered memory blocks before the head index, the head index is moved to point to the memory block at the beginning of the plurality of retrieved memory blocks.

또한, 상기 전체 메모리 블록에서 회수하는 단계에서, 상기 테일 인덱스의 메모리 블록이 회수되는 경우 상기 테일 인덱스가 회수되는 메모리 블록의 다음 위치의 메모리 블록을 가리키도록 이동되는 것을 특징으로 한다.When the memory block of the tail index is retrieved in the step of recovering in the entire memory block, the tail index is moved to point to a memory block in the next position of the memory block in which the tail index is retrieved.

또한, 상기 테일 인덱스 이후에 다수의 회수된 메모리 블록이 존재하는 경우 상기 테일 인덱스가 상기 다수의 회수된 메모리 블록의 마지막 부분의 메모리 블록 다음의 위치의 메모리 블록을 가리키도록 이동되는 것을 특징으로 한다.If there are a plurality of recovered memory blocks after the tail index, the tail index is moved to point to a memory block next to the memory block at the end of the plurality of retrieved memory blocks .

본 발명의 다른 특징에 따른 메모리 할당 방법은,According to another aspect of the present invention,

메모리 할당기가 메모리를 할당하는 방법으로서, 상기 메모리 할당기는 응용 프로그램에게 할당할 전체 메모리 블록을 헤드 인덱스-여기서 헤드 인덱스는 상기 전체 메모리 블록 중에서 할당된 메모리 블록들 중 상기 전체 메모리 블록의 가장 끝 부분에 위치한 메모리 블록의 다음 블록의 위치를 가리킴-와 테일 인덱스-여기서 테일 인덱스는 상기 전체 메모리 블록 중에서 할당된 메모리 블록들 중 상기 전체 메모리 블록의 가장 처음 부분에 위치한 메모리 블록의 위치를 가리킴-를 사용하여 관리하며, 응용 프로그램으로부터 할당 요청된 블록에 대해 상기 헤드 인덱스 이후부터 상기 전체 메모리 블록의 끝 부분까지의 할당 가능한 여유량(이하 "종단 여유량"이라 함)으로 할당이 가능한지를 판단하는 단계; 상기 할당 요청된 블록에 대해 상기 종단 여유량으로 할당이 가능한 경우, 상기 헤드 인덱스의 위치에 상기 할당 요청된 블록 크기의 메모리 블록을 할당하는 단계; 및 상기 할당 요청된 블록에 대해 상기 종단 여유량으로 할당이 불가능한 경우, 상기 종단 여유량을 회수하는 단계를 포함한다.A method for allocating memory in a memory allocator, the memory allocator allocating a total memory block to be allocated to an application program to a head index, wherein a head index is allocated at the end of the entire memory block among allocated memory blocks in the entire memory block Wherein the tail index indicates a position of a memory block located at an initial portion of the entire memory block among the memory blocks allocated among the entire memory blocks, (Hereinafter referred to as "end spare capacity") from the head index to the end of the entire memory block with respect to a block requested to be allocated from an application program; Allocating a memory block of the requested block size to the position of the head index when the allocation of the block requested by the allocation is possible to the end margin amount; And recovering the end margin if the allocation of the block requested by the allocation to the end margin is impossible.

여기서, 상기 종단 여유량을 회수하는 단계에서, 상기 전체 메모리 블록의 총 여유량에서 상기 종단 여유량을 제외한 나머지 여유량이 상기 할당 요청된 블록을 할당할 수 있는 양이 되는 경우에 상기 종단 여유량을 회수하는 것을 특징으로 한다.Herein, in the step of recovering the end margin amount, when the remaining margin amount excluding the end margin amount in the total margin amount of the entire memory blocks becomes an amount capable of allocating the allocation requested block, the end margin amount is recovered .

또한, 상기 종단 여유량을 회수하는 단계에서, 상기 종단 여유량 회수 후에, 상기 헤드 인덱스를 상기 전체 메모리 블록의 처음 메모리 블록을 가리키도록 이동시키고, 이동된 헤드 인덱스의 위치에 상기 할당 요청된 블록 크기의 메모리 블록을 할당하는 것을 특징으로 한다.In the step of recovering the end margin amount, after the end margin amount recovery, the head index is moved to point to the first memory block of the entire memory block, and the position of the moved head index is shifted And allocating a memory block.

본 발명의 또 다른 특징에 따른 메모리 해제 방법은,According to still another aspect of the present invention,

메모리 할당기가 응용 프로그램에게 할당된 메모리를 해제하는 방법으로서, 상기 메모리 할당기는 응용 프로그램에게 할당할 전체 메모리 블록을 헤드 인덱스-여기서 헤드 인덱스는 상기 전체 메모리 블록 중에서 할당된 메모리 블록들 중 상기 전체 메모리 블록의 가장 끝 부분에 위치한 메모리 블록의 다음 블록의 위치를 가리킴-와 테일 인덱스-여기서 테일 인덱스는 상기 전체 메모리 블록 중에서 할당된 메모리 블록들 중 상기 전체 메모리 블록의 가장 처음 부분에 위치한 메모리 블록의 위치를 가리킴-를 사용하여 관리하며, 상기 응용 프로그램으로부터 메모리 블록의 해제 요청이 있는 경우, 해제 요청된 메모리 블록을 회수하는 단계; 상기에서 회수되는 메모리 블록이 상기 헤드 인덱스의 이전 위치의 메모리 블록인 경우, 상기에서 회수되는 메모리 블록을 가리키도록 상기 헤드 인덱스를 이동시키는 단계; 및 상기에서 회수되는 메모리 블록이 상기 테일 인덱스의 메모리 블록인 경우, 상기에서 회수되는 메모리 블록의 다음 위치의 메모리 블록을 가리키도록 상기 테일 인덱스를 이동시키는 단계를 포함한다.CLAIMS What is claimed is: 1. A method for releasing memory allocated to an application by a memory allocator, the memory allocator comprising: a head index for allocating an entire memory block to be allocated to an application program, And a tail index, wherein the tail index indicates a position of a memory block located at the beginning of the entire memory block among the memory blocks allocated among the entire memory blocks, And if the memory block is requested to be released from the application program, recovering the memory block requested to be released; Moving the head index so as to indicate a memory block recovered in the case where the recovered memory block is a memory block in a previous position of the head index; And moving the tail index to point to a memory block at a next position of the memory block retrieved from the tail index if the memory block recovered in the step is a memory block of the tail index.

여기서, 상기 헤드 인덱스를 이동시키는 단계에서, 상기 헤드 인덱스 이전에 다수의 회수된 메모리 블록이 존재하는 경우 상기 다수의 회수된 메모리 블록의 처음 부분의 메모리 블록을 가리키도록 상기 헤드 인덱스가 이동되는 것을 특징으로 한다.Here, in the step of moving the head index, if there are a plurality of recovered memory blocks before the head index, the head index is moved so as to point to the memory block at the beginning of the plurality of recovered memory blocks .

또한, 상기 테일 인덱스를 이동시키는 단계에서, 상기 테일 인덱스 이후에 다수의 회수된 메모리 블록이 존재하는 경우 상기 다수의 회수된 메모리 블록의 마지막 부분의 메모리 블록 다음 위치의 메모리 블록을 가리키도록 상기 테일 인덱스를 이동시키는 것을 특징으로 한다.In the step of moving the tail indices, if there are a plurality of recovered memory blocks after the tail index, the tail index is moved to the memory block at a position next to the memory block at the end of the plurality of recovered memory blocks. And the index is moved.

본 발명에 따르면, 영상 처리 시스템과 같이 메모리 할당과 해제가 비교적 순차적인 경우, 즉 메모리를 할당하고 일정한 시간 후에 해제할 때 그 순차적인 특성을 이용하여 단편화 현상이 해결된다.According to the present invention, fragmentation phenomenon is solved by using the sequential characteristics when the memory allocation and release are relatively sequential like the image processing system, that is, when the memory is allocated and released after a certain time.

또한, 단편화 현상이 해결되어 메모리의 실사용량 예측이 쉽고, 또한 메모리 자원과 CPU 자원을 효율적으로 사용할 수 있게 된다.In addition, the fragmentation phenomenon is solved, the real capacity of the memory can be predicted easily, and memory resources and CPU resources can be efficiently used.

도 1은 본 발명의 실시예에 따라 메모리 할당기가 사용할 환형 버퍼 형태의 메모리를 개념적으로 도시한 도면이다.
도 2는 본 발명의 실시예에 따른 메모리 관리 방법의 흐름도이다.
도 3은 도 2에 도시된 메모리 초기화 단계의 구체적인 흐름도이다.
도 4는 도 2에 도시된 메모리 할당 및 해제 단계에서 메모리 할당 단계를 구체적으로 설명하는 흐름도이다.
도 5는 본 발명의 실시예에 따라 운용중인 메모리 블록의 상태를 도시한 도면이다.
도 6의 (a)는 본 발명의 실시예에 따라 메모리 블록을 할당하기 전의 메모리를 나타내고, (b)는 300 바이트의 메모리 블록을 할당한 후의 메모리를 나타내는 도면이다.
도 7의 (a)는 본 발명의 실시예에 따라 전체 메모리 블록에서 종단 사용량을 나타낸 도면이고, (b)는 종단 사용량을 회수한 후의 메모리를 나타낸 도면이다.
도 8은 도 2에 도시된 메모리 할당 및 해제 단계에서 메모리 해제 단계를 구체적으로 설명하는 흐름도이다.
도 9의 (a)는 본 발명의 실시예에 따라 300 바이트가 할당된 블록을 포함하는 메모리를 도시한 도면이고, (b)는 할당된 300 바이트의 블록을 해제한 후의 메모리를 도시한 도면이다.
도 10의 (a)는 본 발명의 실시예에서 헤드 인덱스 이전 위치의 메모리 블록이 회수 대상의 메모리 블록임을 나타낸 도면이고, (b)는 헤드 인덱스 이전 위치의 메모리 블록이 회수된 상태를 나타낸 도면이며, (c)는 헤드 인덱스 이전 위치의 메모리 블록의 회수로 인해 헤드 인덱스 위치가 이동된 것을 나타낸 도면이다.
도 11의 (a)는 본 발명의 실시예에서 테일 인덱스의 메모리 블록이 회수 대상의 메모리 블록임을 나타낸 도면이고, (b)는 테일 인덱스의 메모리 블록이 회수된 상태를 나타낸 도면이며, (c)는 테일 인덱스의 메모리 블록의 회수로 인해 테일 인덱스 위치가 이동된 것을 나타낸 도면이다.
1 is a block diagram conceptually illustrating an annular buffer type memory to be used by a memory allocator according to an embodiment of the present invention.
2 is a flowchart of a memory management method according to an embodiment of the present invention.
3 is a specific flowchart of the memory initialization step shown in FIG.
FIG. 4 is a flowchart specifically illustrating a memory allocation step in the memory allocation and release step shown in FIG. 2. FIG.
5 is a diagram illustrating a state of a memory block in operation according to an embodiment of the present invention.
FIG. 6A shows a memory before allocating a memory block according to an embodiment of the present invention, and FIG. 6B shows a memory after allocating a memory block of 300 bytes.
FIG. 7A is a diagram showing end use amounts in an entire memory block according to an embodiment of the present invention, and FIG. 7B is a diagram showing a memory after withdrawing end use amounts.
FIG. 8 is a flowchart specifically illustrating a memory release step in the memory allocation and release step shown in FIG. 2. FIG.
9A is a diagram illustrating a memory including a block allocated with 300 bytes according to an embodiment of the present invention, and FIG. 9B is a diagram showing a memory after releasing an allocated block of 300 bytes .
FIG. 10A is a view showing that a memory block at a position before a head index in the embodiment of the present invention is a memory block to be retrieved, FIG. 10B is a view showing a state in which a memory block at a position before a head index is retrieved , and (c) are views showing the movement of the head index position due to the number of memory blocks in the position before the head index.
FIG. 11A is a diagram showing a memory block of a tail index in the embodiment of the present invention as a memory block to be retrieved, FIG. 11B is a diagram showing a state in which memory blocks of a tail index are retrieved, Is a diagram showing that the tail index position is shifted due to the number of memory blocks of the tail index.

아래에서는 첨부한 도면을 참고로 하여 본 발명의 실시예에 대하여 본 발명이 속하는 기술 분야에서 통상의 지식을 가진 자가 용이하게 실시할 수 있도록 상세히 설명한다. 그러나 본 발명은 여러 가지 상이한 형태로 구현될 수 있으며 여기에서 설명하는 실시예에 한정되지 않는다. 그리고 도면에서 본 발명을 명확하게 설명하기 위해서 설명과 관계없는 부분은 생략하였으며, 명세서 전체를 통하여 유사한 부분에 대해서는 유사한 도면 부호를 붙였다.Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily carry out the present invention. The present invention may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein. In order to clearly illustrate the present invention, parts not related to the description are omitted, and similar parts are denoted by like reference characters throughout the specification.

명세서 전체에서, 어떤 부분이 어떤 구성요소를 "포함"한다고 할 때, 이는 특별히 반대되는 기재가 없는 한 다른 구성요소를 제외하는 것이 아니라 다른 구성요소를 더 포함할 수 있는 것을 의미한다. 또한, 명세서에 기재된 "…부", "…기", "모듈" 등의 용어는 적어도 하나의 기능이나 동작을 처리하는 단위를 의미하며, 이는 하드웨어나 소프트웨어 또는 하드웨어 및 소프트웨어의 결합으로 구현될 수 있다.Throughout the specification, when an element is referred to as "comprising ", it means that it can include other elements as well, without excluding other elements unless specifically stated otherwise. Also, the terms " part, "" module," and " module ", etc. in the specification mean a unit for processing at least one function or operation and may be implemented by hardware or software or a combination of hardware and software have.

이제 도면을 참고하여 본 발명의 실시예에 따른 메모리 관리 방법에 대해 상세하게 설명한다.Now, a memory management method according to an embodiment of the present invention will be described in detail with reference to the drawings.

먼저, 본 발명의 실시예에서 메모리 할당기가 사용할 메모리는 첨부한 도 1에 도시된 바와 같이, 환형 버퍼(circular buffer) 형태로 관리된다. 즉, 메모리 할당기가 사용할 전체 메모리 블록의 크기가 N바이트인 경우 N바이트의 전체 메모리 블록이 2개의 포인터, 즉 헤드(head) 인덱스와 테일(tail) 인덱스를 사용하여 관리된다. 여기서, 헤드 인덱스는 사용중인 메모리의 가장 앞을 가리키고, 테일 인덱스는 사용중인 메모리의 가장 뒤를 가리킨다. 즉, 헤드 인덱스부터 전체 메모리 블록의 끝 부분까지와, 테일 인덱스 이전부터 전체 메모리 블록의 시작 부분까지는 사용중인 메모리 블록이 없는 것을 의미한다. 따라서, 테일 인덱스는 헤드 인덱스보다 앞의 메모리를 가리킬 수 없게 된다. 전체 메모리 블록의 크기가 N바이트인 경우 헤드 인덱스와 테일 인덱스는 0부터 N-1까지의 값을 가질 수 있으며, N-1 다음의 메모리 블록을 가리켜야 하는 경우에는 다시 0부터 시작하여 다시 증가하게 된다.First, the memory used by the memory allocator in the embodiment of the present invention is managed in the form of a circular buffer, as shown in FIG. That is, if the size of the entire memory block to be used by the memory allocator is N bytes, the entire memory block of N bytes is managed using two pointers, that is, a head index and a tail index. Here, the head index points to the front of the memory in use, and the tail index points to the end of the memory in use. That is, from the head index to the end of the entire memory block, and from the tail index to the beginning of the entire memory block, there is no memory block in use. Thus, the tail index can not point to memory ahead of the head index. If the size of the entire memory block is N bytes, the head index and the tail index may have a value from 0 to N-1. If the size of the memory block is N-1, do.

도 2는 본 발명의 실시예에 따른 메모리 관리 방법의 흐름도이다.2 is a flowchart of a memory management method according to an embodiment of the present invention.

도 2를 참조하면, 영상 처리 시스템 가동시 메모리 할당기는 프로그래밍 언어 또는 운영체제로부터 사용할 전체 메모리 블록을 할당받는 경우 해당 메모리에 대해 초기화를 수행한다(S100).Referring to FIG. 2, when the image processing system is activated, the memory allocator initializes the memory when all memory blocks to be used by the programming language or the operating system are allocated (S100).

그 후, 메모리 할당기는 전체 메모리 블록에 대해 응용 프로그램으로부터의 요구에 따라 메모리 블록의 할당 및 해제를 수행하여 메모리에 대한 관리를 수행한다(S200).Thereafter, the memory allocator allocates and releases the memory blocks according to the request from the application program for the entire memory blocks to perform management for the memory (S200).

그리고, 메모리 할당기는 프로그래밍 언어 또는 운영체제의 종료시에 사용중인 전체 메모리 블록을 반환한다(S300).The memory allocator then returns the entire memory block being used at the end of the programming language or operating system (S300).

도 3은 도 2에 도시된 메모리 초기화 단계의 구체적인 흐름도이다.3 is a specific flowchart of the memory initialization step shown in FIG.

도 3을 참조하면, 메모리 할당기가 사용할 전체 메모리 블록을 프로그래밍 언어 또는 운영체제로부터 할당받으면(S110), 메모리 할당기는 할당받은 전체 메모리 블록을 관리하는데 사용되는 헤드 인덱스와 테일 인덱스를 0으로 설정하여 초기화를 수행한다(S120). Referring to FIG. 3, when the entire memory block to be used by the memory allocator is allocated from the programming language or the operating system (S110), the memory allocator sets the head index and the tail index used for managing the allocated memory blocks to 0, (S120).

한편, 본 발명의 실시예에 따른 메모리 할당기의 메모리 관리 방법은 프로그래밍 언어, 예를 들어 C 프로그래밍 언어로 나타낼 수 있다.Meanwhile, the memory management method of the memory allocator according to the embodiment of the present invention can be expressed in a programming language, for example, a C programming language.

도 3에서와 같은 메모리 초기화를 위해 메모리 할당기에서 필요한 기본 변수들은 다음과 같다.3, the basic parameters necessary for the memory allocator to initialize the memory are as follows.

Figure 112012036421216-pat00001
Figure 112012036421216-pat00001

여기서, mq_memoryq는 C 프로그래밍언어로부터 메모리 할당기가 사용할 전체 메모리 블록을 할당받아서 저장해 놓을 변수이고, mq_capacity는 메모리 할당기가 사용할 전체 메모리 블록의 크기이다.Here, mq_memoryq is a variable to be allocated and stored in the C programming language for the entire memory block to be used by the memory allocator, and mq_capacity is the size of the entire memory block to be used by the memory allocator.

mq_head, mq_tail는 상기한 헤드 인덱스와 테일 인덱스를 나타낸다. mq_head and mq_tail represent the above head index and tail index.

mq_size는 메모리 할당기의 사용량과 여유량을 계산하기 위해 사용되는 변수이다.mq_size is a variable used to calculate the memory allocator usage and free space.

mq_mark와 mq_mark_int는 할당된 메모리 블록에 기록하는 표식이다.mq_mark and mq_mark_int are markers that write to allocated memory blocks.

한편, 본 발명의 실시예에서 각각의 메모리 블록의 시작과 끝에는 각 블록에 대한 정보가 기록된다. 이러한 정보는 메타 정보라고 한다. 메타 정보는 응용 프로그램에 할당되어 사용중임을 나타내는 사용중 표식, 예를 들어 '*'와 각 메모리 블록의 크기로 이루어진다. 메타 정보로는 메모리 블록 시작 부분의 4바이트와 끝 부분의 4바이트를 합하여 총 8바이트가 사용된다. 따라서, 각 메모리 블록의 크기는 응용 프로그램이 요청한 메모리 블록의 크기에 추가로 메타 정보를 기록하기 위한 8바이트를 더한 값이 된다. 상기에서 _metasize는 메타 정보의 크기인 상수 8이고, _metaoffset은 _metasize의 절반인 상수 4이다.In the embodiment of the present invention, information on each block is recorded at the start and end of each memory block. This information is called meta information. The meta information includes an in-use indicator indicating that the application program is allocated and used, for example, '*' and the size of each memory block. In the meta information, a total of 8 bytes are used, which is the sum of 4 bytes at the beginning of the memory block and 4 bytes at the end. Therefore, the size of each memory block is the size of the memory block requested by the application program plus 8 bytes for recording the meta information. In the above, _metasize is a constant 8 which is the size of meta information, and _metaoffset is a constant 4 which is half of _metasize.

메모리 할당기는 응용 프로그램이 시작된 직후에 한 번 초기화 해 주어야 하며, 이러한 초기화 과정은 다음과 같이 C 프로그래밍 언어로 표현될 수 있다.The memory allocator must be initialized once the application is started, and this initialization process can be expressed in the C programming language as follows.

Figure 112012036421216-pat00002
Figure 112012036421216-pat00002

이러한 초기화를 수행하고 난 후의 메모리의 개념적인 모습은 도 1과 같다. 헤드 인덱스와 테일 인덱스는 시작을 뜻하는 0으로 초기화되고, 메모리 할당기는 C 프로그래밍 언어로부터 응용 프로그램이 사용할 N 바이트 크기의 메모리 블록을 확보한다.A conceptual view of the memory after performing this initialization is shown in FIG. The head index and the tail index are initialized to zero, which means start, and the memory allocator obtains N bytes of memory blocks to be used by the application from the C programming language.

이 후 응용 프로그램은 작업을 수행하면서 수시로 메모리 할당기에게 메모리 블록의 할당과 해제를 요청한다.After that, the application program requests the memory allocator to allocate and release the memory block from time to time while performing the operation.

도 4는 도 2에 도시된 메모리 할당 및 해제 단계에서 메모리 할당 단계를 구체적으로 설명하는 흐름도이다.FIG. 4 is a flowchart specifically illustrating a memory allocation step in the memory allocation and release step shown in FIG. 2. FIG.

도 4를 참조하면, 먼저, 메모리 할당기는 응용 프로그램으로부터 할당 요청된 블록 크기가 메모리의 여유량 이상인지를 판단한다(S210). 즉, 메모리 블록 중에서 할당이 가능한 여유량의 메모리 블록이 있는지가 판단되는 것이다. Referring to FIG. 4, the memory allocator determines whether the block size requested by the application program is equal to or greater than the available memory space (S210). That is, it is judged whether or not there is a memory block having an allowable amount of allocation among the memory blocks.

상기 단계(S210)에서 만약 할당 요청된 블록 크기가 메모리 여유량 이상인 경우 메모리 할당이 불가능하므로 메모리 할당기는 응용 프로그램에게 할당 실패를 알린다(S211).If it is determined in step S210 that the requested block size is equal to or larger than the amount of memory available, the memory allocator can not allocate memory.

그러나, 상기 단계(S210)에서 할당 요청된 블록 크기가 메모리 여유량보다 작은 경우에는 메모리 할당이 가능하므로, 메모리 할당기는 헤드 인덱스가 가리키는 메모리 블록에서 전체 메모리 블록의 끝 부분까지 남은 여유량의 메모리 블록(이하 "종단 여유량"이라 함)으로 할당 가능한지를 판단한다(S212). 즉, 메모리 할당기는 헤드 인덱스에 할당 요청된 블록 크기를 더하고, 여기에 메타 정보 크기를 더한 값이 전체 메모리 블록의 끝 부분보다 큰 지를 판단한다.However, if the block size requested in the above step S210 is smaller than the memory allowance, the memory allocator can allocate the remaining memory blocks from the memory block indicated by the head index to the end of the entire memory block Quot; end margin amount ") (S212). That is, the memory allocator adds the block size requested to be allocated to the head index, and determines whether the value obtained by adding the meta information size to the head index is greater than the end of the entire memory block.

만약 헤드 인덱스, 할당 요청된 블록 크기 및 메타 정보 크기를 더한 값이 전체 메모리 블록의 끝 부분보다 크지 않다면, 즉 종단 여유량으로 할당 가능하다면, 메모리 할당기는 헤드 인덱스가 가리키는 메모리 블록부터 시작해서 할당 요청된 블록을 응용 프로그램에게 할당한다(S213). If the sum of the head index, the allocation requested block size, and the meta information size is not larger than the end of the entire memory block, that is, the end allocation, the memory allocator starts from the memory block indicated by the head index, The block is allocated to the application program (S213).

이하에서는 상기 단계(S213)에서의 메모리 할당에 대해 도면을 참조하여 설명한다.Hereinafter, the memory allocation in step S213 will be described with reference to the drawings.

도 5는 운용중인 메모리 블록의 상태를 도시한 도면이다. 5 is a diagram showing a state of a memory block in operation.

도 5를 참조하면, 내부가 채워져 있는 블록은 응용 프로그램에 할당된 블록이고, 그렇지 않고 내부가 비워져 있는 블록은 응용 프로그램에 할당되지 않은 여유량의 블록이며, 사선이 그려진 블록은 응용 프로그램이 할당받은 블록을 해제한 블록이다. 여기서 해제된 블록은 메모리 할당기가 회수한 블록과 동일한 의미를 갖는다. Referring to FIG. 5, a block filled with an inner program is a block allocated to an application program. Otherwise, a block in which an inner program is empty is an unallocated block that is not allocated to an application program. . Here, the released block has the same meaning as the block retrieved by the memory allocator.

도 5에서 원으로 표시한 부분, 즉 헤드 인덱스가 가리키고 있는 메모리 블록을 확대하여 나타낸 도면이 도 6이다. FIG. 6 is an enlarged view of a portion indicated by a circle in FIG. 5, that is, a memory block indicated by the head index.

도 6의 (a)를 참조하면, 메모리 블록 중에서 응용 프로그램에 할당된 마지막 블록은 400 바이트를 할당한 블록으로, 이 메모리 블록의 다음 메모리 블록을 헤드 인덱스가 가리키고 있다.Referring to FIG. 6A, the last block allocated to the application program among the memory blocks is a block to which 400 bytes are allocated, and the head index indicates the next memory block of the memory block.

이러한 상태에서, 응용 프로그램으로부터 예를 들어 292 바이트의 메모리 블록의 할당 요청을 받으면, 첨부한 도 6의 (b)에 도시된 바와 같이 요청한 292 바이트에 메타 정보 크기 8 바이트를 더한 300 바이트의 메모리 블록을 할당한다. 이 때, 할당 요청받은 292 바이트에 메타 정보 크기 8을 더한 300 바이트의 메모리 블록에 대해 헤드 인덱스 이후의 메모리 블록으로 할당 가능한 경우이므로 이와 같이 할당 과정이 수행되는 것이다.In this state, when a request for allocation of a memory block of, for example, 292 bytes is received from an application program, a memory block of 300 bytes including the meta information size 8 bytes added to the requested 292 bytes as shown in FIG. 6 (b) . In this case, since the memory block after the head index can be allocated to the memory block of 300 bytes which is added with the meta information size 8 to the 292 bytes which are requested to be allocated, the allocation process is performed as described above.

도 6의 (b)를 참조하면, 할당된 블록의 첫 번째 바이트에는 할당되어 사용중임을 나타내는 사용중 표식, 즉 '*'이 쓰여지고 다음 3 바이트에 메모리 블록의 크기인 300 바이트가 16진수인 0x012c로 쓰여진다. 그리고, 할당된 블록의 끝 4 바이트에는 역시 블록의 크기인 0x0012c가 쓰여진다.Referring to FIG. 6 (b), a busy mark, i.e., '*', is assigned to the first byte of the allocated block to indicate that it is in use, and 300 bytes, which is the size of the memory block, is written in 0x012c, which is hexadecimal . The size of the block, 0x0012c, is also written in the last 4 bytes of the allocated block.

그 후, 헤드 인덱스는 할당된 300 바이트만큼 증가되어 할당된 300 바이트의 메모리 블록 다음의 메모리 블록을 가리킨다(S214). 그리고, 메모리 할당기는 응용 프로그램에게 할당된 블록 위치를 반환해 줌으로써 응용 프로그램이 할당된 메모리를 사용하여 작업을 수행할 수 있도록 한다(S215).Thereafter, the head index is increased by the allocated 300 bytes to indicate the memory block next to the allocated 300 bytes of the memory block (S214). Then, the memory allocator returns the block position allocated to the application program so that the application program can perform the operation using the allocated memory (S215).

이와 같이 하여 종단 여유량으로 할당 가능한 경우에 있어서의 메모리 할당이 완료된다.In this manner, the memory allocation in the case where the allocation can be made to the end margin amount is completed.

한편, 상기 단계(S212)에서 헤드 인덱스, 할당 요청된 블록 크기 및 메타 정보 크기를 더한 값이 전체 메모리 블록의 끝 부분보다 크다면, 즉 종단 여유량으로 할당이 불가능하다면, 메모리 할당기는 종단 여유량을 제외하고 전체 메모리 블록에서의 여유량이 할당 요청된 블록을 할당할 수 있는 여유량이 되는지를 판단한다(S216). 이를 위해, 메모리 할당기는 종단 여유량과 할당 요청된 블록 크기를 더한 값이 메모리의 여유량 이상인지를 판단한다.If the sum of the head index, the block size requested by the allocation request, and the meta information size is larger than the end of the entire memory block, that is, the allocation can not be performed as the end spare capacity, the memory allocator excludes the end spare capacity And determines whether or not the amount of spare space in the entire memory block is an amount of spare space for allocating the allocation requested block (S216). To this end, the memory allocator determines whether the value obtained by adding the end margin amount and the block size requested to be allocated is equal to or greater than the margin amount of the memory.

만약 종단 여유량과 할당 요청된 블록 크기를 더한 값이 메모리의 전체 여유량 이상인 경우, 즉 종단 여유량을 제외하고 전체 메모리 블록에서의 여유량이 할당 요청된 블록을 할당할 수 있는 여유량이 안되므로 메모리 할당기는 응용 프로그램에게 할당 실패를 알린다(S211).If the sum of the end margin amount and the allocation requested block size is equal to or more than the total margin amount of the memory, that is, the margin amount in the entire memory block is not sufficient to allocate the allocated allocation block, (S211).

그러나, 상기 단계(S216)에서 종단 여유량과 할당 요청된 블록 크기를 더한 값이 메모리의 전체 여유량보다 작은 경우, 즉 종단 여유량을 제외하고 전체 메모리 블록에서의 여유량이 할당 요청된 블록을 할당할 수 있는 여유량이 되는 경우, 메모리 할당기는 할당 요청된 블록을 할당할 수 없는 종단 여유량의 메모리 블록을 회수하고(S217), 헤드 인덱스를 0으로 설정한다(S218). 즉 헤드 인덱스 위치에서 전체 메모리 블록의 끝 부분까지 남은 메모리 블록을 할당하지 않고 회수 처리한 후 전체 메모리 블록의 처음 부분부터 할당을 위해 헤드 인덱스를 0으로 설정하는 것이다.However, if it is determined in step S216 that the value obtained by adding the end margin amount and the allocation requested block size is less than the total margin amount of the memory, that is, excluding the end margin amount, If there is a spare capacity, the memory allocator retrieves a memory block of an end margin amount that can not allocate the allocation requested block (S217), and sets the head index to 0 (S218). That is, after the memory block remaining from the head index position to the end of the entire memory block is not allocated, the head index is set to 0 for allocation from the beginning of the entire memory block.

이하에서는 상기 단계(S217)에서의 메모리 회수에 대해 도면을 참조하여 설명한다.Hereinafter, the memory number in the step S217 will be described with reference to the drawings.

도 7은 본 발명의 실시예에서 전체 메모리 블록의 끝 부분에서 할당 요청되었을 때의 메모리 상태를 도시한 도면이다.7 is a diagram illustrating a memory state when allocation is requested at the end of an entire memory block in the embodiment of the present invention.

도 7의 (a)를 참조하면, 전체 메모리 블록의 끝 부분에서 할당 가능한 종단 여유량이 20 바이트 남아 있으며, 헤드 인덱스가 해당 위치를 가리키고 있다. 한편, 전체 메모리 블록의 최단에는 항상 최하 메타 정보 크기의 회수된 메모리 블록, 즉 8 바이트의 메모리 블록이 있도록 설정된다.Referring to (a) of FIG. 7, 20 bytes of the end margin that can be allocated at the end of the entire memory block are left, and the head index indicates the corresponding position. On the other hand, at the shortest end of the entire memory block, the memory block having the lowest meta information size is always set, that is, an 8-byte memory block.

따라서, 응용 프로그램이 4 바이트 이하의 메모리 블록을 요청하면, 종단 여유량으로 할당 가능하므로 8 내지 12 바이트의 메모리 블록을 할당하고 8 바이트의 회수된 메모리 블록 1개를 끝에 채울 수 있지만, 4 바이트를 초과하는 블록의 할당 요청이 있으면 종단 여유량으로 할당이 불가능하게 된다. 따라서, 메모리 할당기는 첨부한 도 7의 (b)에 도시된 바와 같이 남은 20 바이트를 회수된 메모리 블록으로 채우게 된다. 그리고, 헤드 인덱스는 0으로 설정한다.Therefore, if an application requests 4 bytes or less of memory blocks, 8 to 12 bytes of memory blocks can be allocated and one 8-byte recovered memory block can be filled at the end, since more than 4 bytes can be allocated. If there is a block allocation request, allocation to the end redundancy amount becomes impossible. Thus, the memory allocator fills the remaining 20 bytes with the retrieved memory block as shown in Figure 7 (b). The head index is set to zero.

그 후, 헤드 인덱스가 0이 되고 남은 여유량의 메모리 블록이 할당 가능하므로, 메모리 할당기는 헤드 인덱스가 가리키는 메모리 블록부터 시작해서 할당 요청된 블록을 응용 프로그램에게 할당하고(S213), 헤드 인덱스를 할당된 메모리 블록만큼 증가시킨 후(S214), 응용 프로그램에게 할당된 블록 위치를 반환해준다(S215).Since the head index is 0 and the remaining spare memory block can be allocated, the memory allocator allocates the allocation requested block to the application program starting from the memory block indicated by the head index (S213), and allocates the head index (S214), and returns the block position allocated to the application program (S215).

이와 같이, 본 발명의 실시예에서는 헤드 위치에서 종단 사용량이 할당 요청된 블록을 할당할 정도의 용량이 안되는 경우 해당 종단 사용량을 회수 처리 함으로써 단편화 문제가 감소된다.As described above, in the embodiment of the present invention, when the terminal usage amount is not enough to allocate the blocks requested to be allocated at the head position, the terminal usage amount is recovered and the fragmentation problem is reduced.

다음은 도 4에 도시된 메모리 할당 방법을 C 프로그래밍 언어로 표현한 일 예를 나타낸다.The following is an example of the memory allocation method shown in FIG. 4 expressed in C programming language.

Figure 112012036421216-pat00003
Figure 112012036421216-pat00003

도 8은 도 2에 도시된 메모리 할당 및 해제 단계에서 메모리 해제 단계를 구체적으로 설명하는 흐름도이다.FIG. 8 is a flowchart specifically illustrating a memory release step in the memory allocation and release step shown in FIG. 2. FIG.

도 8을 참조하면, 먼저 메모리 할당기는 응용 프로그램에게 할당되어 사용중인 메모리가 있는지를 확인하기 위해 사용량이 0보다 큰지를 판단한다(S220).Referring to FIG. 8, in step S220, the memory allocator determines whether the usage amount is greater than 0 in order to check whether there is an active memory allocated to an application program.

상기 단계(S220)에서 만약 사용량이 0인 경우에는 사용중인 메모리가 없으므로 메모리 해제를 수행할 수 없으므로 메모리 할당기는 응용 프로그램에게 해제 실패를 알린다(S221).If the used amount is 0 in step S220, the memory allocator can not perform the memory release because there is no memory in use, so that the memory allocator notifies the application program of the release failure (S221).

그런, 상기 단계(S220)에서 사용량이 0보다 커서 응용 프로그램에게 할당되어 사용중인 메모리가 있는 것으로 판단되면, 응용 프로그램에 의해 해제 요청된 메모리 블록이 할당된 메모리 블록인지를 판단한다(S222).If it is determined in step S220 that the amount of usage is greater than 0 and the memory is allocated to the application program and there is an in-use memory, it is determined whether the memory block allocated by the application program is a memory block allocated in operation S222.

만약 해제 요청된 메모리 블록이 할당된 메모리 블록이 아닌 경우, 즉 할당되지 않은 여유량의 메모리 블록이라면, 메모리 할당기는 이에 대해서도 응용 프로그램에게 해제 실패를 알린다(S221).If the memory block requested to be released is not a memory block to which the allocated memory block is allocated, that is, if the memory block is not allocated, the memory allocator notifies the application program of the release failure (S221).

그러나, 해제 요청된 메모리 블록이 할당된 메모리 블록인 경우, 메모리 할당기는 해제 요청된 메모리 블록을 회수 처리한다(S223).However, if the released memory block is the allocated memory block, the memory allocator reclaims the memory block requested to be released (S223).

이하에서는 상기 단계(S223)에서의 메모리 회수에 대해 도면을 참조하여 설명한다.Hereinafter, the memory recall in step S223 will be described with reference to the drawings.

도 9는 본 발명의 실시예에서 해제 요청된 블록을 포함하는 메모리 상태를 도시한 도면이다.9 is a diagram showing a memory state including blocks requested to be released in an embodiment of the present invention.

도 9의 (a)를 참조하면, 전체 메모리 블록에서 도 6의 (b)에서 응용 프로그램에게 할당된 300 바이트의 메모리 블록이 응용 프로그램으로부터 해제 요청된 상태이다.Referring to FIG. 9A, the memory block of 300 bytes allocated to the application program in the entire memory block is requested to be released from the application program in FIG. 6B.

메모리 할당기는 해제 요청된 메모리 블록이 응용 프로그램에게 할당된 메모리 블록이므로, 도 9의 (b)에 도시된 바와 같이, 해제 요청된 메모리 블록의 첫 번째 바이트에 회수되었음을 나타내는 0을 기록함으로써 회수 처리하여 해당 메모리 블록에 대한 해제 처리를 완료한다.Since the memory allocator is a memory block allocated to the application program by the memory block requested to be released, the memory allocator is recovered by writing 0 indicating that the first byte of the memory block requested to be released has been recovered as shown in FIG. 9 (b) And completes the releasing process for the memory block.

여기서, 해제 요청된 메모리 블록이 사용중인 메모리 블록들 사이에 위치하므로 헤드 인덱스 및 테일 인덱스의 변동은 없게 된다.Here, since the memory block requested to be released is located between the in-use memory blocks, there is no variation in the head index and the tail index.

그 후, 응용 프로그램에게 할당되어 사용중인 메모리 블록(사용량)이 있고 상기 단계(S223)에서 회수된 메모리 블록이 헤드 인덱스 이전 위치의 메모리 블록인지의 여부가 판단된다(S224).Thereafter, it is judged whether or not the memory block allocated to the application program is in use and the memory block recovered in the step S223 is a memory block before the head index (S224).

만약 사용량이 있고, 즉 사용량이 0보다 크고 회수된 메모리 블록이 헤드 인덱스 이전 위치의 메모리 블록인 경우 헤드 인덱스를 이전 위치의 메모리 블록을 가리키도록 그 값을 치환한다(S225). 여기서, 상기 단계(S224, S225)가 반복되어 헤드 인덱스 이전 위치의 메모리 블록이 회수된 메모리 블록이 아닐 때까지, 즉 사용중인 메모리 블록일 때까지 반복된다. 첨부한 도 10이 이를 나타낸다. If the used memory block is larger than 0 and the recovered memory block is a memory block located before the head index, the value of the head index is replaced to indicate the memory block at the previous position (S225). Here, steps S224 and S225 are repeated until the memory block at the position before the head index is not the recovered memory block, that is, until it is the in-use memory block. This is illustrated in FIG.

도 10의 (a)는 본 발명의 실시예에서 헤드 인덱스 이전 위치의 메모리 블록이 회수 대상의 메모리 블록임을 나타낸 도면이고, (b)는 헤드 인덱스 이전 위치의 메모리 블록이 회수된 상태를 나타낸 도면이며, (c)는 헤드 인덱스 이전 위치의 메모리 블록의 회수로 인해 헤드 인덱스 위치가 이동된 것을 나타낸 도면이다. 도 10의 (b)를 참조하면, 헤드 인덱스 이전 위치의 메모리 블록이 회수됨으로써 그 이전의 여러 개의 메모리 블록이 연속적으로 회수된 메모리 블록이 된다. 따라서, 상기 단계(S224, S225)의 반복 수행에 의해 도 10의 (c)와 같이 헤드 인덱스는 연속적으로 회수된 메모리 블록을 모두 지나쳐서 사용중인 메모리 블록 앞의 위치를 가리키도록 이동됨으로써 연속적으로 회수된 메모리 블록이 할당 가능한 사용량으로 편입되게 된다.FIG. 10A is a view showing that a memory block at a position before a head index in the embodiment of the present invention is a memory block to be retrieved, FIG. 10B is a view showing a state in which a memory block at a position before a head index is retrieved , and (c) are views showing the movement of the head index position due to the number of memory blocks in the position before the head index. Referring to FIG. 10B, a memory block at a position before the head index is retrieved, so that a plurality of previous memory blocks become consecutively recovered memory blocks. Therefore, by repeating the above steps (S224, S225), the head index passes all the memory blocks continuously retrieved and is moved to point to the position in front of the memory block in use as shown in FIG. 10 (c) The allocated memory block is incorporated into the allocable usage amount.

이와 같이, 헤드 인덱스 이전 위치의 메모리 블록이 회수된 메모리 블록인 경우 그 이전 위치의 메모리 블록이 할당 가능한 메모리 블록이 되도록 헤드 인덱스를 이동함으로써 메모리의 단편화가 감소된다.Thus, if the memory block at the position before the head index is the recovered memory block, the memory fragmentation is reduced by moving the head index so that the memory block at the previous position becomes the allocatable memory block.

다음, 상기 단계(S224)에서 사용량이 없거나 또는 사용량이 0보다 크지만 헤드 인덱스 이전 위치의 메모리 블록이 회수된 메모리 블록이 아닌 경우, 메모리 할당기는 테일 인덱스의 이동을 위해 다시 할당기의 사용량이 0보다 크고 테일 인덱스 위치의 메모리 블록이 회수된 메모리 블록인지를 판단한다(S226).Next, if the amount of memory used in step S224 is less than or equal to 0, but the memory block in the previous position is not the recovered memory block, the memory allocator allocates 0 It is determined whether the memory block having the larger tail index position is the recovered memory block (S226).

만약 사용량이 있고, 헤드 인덱스의 메모리 블록이 회수된 메모리 블록인 경우 메모리 할당기는 테일 인덱스를 다음 메모리 블록으로 치환한다(S227). 여기서, 상기 단계(S226, S226)가 반복되어 테일 인덱스의 메모리 블록이 회수된 메모리 블록이 아닐 때까지, 즉 사용중인 메모리 블록일 때까지 반복된다. 첨부한 도 11이 이를 나타낸다.If there is a usage and the memory block of the head index is the retrieved memory block, the memory allocator replaces the tail index with the next memory block (S227). Here, the steps (S226, S226) are repeated until the memory block of the tail index is not the recovered memory block, that is, until it is the in-use memory block. This is illustrated by the accompanying Fig.

도 11의 (a)는 본 발명의 실시예에서 테일 인덱스의 메모리 블록이 회수 대상의 메모리 블록임을 나타낸 도면이고, (b)는 테일 인덱스의 메모리 블록이 회수된 상태를 나타낸 도면이며, (c)는 테일 인덱스의 메모리 블록의 회수로 인해 테일 인덱스 위치가 이동된 것을 나타낸 도면이다. 도 11의 (b)를 참조하면, 테일 인덱스의 메모리 블록이 회수됨으로써 그 앞의 여러 개의 메모리 블록이 연속적으로 회수된 메모리 블록이 된다. 따라서, 상기 단계(S226, S227)의 반복 수행에 의해 도 11의 (c)와 같이 테일 인덱스는 연속적으로 회수된 메모리 블록을 모두 지나쳐서 사용중인 메모리 블록을 가리키도록 이동됨으로써 연속적으로 회수된 메모리 블록이 할당 가능한 사용량으로 편입되게 된다.FIG. 11A is a diagram showing a memory block of a tail index in the embodiment of the present invention as a memory block to be retrieved, FIG. 11B is a diagram showing a state in which memory blocks of a tail index are retrieved, Is a diagram showing that the tail index position is shifted due to the number of memory blocks of the tail index. Referring to FIG. 11B, the memory block of the tail index is retrieved, and thus the memory blocks preceding the several memory blocks are consecutively recovered. 11C, the tail index is shifted to point to the memory block in use by passing all the memory blocks continuously recovered, and thus the memory block is continuously recovered. As a result, Is incorporated into the allocable usage amount.

이와 같이, 테일 인덱스의 메모리 블록이 회수된 메모리 블록인 경우 그 다음의 메모리 블록이 할당 가능한 메모리 블록이 되도록 테일 인덱스를 이동함으로써 메모리의 단편화가 감소된다.In this manner, if the memory block of the tail index is a retrieved memory block, memory fragmentation is reduced by moving the tail index so that the next memory block is an allocatable memory block.

다음은 도 8에 도시된 메모리 헤제 방법을 C 프로그래밍 언어로 표현한 일 예를 나타낸다.The following is an example of the memory heap method shown in FIG. 8 expressed in C programming language.

Figure 112012036421216-pat00004
Figure 112012036421216-pat00004

상기에서 리틀 엔디언(little-endian)이 사용되는 경우에는 *(cptr-1) = 0 으로 대체되어야 한다.If little-endian is used in the above, it should be replaced with * (cptr-1) = 0.

그리고, 상기에서 mq_notuse(index)는 다음과 같이 간단히 구현될 수 있다.In the above, the mq_notuse (index) can be simply implemented as follows.

빅 엔디언(big-endian)의 경우: !*(mq_memoryq + index)For big-endian:! * (Mq_memoryq + index)

리틀 엔디언의 경우 :!*(mq_memoryq + index +3)
For Little Endian:! * (Mq_memoryq + index +3)

그리고, 상기에서 mq_ndsize(index)는 다음과 같이 구현될 수 있다.In the above, mq_ndsize (index) can be implemented as follows.

int *iptr = (int*) (mq_memoryq+ index);int * iptr = (int *) (mq_memoryq + index);

return *iptr & 0x00ffffff;
return * iptr &0x00ffffff;

또한, 함수 mq_prev(index)와 mq_next(index)는 각각 다음과 같이 구현될 수 있다.The functions mq_prev (index) and mq_next (index) can be implemented as follows.

Figure 112012036421216-pat00005
Figure 112012036421216-pat00005

Figure 112012036421216-pat00006
Figure 112012036421216-pat00006

한편, 상기에서는 본 발명의 실시예에서의 메모리 할당 및 해제 방법에 대해 C 프로그래밍 언어를 사용하여 나타내었지만 이는 하나의 예에 해당될 뿐, 다른 방식을 통해서도 구현 가능하며, 또한 다른 프로그래밍 언어를 사용하여서도 구현 가능하다.In the above description, the memory allocation and release method in the embodiment of the present invention has been described using the C programming language. However, the present invention is not limited to this example, and it can be realized by other methods, Can also be implemented.

이상에서 본 발명의 실시예에 대하여 상세하게 설명하였지만 본 발명의 권리범위는 이에 한정되는 것은 아니고 다음의 청구범위에서 정의하고 있는 본 발명의 기본 개념을 이용한 당업자의 여러 변형 및 개량 형태 또한 본 발명의 권리범위에 속하는 것이다.While the present invention has been particularly shown and described with reference to exemplary embodiments thereof, it is to be understood that the invention is not limited to the disclosed exemplary embodiments, It belongs to the scope of right.

Claims (15)

메모리 할당기가 메모리를 관리하는 방법에 있어서,
응용 프로그램에게 할당할 전체 메모리 블록을 초기화하는 단계;
응용 프로그램으로부터 할당 요청된 블록을 상기 전체 메모리 블록에서 할당하고, 상기 응용 프로그램으로부터 해제 요청된 블록을 상기 전체 메모리 블록에서 회수하는 단계; 및
상기 전체 메모리 블록을 반환하는 단계를 포함하며,
상기 전체 메모리 블록을 헤드 인덱스-여기서 헤드 인덱스는 상기 전체 메모리 블록 중에서 할당된 메모리 블록들 중 상기 전체 메모리 블록의 가장 끝 부분에 위치한 메모리 블록의 다음 블록의 위치를 가리킴-와 테일 인덱스-여기서 테일 인덱스는 상기 전체 메모리 블록 중에서 할당된 메모리 블록들 중 상기 전체 메모리 블록의 가장 처음 부분에 위치한 메모리 블록의 위치를 가리킴-를 사용하여 관리하며, 상기 헤드 인덱스와 테일 인덱스는 상기 전체 메모리 블록의 시작 위치부터 증가하여 상기 전체 메모리 블록의 끝 위치에서 다시 상기 시작 위치로 설정되고,
상기 회수하는 단계에서, 회수되는 메모리 블록이 상기 헤드 인덱스의 메모리 블록의 이전 위치의 메모리 블록인 경우에는 상기 헤드 인덱스가 변경되고, 상기 테일 인덱스의 메모리 블록인 경우에는 상기 테일 인덱스가 변경되며, 상기 헤드 인덱스의 메모리 블록의 이전 위치의 메모리 블록과 상기 테일 인덱스의 메모리 블록이 아닌 경우에는 상기 헤드 인덱스 및 테일 인덱스가 변경되지 않는
것을 특징으로 하는 메모리 관리 방법.
In a method for a memory allocator to manage memory,
Initializing an entire memory block to be allocated to an application program;
Allocating a block requested to be allocated from an application program in the entire memory block and recovering a block requested to be released from the application program in the entire memory block; And
And returning the entire memory block,
Wherein the head index refers to the position of the next block of the memory block located at the end of the entire memory block among the memory blocks allocated among the entire memory blocks and a tail index, Wherein the head index and the tail index correspond to a position of a memory block located at the beginning of the entire memory block among the memory blocks allocated among the entire memory blocks, And is set to the start position again from the end position of the entire memory block,
Wherein the head index is changed when the memory block to be recovered is a memory block at a previous position of the memory block of the head index and the tail index is changed when the memory block is the memory block of the tail index, The head index and the tail index are not changed when the memory block is not the memory block at the previous position of the memory block of the head index and the memory block of the tail index
Lt; / RTI >
제1항에 있어서,
상기 초기화하는 단계는,
프로그래밍 언어 또는 운영체제로부터 상기 전체 메모리 블록을 할당받는 단계; 및
상기 헤드 인덱스와 상기 테일 인덱스를 상기 시작 위치로 설정하는 단계
를 포함하는 메모리 관리 방법.
The method according to claim 1,
Wherein the initializing comprises:
Allocating the entire memory block from a programming language or an operating system; And
Setting the head index and the tail index to the start position
/ RTI >
제1항에 있어서,
상기 메모리 할당기는 상기 할당 요청된 블록 할당시 메타 정보를 포함하여 할당하는 것을 특징으로 하는 메모리 관리 방법.
The method according to claim 1,
Wherein the memory allocator allocates the meta information when allocating the requested block.
제3항에 있어서,
상기 메타 정보는 할당된 블록임을 나타내는 사용중 표식과 할당된 메모리 블록의 크기를 나타내는 정보를 포함하는 것을 특징으로 하는 메모리 관리 방법.
The method of claim 3,
Wherein the meta information includes an in-use indicator indicating the allocated block and information indicating a size of the allocated memory block.
제4항에 있어서,
상기 사용중 표식은 할당되는 메모리 블록의 첫 번째 바이트에 기재되며, "*"인 것을 특징으로 하는 메모리 관리 방법.
5. The method of claim 4,
Wherein the in-use indicator is written in the first byte of the allocated memory block and is "* ".
제5항에 있어서,
상기 사용중 표식이 '0'으로 기재되는 경우 해당 메모리 블록이 회수된 것을 나타내는 것을 특징으로 하는 메모리 관리 방법.
6. The method of claim 5,
And when the in-use mark is written as '0', it indicates that the corresponding memory block has been retrieved.
제4항에 있어서,
상기 메타 정보 중 할당된 메모리 블록의 크기를 나타내는 정보는 할당된 메모리 블록의 처음 부분과 마지막 부분에 각각 기록되는 것을 특징으로 하는 메모리 관리 방법.
5. The method of claim 4,
Wherein the information indicating the size of the allocated memory block among the meta information is recorded at the beginning and the end of the allocated memory block, respectively.
제1항에 있어서,
상기 할당 요청된 블록에 대해 상기 헤드 인덱스 이후부터 상기 전체 메모리 블록의 끝 부분까지의 할당 가능한 여유량(이하 "종단 여유량"이라 함)으로 할당이 어려운 경우 상기 종단 여유량에 대해 회수 처리하고, 상기 전체 메모리 블록의 처음 부분부터 할당하는 것을 특징으로 하는 메모리 관리 방법.
The method according to claim 1,
(Hereinafter referred to as "end margin amount") from the head index to the end of the entire memory block with respect to the allocation requested block, And allocating the memory area from the beginning of the block.
제1항에 있어서,
상기 전체 메모리 블록에서 회수하는 단계에서,
상기 헤드 인덱스 이전 위치의 메모리 블록이 회수되는 경우 상기 헤드 인덱스가 회수되는 메모리 블록을 가리키도록 이동되는 것을 특징으로 하는 메모리 관리 방법.
The method according to claim 1,
In the step of recovering in the entire memory block,
And when the memory block at a position before the head index is retrieved, the head index is moved to point to the memory block from which the head index is retrieved.
제9항에 있어서,
상기 헤드 인덱스 이전에 다수의 회수된 메모리 블록이 존재하는 경우 상기 헤드 인덱스가 상기 다수의 회수된 메모리 블록의 처음 부분의 메모리 블록을 가리키도록 이동되는 것을 특징으로 하는 메모리 관리 방법.
10. The method of claim 9,
Wherein the head index is moved to point to a memory block in a first portion of the plurality of retrieved memory blocks if a plurality of retrieved memory blocks exist prior to the head index.
제1항에 있어서,
상기 전체 메모리 블록에서 회수하는 단계에서,
상기 테일 인덱스의 메모리 블록이 회수되는 경우 상기 테일 인덱스가 회수되는 메모리 블록의 다음 위치의 메모리 블록을 가리키도록 이동되는 것을 특징으로 하는 메모리 관리 방법.
The method according to claim 1,
In the step of recovering in the entire memory block,
Wherein when the memory block of the tail index is retrieved, the tail index is moved to point to the memory block at the next position of the memory block from which the tail index is retrieved.
제11항에 있어서,
상기 테일 인덱스 이후에 다수의 회수된 메모리 블록이 존재하는 경우 상기 테일 인덱스가 상기 다수의 회수된 메모리 블록의 마지막 부분의 메모리 블록 다음의 위치의 메모리 블록을 가리키도록 이동되는 것을 특징으로 하는 메모리 관리 방법.
12. The method of claim 11,
And if the number of recovered memory blocks after the tail index exists, the tail index is moved to point to a memory block at a position next to the memory block at the end of the plurality of recovered memory blocks. Way.
삭제delete 삭제delete 삭제delete
KR1020120048288A 2012-05-07 2012-05-07 Method for scheduling resource block in wireless communicatoin system and apparatus thereof KR101391957B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020120048288A KR101391957B1 (en) 2012-05-07 2012-05-07 Method for scheduling resource block in wireless communicatoin system and apparatus thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020120048288A KR101391957B1 (en) 2012-05-07 2012-05-07 Method for scheduling resource block in wireless communicatoin system and apparatus thereof

Publications (2)

Publication Number Publication Date
KR20130124840A KR20130124840A (en) 2013-11-15
KR101391957B1 true KR101391957B1 (en) 2014-05-07

Family

ID=49853498

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020120048288A KR101391957B1 (en) 2012-05-07 2012-05-07 Method for scheduling resource block in wireless communicatoin system and apparatus thereof

Country Status (1)

Country Link
KR (1) KR101391957B1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101593161B1 (en) 2014-10-02 2016-02-15 한국전자통신연구원 Apparatus and method for memory management

Also Published As

Publication number Publication date
KR20130124840A (en) 2013-11-15

Similar Documents

Publication Publication Date Title
US11237769B2 (en) Memory system and method of controlling nonvolatile memory
US8775755B2 (en) Peer-to-peer transcendent memory
EP3036642B1 (en) Hardware managed compressed cache
US7536500B2 (en) Header blocks for flash memory writes
US20080195833A1 (en) Systems, methods and computer program products for operating a data processing system in which a file system's unit of memory allocation is coordinated with a storage system's read/write operation unit
US20100241820A1 (en) Reclaiming storage on a thin-provisioning storage device
CN107066498B (en) Key value KV storage method and device
CN103095686B (en) Focus metadata access control method and service device
EP3306477A1 (en) Storage device and block storage method based on the storage device
CN107111627B (en) Online file system checking
US10789170B2 (en) Storage management method, electronic device and computer readable medium
KR20140033448A (en) Memory management model and interface for unmodified applications
US7330956B1 (en) Bucket based memory allocation
US10359945B2 (en) System and method for managing a non-volatile storage resource as a shared resource in a distributed system
CN115599544A (en) Memory management method and device, computer equipment and storage medium
CN108958660B (en) Distributed storage system and data processing method and device thereof
US10282116B2 (en) Method and system for hardware accelerated cache flush
KR101391957B1 (en) Method for scheduling resource block in wireless communicatoin system and apparatus thereof
US11055184B2 (en) In-place garbage collection of a sharded, replicated distributed state machine based on supersedable operations
CN112346848A (en) Method, device and terminal for managing memory pool
CN115712500A (en) Memory release method, memory recovery method, memory release device, memory recovery device, computer equipment and storage medium
CN112559388B (en) Data caching method and device
KR101950759B1 (en) Garbage collection method for performing memory controller of storage device and memory controler
US9727486B1 (en) Writing pages to a storage system
CN115543859A (en) Wear leveling optimization method, device, equipment and medium for multi-partition SSD

Legal Events

Date Code Title Description
A201 Request for examination
E902 Notification of reason for refusal
E701 Decision to grant or registration of patent right
GRNT Written decision to grant
FPAY Annual fee payment

Payment date: 20170412

Year of fee payment: 4

LAPS Lapse due to unpaid annual fee