KR100617859B1 - Method for allocation of heap memory in embedded and system thereof - Google Patents
Method for allocation of heap memory in embedded and system thereof Download PDFInfo
- Publication number
- KR100617859B1 KR100617859B1 KR1020050048612A KR20050048612A KR100617859B1 KR 100617859 B1 KR100617859 B1 KR 100617859B1 KR 1020050048612 A KR1020050048612 A KR 1020050048612A KR 20050048612 A KR20050048612 A KR 20050048612A KR 100617859 B1 KR100617859 B1 KR 100617859B1
- Authority
- KR
- South Korea
- Prior art keywords
- memory
- buddy
- heap
- allocation
- size
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation 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/5016—Allocation 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
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Memory System (AREA)
Abstract
본 발명은 힙 메모리로 할당된 영역을 포함하며, 힙 메모리에 대한 버디 메모리 할당 절차를 수행하기 위한 버디 프리 리스트(buddy free list)를 저장하고 있는 메모리와, 힙 메모리에 대한 메모리 할당 요청이 있는 경우, 필요한 메모리의 크기가 임계치 이상인 경우에는 시퀀셜 메모리 할당절차를 통해 힙 메모리에 메모리 할당을 수행하고, 필요한 메모리의 크기가 임계치 이하인 경우에는 버디 메모리 할당 절차를 통해 힙 메모리에 메모리 할당을 수행하는 제어부를 포함하고 있는 임베디드 시스템을 제공한다.The present invention includes an area allocated as heap memory, and includes a memory storing a buddy free list for performing a buddy memory allocation procedure for the heap memory, and a memory allocation request for the heap memory. If the size of the required memory is greater than or equal to the threshold, the memory allocation to the heap memory is performed through the sequential memory allocation procedure. If the size of the required memory is less than or equal to the threshold, the controller that performs memory allocation to the heap memory is performed through the buddy memory allocation procedure. Provides embedded system included.
본 발명에 의하면, 소용량의 메모리 할당이 요청되는 경우 버디 프리 리스트를 이용해서 메모리를 신속하게 할당할 수 있음으로 실시간 메모리 할당에 효율적이다. 또한, 소용량의 메모리들이 힙 메모리에 산재적으로 할당되는 것을 방지할 수 있음으로 대용량의 메모리 할당시 산재적으로 미리 할당되어 있는 소용량의 메모리들에 의해 발생할 수 있는 외부 플래그먼트를 효과적으로 줄일 수 있다.According to the present invention, when a small memory allocation is requested, the memory can be quickly allocated using a buddy free list, which is efficient for real-time memory allocation. In addition, since a small amount of memory may be prevented from being scattered to the heap memory, an external fragment that may be generated by the small amount of memory that is preemptively allocated during large memory allocation may be effectively reduced.
힙, 버디, 시퀀셜, 버디 프리 리스트, 메모리, 할당, 임베디드 Heap, Buddy, Sequential, Buddy Free List, Memory, Allocation, Embedded
Description
도 1은 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법을 수행하기 위한 이동 통신 단말기의 구성 블록도.1 is a block diagram illustrating a mobile communication terminal for performing a heap memory allocation method of an embedded system according to an exemplary embodiment of the present invention.
도 2는 도 1에서 제어부의 구성 블록도.FIG. 2 is a block diagram illustrating a configuration of a control unit in FIG. 1. FIG.
도 3은 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법을 설명하기 위한 힙 메모리의 구조도.3 is a structural diagram of a heap memory for explaining a heap memory allocation method of an embedded system according to an embodiment of the present invention.
도 4는 도 3에 도시된 헤더의 구조도.4 is a structural diagram of a header shown in FIG. 3;
도 5는 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법을 수행하기 위한 버디 프리 리스트의 예시도.5 is an exemplary diagram of a buddy free list for performing a heap memory allocation method of an embedded system according to an embodiment of the present invention.
도 6 및 도 7은 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법중에 시퀀셜 할당을 설명하기 위한 힙 메모리의 구조도.6 and 7 are structural diagrams of a heap memory for explaining sequential allocation in the heap memory allocation method of the embedded system according to an embodiment of the present invention.
도 8은 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법중에 버디 할당을 설명하기 위한 힙 메모리의 구조도.8 is a structural diagram of a heap memory for explaining buddy allocation in the heap memory allocation method of the embedded system according to an embodiment of the present invention.
도 9 및 도 10은 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법중에 버디 할당을 설명하기 위한 버디 프리 리스트의 예시도.9 and 10 are exemplary diagrams of a buddy free list for explaining buddy allocation in a heap memory allocation method of an embedded system according to an embodiment of the present invention.
도 11 및 도 12는 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법을 수행하는 동작 흐름도.11 and 12 are flowcharts illustrating a method of allocating a heap memory of an embedded system according to an exemplary embodiment of the present invention.
본 발명은 임베디드 시스템(embedded system)의 힙(heap) 메모리 할당에 관한 것으로, 상세하게는 임베디드 시스템의 힙 메모리 할당 방법 및 그 시스템에 관한 것이다.The present invention relates to heap memory allocation of an embedded system, and more particularly, to a method and system for allocating a heap memory of an embedded system.
임베디드 시스템(embedded system)은 일반적으로 특정 기능을 수행하기 위해 하드웨어와 소프트웨어를 밀접하게 통합한 컴퓨팅 장치로 정의될 수 있다. 임베디드(embedded)라는 단어는 이들 시스템이 더 큰 시스템인 임베딩 시스템의 일부로 내장된다(embedded)는 것을 의미한다. 이들을 포함하는 임베딩 시스템(embedding system)안에는 여러 개의 임베디드 시스템이 동시에 존재할 수 있다.Embedded systems are generally defined as computing devices in which hardware and software are tightly integrated to perform specific functions. The word embedded means that these systems are embedded as part of a larger system, the embedding system. In an embedding system including these, several embedded systems may exist simultaneously.
임베디드 시스템은 특정 임무를 수행하도록 설계된 전용 컴퓨터 시스템(dedicated computer systems)을 뜻하며, 퍼베이시브 컴퓨터(pervasive computer) 또는 유비쿼터스 컴퓨터(ubiquotous computer)라고도 불린다. 많은 임베디드 시스템은 신뢰할 만 하며 예측 가능한 동작을 한다. 임베디드 시스템을 내장한 기기는 편하고 사용이 용이하며 안정적이다.Embedded systems are dedicated computer systems designed to perform specific tasks, and are also referred to as pervasive computers or ubiquotous computers. Many embedded systems have reliable and predictable behavior. Devices with embedded systems are convenient, easy to use and stable.
어떤 임베디드 시스템은 일정한 시간안에 외부 이벤트(event)에 반응해야 된 다는 특별한 요구 조건을 갖고 있어서 다른 임베디드 시스템과 구분된다. 이런 부류의 임베디드 시스템을 실시간(real-time) 임베디드 시스템이라 한다.Some embedded systems have a special requirement to react to external events in a certain amount of time, which distinguishes them from other embedded systems. This class of embedded systems is called real-time embedded systems.
이러한 임베디드 시스템은 도처에 존재한다. 임베디드 시스템은 공장 자동화, 방어 시스템, 수송장치, 항공장치, 통신 분야 등 여러 분야에서 사용된다.Such embedded systems are everywhere. Embedded systems are used in many fields, including factory automation, defense systems, transportation, aviation, and communications.
이동 통신 기술의 비약적인 발전에 따라 계속적으로 발전되고 있는 각종 이동 통신 단말기로 임베디드 시스템의 적용예이다.BACKGROUND OF THE INVENTION An application of an embedded system to various mobile communication terminals that are continuously developed with the rapid development of mobile communication technology.
임베디드 시스템은 일반적으로 각종 실시간 작업을 수행하는 경우가 많으며, 실시간 작업을 수행하기 위해서는 각종 실시간 작업을 수행하는데 발생되는 각종 정보들을 메모리에 실시간적으로 할당하는 기술이 필요하다.Embedded systems generally perform various real-time tasks, and in order to perform real-time tasks, a technique for real-time allocating various types of information generated to perform various real-time tasks is required in memory.
여기에서 사용되는 메모리는 일반적으로 램(ram)메모리가 사용된다. 특히, 램 메모리중에서 실시간 동작을 위해 동적으로 각종 정보를 저장하기 위해 할당된 메모리 영역을 힙(heap) 메모리라고 한다.The memory used here is typically a RAM memory. In particular, a memory area allocated in RAM memory for dynamically storing various types of information for a real time operation is called a heap memory.
일반적으로 이러한 임베디드 시스템은 소용량 메모리를 가지고 있다. 따라서, 소용량의 한정된 메모리에 구비된 힙 메모리를 효과적으로 할당하고 관리하기 위해 여러가지 기술이 제안되고 있다.Typically, these embedded systems have small amounts of memory. Accordingly, various techniques have been proposed to effectively allocate and manage the heap memory provided in the small limited memory.
임베디드 시스템의 힙 메모리 할당 관리 기술에 크게 시퀀셜(sequential) 메모리 할당 방식과 버디(buddy) 메모리 할당 방식이 있다. Heap memory allocation management techniques in embedded systems include sequential memory allocation and buddy memory allocation.
시퀀셜 메모리 할당 방식은 힙 메모리에서 메모리를 할당할 때 요청된 크기의 메모리르를 힙(heep) 메모리의 처음부터 검색하여 비어있는 영역중에서 요청된 크기의 영역이 있으면 해당 영역에 메모리를 할당하는 방식이다.In sequential memory allocation method, when memory is allocated from heap memory, the memory of requested size is searched from the beginning of heap memory, and if there is an area of the requested size among the empty areas, the memory is allocated to the corresponding area. .
버디 메모리 할당 방식은 버디 프리 리스트를 구비하여 메모리 할당 요청이 있는 경우 버디 프리 리스트에서 필요한 메모리의 크기에 맞는 메모리의 주소를 찾아서 해당 주소의 메모리를 할당하도록 하는 것이다. The buddy memory allocation method is to have a buddy free list so that when a memory allocation request is made, the memory address corresponding to the required memory size is found in the buddy free list and the memory of the corresponding address is allocated.
시퀀셜 메모리 할당 방식은 메모리를 할당할 때 요청한 크기에 상관없이 항상 힙(heep)영역의 처음부터 검색하여 메모리 할당 시간이 오래 걸린다. 또한, 소용량의 메모리들과 대용량 메모리들이 산재적으로 할당됨에 따라 대용량의 메모리 할당시 산재적으로 미리 할당되어 있는 소용량의 메모리들에 의해 사용되고 있지 않으나 메모리 할당을 하기에는 작은 크기의 메모리인 외부 플래그먼트(external fragmetation)이 발생될 수 있음에 따라 힙 메모리가 낭비되는 문제점이 있다.The sequential memory allocation method always takes a long time to allocate memory by searching from the beginning of the heap regardless of the size requested. Also, since small memories and large memories are scattered, they are not used by small amounts of memory that are pre-allocated preemptively when allocating a large amount of memory. As external fragmetation may occur, heap memory is wasted.
한편, 버디 메모리 할당 방식은 할당된 메모리의 영역중에서 일부의 영역만 사용되고 할당된 영역의 일부가 미사용 상태로 남아있는 내부 플래그멘테이션(internal fragmetation)이 많이 생길 수 있다. 특히, 작은 영역의 플래그멘테이션이 힙 메모리의 중간 중간에 산재적으로 생겨 대용량(large size)의 메모리 할당 요청이 있을 때, 힙 메모리에 프리(free) 영역이 있는데도 불구하고 작은 크기의 형태로 나누어져 있기 때문에 힙 메모리가 낭비되는 문제점이 있다.On the other hand, in the buddy memory allocation method, internal fragmetation may occur in which only a part of the allocated memory area is used and a part of the allocated area remains unused. In particular, when small area fragmentation is scattered in the middle of heap memory, and there is a large size memory allocation request, even though there is a free area in heap memory, it is divided into small sizes. Because of this problem, heap memory is wasted.
본 발명은 이러한 종래의 문제점을 해결하기 위해 안출된 것으로, 임베디드 시스템에 구비된 힙 메모리에 메모리 할당이 요청되는 경우 힙 메모리를 낭비하지 않으면서 메모리 할당을 신속하게 할 수 있는 임베디드 시스템의 힙 메모리 할당 방법 및 그 시스템을 제공하는데 그 목적이 있다.The present invention has been made to solve such a conventional problem, the heap memory allocation of the embedded system that can quickly allocate the memory without wasting the heap memory when the memory allocation is requested to the heap memory provided in the embedded system Its purpose is to provide a method and a system thereof.
이러한 목적을 달성하기 위한 본 발명의 일측면에 의하면, 힙 메모리로 할당된 영역을 포함하며, 힙 메모리에 대한 버디 메모리 할당 절차를 수행하기 위한 버디 프리 리스트를 저장하고 있는 메모리와, 힙 메모리에 대한 메모리 할당 요청이 있는 경우, 필요한 메모리의 크기가 임계치보다 큰 경우에는 시퀀셜 메모리 할당절차를 통해 힙 메모리에 메모리 할당을 수행하고, 필요한 메모리의 크기가 임계치 이하인 경우에는 버디 메모리 할당 절차를 통해 힙 메모리에 메모리 할당을 수행하는 제어부를 포함하고 있는 임베디드 시스템을 제공한다.According to an aspect of the present invention for achieving this object, a memory including a region allocated as heap memory, and stores a buddy free list for performing a buddy memory allocation procedure for the heap memory, If there is a memory allocation request, if the required memory size is larger than the threshold, the sequential memory allocation procedure performs memory allocation to the heap memory. If the required memory size is below the threshold, the buddy memory allocation procedure Provided is an embedded system including a control unit that performs memory allocation.
바람직하게 제어부는, 힙 메모리의 일측부터 시퀀셜 메모리 할당절차를 통해 힙 메모리에 대한 메모리 할당을 수행하고, 힙 메모리의 타측부터 버디 메모리 할당절차를 통해 힙 메모리에 대한 메모리 할당을 수행할 수 있다.Preferably, the controller may perform memory allocation for the heap memory through the sequential memory allocation procedure from one side of the heap memory and memory allocation for the heap memory through the buddy memory allocation procedure from the other side of the heap memory.
또한, 바람직하게 제어부는, 힙 메모리를 블록 단위로 구분하여 시퀀셜 메모리 할당 절차 및 버디 메모리 할당 절차를 수행할 수 있다. 이때, 임계치는 블록의 크기에 의해 결정된다.Also, preferably, the controller may divide the heap memory into block units to perform a sequential memory allocation procedure and a buddy memory allocation procedure. At this time, the threshold is determined by the size of the block.
바람직하게 제어부는, 힙 메모리에 대한 메모리 할당 요청이 있는 경우, 필요한 메모리의 크기가 임계치보다 큰지 여부를 판단하는 메모리 할당 크기 판단부와, 메모리 할당 크기 판단부의 판단 결과, 필요한 메모리의 크기가 임계치보다 큰 경우에 시퀀셜 메모리 할당절차를 통해 힙 메모리에 메모리 할당을 수행하는 시퀀 셜 메모리 할당부와, 메모리 할당 크기 판단부의 판단 결과, 필요한 메모리의 크기가 임계치이하인 경우에 메모리에 저장된 버디 프리 리스트에 따라 버디 메모리 할당 절차를 통해 힙 메모리에 메모리 할당을 수행하는 버디 메모리 할당부와, 메모리에 저장된 버디 프리 리스트를 관리하는 버디 프리 리스트 관리부를 포함하여 구성될 수 있다.Preferably, the control unit, when there is a memory allocation request for the heap memory, the memory allocation size determination unit for determining whether the required memory size is larger than the threshold, and as a result of the determination of the memory allocation size determination unit, the required memory size is larger than the threshold In the case of large memory, the sequential memory allocation unit that performs memory allocation to the heap memory through the sequential memory allocation procedure and the buddy free list stored in the memory when the required memory size is less than the threshold as a result of the determination of the memory allocation size determination unit A buddy memory allocator for allocating memory to the heap memory through a memory allocation procedure and a buddy free list manager for managing a buddy free list stored in the memory may be configured.
또한, 본 발명의 다른 측면에 의하면, 힙 메모리에 대한 메모리 할당 요청이 있는 경우, 필요한 메모리의 크기가 임계치보다 큰지 여부를 판단하는 단계와, 판단 결과, 필요한 메모리의 크기가 임계치보다 큰 경우에 시퀀셜 메모리 할당절차를 통해 힙 메모리에 메모리 할당을 수행하는 단계와, 판단 결과, 필요한 메모리의 크기가 임계치 이하인 경우에 버디 프리 리스트에 따라 버디 메모리 할당 절차를 통해 힙 메모리에 메모리 할당을 수행하는 단계를 포함하는 임베디드 시스템의 힙 메모리 할당 방법을 제공한다.According to another aspect of the present invention, if there is a memory allocation request for heap memory, determining whether the required memory size is larger than the threshold, and as a result of the determination, if the required memory size is larger than the threshold, the sequential Performing memory allocation to the heap memory through a memory allocation procedure; and performing memory allocation to the heap memory through a buddy memory allocation procedure according to the buddy-free list when the required memory size is less than or equal to a threshold as a result of the determination. It provides heap memory allocation method of embedded system.
여기에서, 힙 메모리는, 시퀀셜 메모리 할당절차를 통해 힙 메모리의 일측부터 메모리의 할당이 이루어지고, 버디 메모리 할당절차를 통해 힙 메모리의 타측부터 메모리의 할당이 이루어질 수 있다.Here, the heap memory may be allocated from one side of the heap memory through the sequential memory allocation procedure, and the memory may be allocated from the other side of the heap memory through the buddy memory allocation procedure.
이하, 첨부된 도면을 참조하여 본 발명을 상세히 설명하도록 한다.Hereinafter, the present invention will be described in detail with reference to the accompanying drawings.
도 1은 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법을 수행하기 위한 이동 통신 단말기의 구성 블록도이다.1 is a block diagram illustrating a mobile communication terminal for performing a heap memory allocation method of an embedded system according to an exemplary embodiment of the present invention.
도 1을 참조하면, 본 발명의 일실시예에 따른 이동 통신 단말기(100)는 힙 메모리로 할당된 저장 영역과 힙 메모리에 버디 메모리 할당을 위한 버디 프리 리 스트와 각종 단말기 정보를 저장하고 있는 메모리(110)와, 무선망 시스템 접속을 위한 각종 메시지를 처리하고, 힙 메모리의 메모리 할당 요청이 있는 경우, 필요한 메모리의 크기를 판단하여 임계치보다 큰 경우에는 시퀀셜 메모리 할당 절차를 통해 힙 메모리의 메모리 할당을 수행하고, 임계치 이하인 경우에는 버디 메모리 할당 절차를 통해 힙 메모리의 메모리 할당을 수행하는 제어부(120)와, 제어부(120)에 의해 생성된 무선망 시스템 접속 메시지를 무선통신을 통해 무선망으로 전송하는 RF부(130)와, 음성 처리부(140)와, 스피커(150)와, 마이크로폰(160)과, 버튼으로 구성되는 키입력부(170)와, 화면창을 제공하는 표시부(180)를 포함하여 구성된다.Referring to FIG. 1, a
이동 통신 단말기(100)는 이동 통신 단말기(100)의 초기 기동을 수행하기 위한 데이터들과 각종 멀티미디어 서비스를 수행하기 위한 해당 소프트웨어 프로그램들을 메모리(110)에 저장하고 있다. The
이동 통신 단말기(100)의 초기 기동을 수행하기 위한 데이터들은 롬(111)에 저장되고, 실시간 처리를 요하는 OS(Operating System) 호처리 소프트웨어 및 각종 멀티미디어 서비스를 수행하기 위한 소프트웨어 프로그램들은 일반적으로 이동 통신 단말기(100)의 플래시 메모리(112)에 저장된다. 이들 프로그램들의 변수 및 상태는 램(113)에 불러와서 해당 동작이 수행된다.Data for performing initial startup of the
플래시 메모리(112)에 저장되는 데이터들은 유무선 인터넷 또는 유선망을 통해 해당 소프트웨어 프로그램을 다운로드 받아 설치하거나 추가로 업데이트할 수 있다.Data stored in the
램(113)은 제어부(120)에 의해 롬(111)이나 플래시 메모리(112)에 있던 프로그램들이 실행될 때, 프로그램의 실행시에 발생되는 각종 정보들을 임시로 저장하는 메모리이다. 따라서, 램(113)에서는 각종 프로그램이 실행되기 위해 실시간적으로 메모리를 할당하는 것이 필요하다. 램(113)에서 실시간 메모리 할당을 위해 할당된 메모리 영역을 힙 메모리(heap memory)라 한다.The
여기에서, 램(113)의 힙 메모리는 시퀀셜 메모리 할당 절차와 버디 메모리 할당 절차를 통해 메모리 할당이 이루어지며, 블록별로 관리되어 진다.Herein, the heap memory of the
램(113)의 힙 메모리는 시퀀셜 메모리 할당절차를 통해서는 힙 메모리의 위쪽부터 차례대로 메모리 할당이 이루어지고, 버디 메모리 할당절차를 통해서는 힙 메모리의 아래쪽부터 메모리의 할당이 차례대로 이루어진다.The heap memory of the
제어부(120)는 롬(111)이나 플래시 메모리(112)에 저장되어 있던 각종 프로그램들을 실행할 때 프로그램의 실행시에 발생되는 각종 정보들을 임시로 저장하기 위해 램(113)에 할당된 힙 메모리를 관리한다.The
제어부(120)는 이동 통신 단말기에서 발생되는 각종 음성 처리, 기지국과의 각종 데이터 송수신, 문자 메시지의 작성과 송수신, 영상 촬영 및 저장, 음악 재생을 위해 힙 메모리에 실시간적으로 필요한 메모리를 할당해야 한다.The
따라서, 제어부(120)는 힙 메모리를 블록단위로 관리하고, 할당 요청된 메모리의 크기에 따라 서로 다른 메모리 할당 방식을 사용하여 메모리의 할당을 수행한다.Accordingly, the
즉, 제어부(120)는 메모리 요청의 크기를 구분하는 임계치(threshold value) 를 정해서 소용량인지 대용량인지를 구분해서 대용량인 경우에는 시퀀셜 메모리 할당 절차를 통해 메모리를 할당하고, 소용량인 경우에는 버디 메모리 할당 절차를 통해 메모리를 할당해준다.That is, the
이렇게 함으로써 제어부(120)는 소용량의 메모리 할당이 요청되는 경우 버디 프리 리스트(buddy free list)를 이용해서 프리한 메모리 공간을 신속하게 할당할 수 있음으로 실시간 메모리 할당에 큰 효과를 제공한다.In this way, when a small memory allocation is requested, the
또한, 제어부(120)는 대용량의 메모리 할당이 요청되는 경우에는 힙 메모리의 위쪽부터 메모리를 할당하고, 소용량의 메모리 할당이 요청되는 경우에는 힙 메모리의 아래쪽부터 메모리를 할당해준다.In addition, the
이렇게 함으로써, 제어부(120)는 소용량의 메모리들이 힙 메모리에 산재적으로 할당되는 것을 방지할 수 있음으로 대용량의 메모리 할당시 산재적으로 미리 할당되어 있는 소용량의 메모리들에 의해 발생할 수 있는 외부 플래그먼트를 효과적으로 줄일 수 있다.By doing so, the
RF부(130)는 제어부(120)의 제어를 받으며, 제어부(120)로부터 출력되는 신호를 무선신호로 변환한다. 또한, RF부(130)는 안테나를 통해 수신된 무선신호를 원하는 신호로 변환하여 출력한다.The
음성처리부(140)는 마이크로폰(microphone)(160)으로부터 입력된 음성 신호를 변조하여 음성 데이터로 변환하고, RF부(130)로부터 입력된 음성 데이터 및 메모리(110)에 저장된 음성 데이터를 음성신호로 복조하여 스피커(speaker)(150)를 통해 음성으로 출력한다.The
키입력부(170)는 다수의 숫자 키와 메뉴 키 및 각종 기능을 수행하기 위한 기능 키로 이루어지며, 외부의 조작에 의해 제어부(120)로 키 데이터를 출력한다.The
따라서, 제어부(120)는 키입력부(170)에 의한 사용자의 메뉴 표시 요구에 따라 해당 메뉴를 메모리(110)로부터 독출하여 표시부(180)에 표시한다. 즉, 키입력부(170)는 통상적인 사용자 정보 입력 수단으로, 다수의 숫자 키와 기능키 등 적용되는 이동 통신 단말기에 적절한 다수의 키들을 구비하며, 구비된 각 키들의 입력이 있으면 입력 키 각각에 있어 해당되는 고유의 키 데이터를 출력하여 제어부(120)로 전달함으로써, 키입력부(170)의 키 입력 동작을 통해 메뉴 표시 모드로의 진입 및 메뉴의 선택이 이루어지게 된다. 그러면, 제어부(120)에서 해당 키 입력에 따른 메뉴를 메모리(110)에서 독출하여 표시부(180)에 표시하게 된다.Accordingly, the
표시부(180)는 액정표시장치(LCD) 등과 같은 표시장치로서, 제어부(120)의 제어를 받아 이동 통신 단말의 상태나 프로그램의 진행 상황을 표시한다. 즉, 이동 통신 단말기의 전반적인 상태 및 입력되는 사용자 정보 등을 표시한다.The
도 2는 도 1에 도시된 제어부의 구성 블록도이다.FIG. 2 is a block diagram illustrating the configuration of the control unit shown in FIG. 1.
도 2를 참조하면, 제어부(120)는 메모리 할당 크기 판단부(121)와, 시퀀셜 메모리 할당부(122)와, 버디 메모리 할당부(123)와, 버디 프리 리스트 관리부(124)를 포함하여 구성된다.Referring to FIG. 2, the
메모리 할당 크기 판단부(121)는 힙 메모리에 대한 메모리 할당 요청이 있는 경우, 필요한 메모리의 크기가 임계치보다 큰지 여부를 판단한다.When there is a memory allocation request for the heap memory, the memory allocation
메모리 할당 크기 판단부(121)에서 요청된 메모리의 크기를 판단할 때 사용 하는 임계치는 힙 메모리의 관리에 사용되는 블록의 크기에 의해 정해질 수 있다.The threshold used when determining the size of the memory requested by the memory allocation
예를 들어, 힙 메모리의 관리에 사용되는 블록의 크기를 32K바이트로 한 경우에 임계치는 32K바이트가 된다.For example, when the size of a block used for managing heap memory is 32K bytes, the threshold is 32K bytes.
힙 메모리는 블록 단위로 관리되어 짐에 따라, 각 메모리의 블록은 해당 메모리 블록에 대한 정보를 가지는 헤더를 가지게 된다. 예를 들어, 헤더에 4바이트의 크기가 할당될 수 있다.As heap memory is managed in units of blocks, each block of memory has a header having information about the corresponding block of memory. For example, a size of 4 bytes may be allocated to the header.
따라서, 임의의 크기를 가지는 메모리에 대한 할당 요청이 있는 경우, 메모리 할당 크기 판단부(121)는 요청된 크기에 4바이트를 더한 값이 임계치인 32K 바이트보다 큰지 여부를 판단한다.Therefore, when there is an allocation request for a memory having an arbitrary size, the memory allocation
판단 결과, 요청된 크기에 4바이트를 더한 값이 임계치인 32K 바이트보다 큰 경우에는 시퀀셜 메모리 할당을 수행하게 하고, 임계치인 32K 바이트 이하인 경우에는 버디 메모리 할당을 수행하게 한다.As a result of the determination, if the value obtained by adding 4 bytes to the requested size is larger than the threshold of 32K bytes, the sequential memory allocation is performed.
시퀀셜 메모리 할당부(122)는 메모리 할당 크기 판단부(121)의 판단 결과, 필요한 메모리의 크기가 임계치보다 큰 경우에 시퀀셜 메모리 할당절차를 통해 힙 메모리에 메모리 할당을 수행한다.The sequential
시퀀셜 메모리 할당부(122)는 요청된 크기의 메모리를 블록 단위로 크기조절을 한 후 힙 메모리를 할당한다.The
버디 메모리 할당부(123)는 메모리 할당 크기 판단부(121)의 판단 결과, 필요한 메모리의 크기가 임계치이하인 경우에 메모리(110)에 저장된 버디 프리 리스트에 따라 버디 메모리 할당 절차를 통해 힙 메모리에 메모리 할당을 수행한다.The
버디 메모리 할당부(123)는 프리 크기(free size)를 검색할 때 힙 메모리의 시작번지로부터 검색하여 크기 조절된 크기 만큼의 프리 영역이 있을 때 영역을 할당해 준다.When the
버디 메모리 할당부(123)는 메모리 할당 요청시에 요청 크기가 임계치보다 작을 때는 버디 메모리 할당에 의해 할당해준다. 버디 메모리 할당 절차는 힙 메모리의 블록을 1/2로 쪼개어 메모리 블록을 할당한다.The
버디 메모리 할당에 의해 할당된 힙 메모리 블록에서 할당된 부분의 나머지는 버디 프리 리스트에서 주소를 가지고 있게 한다. 즉, 크기별로 프리한 영역은 버디 프리 리스트에서 관리하게 된다. The remainder of the allocated portion of the heap memory block allocated by buddy memory allocation keeps the address in the buddy free list. That is, the free area for each size is managed in the buddy free list.
버디로 할당할 때는 요청한 크기의 버디 프리 리스트를 검색하여 비어있는 공간이 있으면 할당해준다. 만약에 없으면 힙의 마지막 번지에서부터 검색하여 버디로 할당해줄 수 있는 공간이 있는지 찾아본다.When allocating as a buddy, it searches for a buddy free list of the requested size and allocates an empty space if there is one. If not, we search from the last address on the heap to see if there is space available for allocation to the buddy.
버디 프리 리스트 관리부(124)는 메모리(110)에 저장된 버디 프리 리스트를 관리한다.The buddy
버디 프리 리스트는 블록 단위로 관리되는 힙 메모리중에서 버디 메모리 할당에 사용할 수 있도록 각 프리 상태에 있는 메모리 버디(buddy)들의 리스트를 저장하고 있다.The buddy free list stores a list of memory buddies in each free state so that they can be used for allocating buddy memory among the block memory managed by blocks.
여기에서, 버디(buddy)라는 것은 친구를 의미한다. 따라서, 힙 메모리를 블록 단위로 관리할 때, 버디 메모리 할당을 위해 하나의 메모리 블록을 반으로 분할하여 동일한 크기를 가지는 두개의 메모리로 구분하게 되는데, 이때 동일한 크기로 분할되는 두개의 메모리는 서로 버디 관계에 있게 된다.Here, buddy means friend. Therefore, when managing the heap memory in block units, one memory block is divided into two and divided into two memories having the same size to allocate the buddy memory. You are in a relationship.
이때, 분할 된 두개의 메모리 버디중에서 하나의 메모리 버디가 할당되면 나머지 사용되지 메모리 버디는 미할당된 상태로 남으면, 버디 프리 리스트 관리부(124)는 할당된 메모리 버디를 버디 프리 리스트에서 삭제하고 미할당된 메모리 버디만을 버디 프리 리스트에 남겨둔다.At this time, if one memory buddy is allocated among two divided memory buddies, the remaining unused memory buddy remains unallocated, and the buddy
이때, 버디 프리 리스트 관리부(124)는 버디 메모리 할당에 의해 할당된 힙 메모리 블록에서 할당된 부분의 나머지에 대한 주소를 버디 프리 리스트에서 저장하여 관리한다. 또한, 버디 프리 리스트 관리부(124)는 버디 프리 리스트에서 크기별로 프리한 메모리 영역을 관리한다.At this time, the buddy
도 3은 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법을 설명하기 위한 힙 메모리의 구조도이다.3 is a structural diagram of a heap memory for explaining a heap memory allocation method of an embedded system according to an embodiment of the present invention.
도 3을 참조하면, 힙 메모리(heap memory)(200)는 시퀀셜 메모리 할당 절차와 버디 메모리 할당 절차를 통해 메모리 할당이 이루어지며, 블록별로 관리되어 진다. Referring to FIG. 3, a
힙 메모리(200)에는 이동 통신 단말기에서 발생되는 각종 음성 처리, 기지국과의 각종 데이터 송수신, 문자 메시지의 작성과 송수신, 영상 촬영 및 저장, 음악 재생을 위해 힙 메모리에 실시간적으로 필요한 정보들을 저장하기 위한 메모리들이 할당된다.The
힙 메모리(200)는 제어부(120)에 의해 블록단위로 관리되고 할당 요청된 메모리의 크기에 따라 서로 다른 메모리 할당 방식이 사용되어 메모리 할당이 이루어 진다.The
즉, 제어부(120)에 의해 메모리 요청의 크기를 구분하는 임계치(threshold value)가 정해져서 그 임계치에 의해 요청된 메모리의 크기가 소용량인지 대용량인지를 구분해서 대용량인 경우에는 시퀀셜 메모리 할당 절차를 통해 메모리가 할당되고, 소용량인 경우에는 버디 메모리 할당 절차를 통해 메모리가 할당된다.That is, a threshold value for classifying a size of a memory request is determined by the
이렇게 함으로써 힙 메모리(200)는 소용량의 메모리 할당이 요청되는 경우 버디 프리 리스트(buddy free list)를 이용해서 프리한 메모리 공간이 신속하게 할당될 수 있다.By doing so, the
힙 메모리(200)는 시퀀셜 메모리 할당절차를 통해서는 힙 메모리의 위쪽부터 차례대로 메모리 할당이 이루어지고, 버디 메모리 할당절차를 통해서는 힙 메모리의 아래쪽부터 메모리의 할당이 차례대로 이루어진다. The
따라서, 시퀀셜 메모리 할당을 위해 프리한 영역의 메모리를 찾는 시퀀셜 검색은 힙 메모리(200)의 위쪽부터 아래쪽으로 시작되고, 버디 메모리 할당을 위해 프리한 영역의 메모리를 찾는 버디 검색은 힙 메모리(200)의 아래쪽부터 위쪽으로 시작된다.Accordingly, the sequential search for finding the memory of the free area for sequential memory allocation starts from the top of the
이렇게 함으로써, 힙 메모리(200)는 소용량의 메모리들이 힙 메모리(200)에 산재적으로 할당되는 것이 방지될 수 있음에 따라 대용량의 메모리 할당시 산재적으로 미리 할당되어 있는 소용량의 메모리들에 의해 발생할 수 있는 외부 플래그먼트가 효과적으로 줄어들수 있다.By doing so, the
힙 메모리(200)는 블록 단위로 관리되어 진다. 예를 들어, 힙 메모리의 관리 에 사용되는 블록의 크기는 32K바이트가 될 수 있다.The
힙 메모리(200)는 블록 단위로 관리되어 짐에 따라, 각 메모리의 블록은 해당 메모리 블록에 대한 정보를 가지는 헤더를 가지게 된다. 예를 들어, 헤더에 4바이트의 크기가 할당될 수 있다.As the
따라서, 임의의 크기를 가지는 메모리에 대한 할당 요청이 있는 경우, 요청된 크기에 4바이트를 더한 값이 임계치인 32K 바이트보다 큰지 여부가 판단된다.Therefore, when there is an allocation request for a memory having an arbitrary size, it is determined whether the value obtained by adding 4 bytes to the requested size is larger than the threshold of 32K bytes.
판단 결과, 요청된 크기에 4바이트를 더한 값이 임계치인 32K 바이트보다 큰 경우에는 시퀀셜 메모리 할당이 수행되고, 임계치인 32K 바이트 이하인 경우에는 버디 메모리 할당이 수행된다.As a result, sequential memory allocation is performed when 4 bytes plus the requested size is larger than the threshold of 32K bytes, and buddy memory allocation is performed when the threshold is less than or equal to 32K bytes.
도 4는 도 3에 도시된 헤더의 구조도이다.4 is a structural diagram of a header shown in FIG. 3.
도 4를 참조하면, 힙 메모리의 헤더는 4바이트의 크기로 이루어지며, 1바이트가 플래그 필드로 할당되어 있고, 3바이트가 사이즈 필드로 할당되어 있다.Referring to FIG. 4, a header of a heap memory has a size of 4 bytes, 1 byte is allocated to a flag field, and 3 bytes are allocated to a size field.
플래그 필드는 블록별로 관리되는 해당 메모리의 할당여부에 대한 정보를 표시하는 필드이다. The flag field is a field indicating information on whether the corresponding memory managed by each block is allocated.
즉, 플래그 필드가 0x80으로 설정되어 있으면 더티 플래그(Dirty Flag)로서 해당 메모리 블록이 이미 할당되어 사용중임을 의미한다.That is, if the flag field is set to 0x80, this means that the corresponding memory block is already allocated and used as a dirty flag.
플래그 필드가 0x40으로 설정되어 있으면 리키지 플래그(Leakage Flag)로서 해당 메모리 블록이 메모리의 리키지를 테스트하기 위한 메모리로 할당되어 사용중임을 의미한다.If the flag field is set to 0x40, it is a leak flag, which means that the corresponding memory block is allocated and used as a memory for testing the memory of the memory.
플래그 필드가 0x20으로 설정되어 있으면 공유 메모리 플래그(ShMen Flag)로 서 해당 메모리 블록이 공유 메모리로 할당되어 사용중임을 의미한다. 여기에서 공유 메모리라는 것은 하나 이상의 어플리케이션에서 해당 메모리에 대한 설정을 변경할 수 있는 메모리를 의미한다.If the flag field is set to 0x20, this means that the corresponding memory block is allocated as shared memory and is being used as a shared memory flag (ShMen Flag). In this case, the shared memory refers to a memory in which one or more applications can change a setting for the corresponding memory.
플래그 필드가 0x10으로 설정되어 있으면 버디 플래그(Buddy Flag)로서 해당 메모리 블록이 버디 메모리로서 할당되어 있음을 나타낸다.If the flag field is set to 0x10, it indicates that the corresponding memory block is allocated as a buddy memory as a buddy flag.
사이즈 필드는 해당 메모리 블록의 크기 정보를 나타낸다. 즉, 이미 할당되어 사용되고 있는 사용 블록(used block) 또는 미할당되어 프리한 상태에 있는 프리 블록(free block)에 대한 정보를 포함하고 있다.The size field indicates size information of the corresponding memory block. That is, it includes information on a used block that is already allocated and used or a free block that is in an unassigned and free state.
해당 메모리 블록이 사용 블록(used block)인 경우에는 헤더 4바이트의 크기에 실제 할당된 메모리의 크기를 합한 값이 설정되어 있다.If the corresponding memory block is a used block, a value obtained by adding the size of 4 bytes of headers to the size of the actually allocated memory is set.
해당 메모리 블록이 프리 블록(free block)인 경우에는 프리한 상태에 있는 전체 블록 크기 또는 같은 크기를 가지는 프리한 상태에 있는 메모리 버디의 주소정보가 설정되어 있다.When the memory block is a free block, the address information of the entire block size in the free state or the memory buddy in the free state having the same size is set.
도 5는 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법을 수행하기 위한 버디 프리 리스트의 예시도이다.5 is an exemplary diagram of a buddy free list for performing a heap memory allocation method of an embedded system according to an embodiment of the present invention.
도 5를 참조하면 버디 프리 리스트는 각 메모리의 사이즈별로 프리한 상태에 있는 메모리 공간의 주소들이 리스트화되어 있다. 즉, 2n의 사이즈를 가지는 메모리 블록의 주소(0x00293898..), 2n의 사이즈를 가지는 메모리 블록의 주소(0x002930a8..)..... 23의 사이즈를 가지는 메모리의 주소(0x002945b8)들이 리스트 화되어 있다. 여기에서는 24의 사이즈를 가지는 메모리는 없으므로 NULL로 설정되어 있다.Referring to FIG. 5, in the buddy free list, addresses of memory spaces in a free state for each memory size are listed. That is, the address of the memory block having a size of 2 n (0x00293898 ..), the address of the memory block having a size of 2 n (0x002930a8 ..) ..... The address of the memory having a size of 2 3 (0x002945b8) Are listed. Since there is no memory of
버디 프리 리스트에서 23의 사이즈를 가지는 메모리의 주소까지만 리스트화되어 있는 것은 이론적으로는 20 사이즈를 가지는 메모리의 주소까지 리스트화되어야 하지만, 헤더의 크기 4바이트를 차지하고 있으므로 최소한 4바이트의 헤더가 차지하는 메모리의 크기를 감안하여 버디 프리 리스트에서 23의 사이즈까지의 메모리를 가지는 주소들이 리스트화되어 있다.In the buddy-free list, only the address of the memory of
도 6 및 도 7은 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법중에 시퀀셜 할당을 설명하기 위한 힙 메모리의 구조도이다.6 and 7 are structural diagrams of a heap memory for explaining sequential allocation in a heap memory allocation method of an embedded system according to an embodiment of the present invention.
도 6에 도시된 바와 같이 힙 메모리(200)의 전체가 미사용 상태에 있으므로 헤더(221)의 플래그는 0x00로 설정되어 있고, 힙 메모리 전체의 메모리 용량이 설정되어 있다.As shown in FIG. 6, since the
이러한 상태에서 시퀀셜 메모리 할당이 이루어질 경우, 시퀀셜 메모리 할당부(122)는 힙 메모리(200)의 위쪽부터 검색을 시작하여 힙 메모리의 헤더(221)를 읽게 된다. 플래그가 0x00로 설정되어 있음에 따라 힙 메모리(200)의 전체가 미사용상태임을 알게 되고, 사이즈 필드를 읽어 힙 메모리의 용량을 알게 된다.In this state, when sequential memory allocation is performed, the sequential
예를 들어, 요청된 메모리의 용량이 하나의 메모리 블록보다는 크고, 두개의 메모리 블록보다는 작은 크기일 경우에는 도 7에 도시된 바와 같이 두개의 메모리 블록이 메모리 영역으로 할당되고, 두개의 메모리 영역중에 일부의 영역(222a)만 사용되어 진다.For example, if the requested memory capacity is larger than one memory block and smaller than two memory blocks, two memory blocks are allocated to the memory area as shown in FIG. 7, and among the two memory areas. Only a part of the
따라서, 사용되어지는 두개의 메모리 블록은 하나의 헤더(222)에 의해 하나의 메모리 영역으로 관리되어지고, 힙 메모리(200)중에서 미사용되는 메모리 영역(223a)는 또 하나의 헤더(223)에 의해 관리되어 진다.Therefore, the two memory blocks to be used are managed by one
이에 따라, 사용되는 메모리 영역의 헤더(222)에는 플래그 필드에 0x80이 설정되고, 사이즈 필드에는 사용되는 메모리 영역(222a)에 대한 메모리 크기가 설정된다.Accordingly, 0x80 is set in the flag field in the
또한, 미사용되는 메모리 영역의 헤더(223)에는 플래그 필드에 0x00이 설정되어 있고, 사이즈 필드에는 미사용되는 메모리 영역(223a)에 대한 메모리 크기가 설정되어 있다.In the
도 8은 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법중에 버디 할당을 설명하기 위한 힙 메모리의 구조도이다.8 is a structural diagram of a heap memory for explaining buddy allocation in a heap memory allocation method of an embedded system according to an exemplary embodiment of the present invention.
도 8을 참조하면, 메모리의 영역(230)은 32K 바이트의 크기를 가지고 있으며, 임의의 메모리 주소(addr_A)를 가지고 있다.Referring to FIG. 8, an
임계치가 32K 바이트로 설정된 상태에서 요청된 메모리의 할당 용량이 2000바이트인 경우에 메모리의 영역(230)에 대하여 버디 메모리 할당 절차에 의해 메모리를 할당하는 것을 설명하도록 한다.The allocation of memory by the buddy memory allocation procedure for the
2000바이트의 메모리 할당 용량이 요청되었으므로 할당 요청된 메모리의 크기인 2000 바이트에 헤더의 크기인 4바이트를 더한 2004 바이트가 전체 할당 용량 이 된다.Since 2000 bytes of memory allocation capacity is requested, the total allocation capacity is 2004 bytes, which is 2000 bytes, which is the size of memory requested for allocation, plus 4 bytes of the header size.
요청된 할당 용량 2004는 임계치인 32K 바이트보다 작으므로 버디 메모리 할당 절차가 수행된다. 이에 따라, 2004에 근접한 2n을 찾아보면, 2048(211)이 됨을 알 수 있다.Since the requested allocation capacity 2004 is smaller than the threshold of 32K bytes, the buddy memory allocation procedure is performed. Accordingly, looking for 2 n close to 2004, it can be seen that 2048 (2 11 ).
따라서, 버디 프리 리스트에서 2048(211) 크기를 가지는 메모리 영역의 주소를 찾아 해당 메모리 영역을 할당하면 된다. 도면에서는 2048(211) 크기를 가지는 메모리의 영역(232)의 주소가 addr_E로 표시되어 있다.Accordingly, an address of a memory area having a size of 2048 (2 11 ) may be found in the buddy free list and the corresponding memory area may be allocated. In the figure, the address of the
2048(211)의 크기를 가지는 메모리 영역(232)은 해당 메모리 영역(232)에 대한 정보를 가지고 있는 헤더(232a)를 가지고 있고, 해당 메모리 영역(232)은 그중에서 2000바이트 만큼 일부의 영역(232b)이 할당되고, 나머지 영역(232c)은 비어 있는 상태로 있게 된다.The
도 9 및 도 10은 도 8에 도시된 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법중에 버디 할당을 설명하기 위한 버디 프리 리스트의 예시도이다.9 and 10 are exemplary diagrams of a buddy free list for explaining buddy allocation in a heap memory allocation method of an embedded system according to an embodiment of the present invention illustrated in FIG. 8.
도 9를 참조하면, 메모리의 할당이 이루어지지 않은 상태에서 최초에 메모리 블록의 단위가 32K 바이트이므로 32K 바이트의 크기를 가지는 메모리 영역(230)은 addr_A라는 주소를 가지고 있다. 이에 따라 LIST[15]에 addr_A -> NULL 이 설정된다. 즉, 32K 바이트의 용량을 가지는 메모리 영역은 addr_A 라는 주소를 가지고 있 으며, 해당 메모리 영역이 할당되고 나면 더 이상 비어있는 메모리는 없다는 것을 의미한다.Referring to FIG. 9, the
블록의 단위가 32K 바이트인 상태에서 요청된 할당 메모리의 용량이 2000 바이트이므로 버디 프리 리스트 관리부(124)는 32K 바이트의 크기를 가지는 메모리 영역(230)을 16K 바이트씩 반으로 나누어 두개의 메모리 영역으로 분할한다. Since the requested allocation memory capacity is 2000 bytes while the unit of the block is 32K bytes, the buddy
즉, LIST[15]에 설정된 addr_A라는 주소의 32K 바이트 크기를 가지는 메모리영역을 16K 바이트 크기를 가지는 두개의 메모리 영역으로 나누고 각각의 주소를 addr_B, addr_A라고 한다. 이에 따라 LIST[14]에 addr_B -> addr_A -> NULL이 설정된다. That is, the memory area having a size of 32K bytes of the address of addr_A set in LIST [15] is divided into two memory areas having a size of 16K bytes, and each address is called addr_B and addr_A. Accordingly, addr_B-> addr_A-> NULL is set in LIST [14].
한편, 16K 바이트는 또 반으로 분할할 수 있으므로 반으로 분할하면 두개의 8K 바이트로 나눌 수 있다. On the other hand, 16K bytes can be split in half, so splitting in half divides it into two 8K bytes.
즉, LIST[14]에 설정된 addr_B라는 주소의 16K 바이트 크기를 가지는 메모리영역을 8K 바이트 크기를 가지는 두개의 메모리 영역으로 나누고 각각의 주소를 addr_B, addr_B라고 한다. 이에 따라 LIST[13]에 addr_C -> addr_B -> NULL이 설정된다. That is, a memory area having a size of 16K bytes of an address of addr_B set in LIST [14] is divided into two memory areas having a size of 8K bytes, and each address is called addr_B and addr_B. Accordingly, addr_C-> addr_B-> NULL is set in LIST [13].
한편, 8K 바이트는 또 반으로 분할할 수 있으므로 반으로 분할하면 두개의 4K 바이트로 나눌 수 있다. On the other hand, 8K bytes can be split in half, so splitting in half divides it into two 4K bytes.
즉, LIST[13]에 설정된 addr_C라는 주소의 8K 바이트 크기를 가지는 메모리영역을 4K 바이트 크기를 가지는 두개의 메모리 영역으로 나누고 각각의 주소를 addr_D, addr_C라고 한다. 이에 따라 LIST[12]에 addr_D -> addr_C -> NULL이 설정 된다.That is, a memory area having an 8K byte size of an address of addr_C set in LIST [13] is divided into two memory areas having a 4K byte size, and each address is called addr_D and addr_C. Accordingly, addr_D-> addr_C-> NULL is set in LIST [12].
한편, 4K 바이트는 또 반으로 분할할 수 있으므로 반으로 분할하면 두개의 2K 바이트로 나눌 수 있다. On the other hand, 4K bytes can be split in half, so splitting in half divides them into two 2K bytes.
즉, LIST[12]에 설정된 addr_D라는 주소의 4K 바이트 크기를 가지는 메모리영역을 2K 바이트 크기를 가지는 두개의 메모리 영역으로 나누고 각각의 주소를 addr_E, addr_D라고 한다. 이에 따라 LIST[11]에 addr_E -> addr_D -> NULL이 설정된다. That is, a memory area having a 4K byte size of an address of addr_D set in LIST [12] is divided into two memory areas having a 2K byte size, and each address is called addr_E and addr_D. Accordingly, addr_E-> addr_D-> NULL is set in LIST [11].
이렇게 하면 최종적으로 addr_E의 주소를 가지는 메모리 영역(232)는 2048바이트의 메모리 용량을 가지므로 요청된 메모리의 용량인 2004 바이트에 가장 가장이 근접한 메모리 용량이 되어 addr_E의 주소를 가지는 메모리 영역(232)이 최종적으로 할당된다.In this case, since the
물론, 최종적으로 버디 메모리 할당절차에 의해 addr_E의 주소를 가지는 메모리 영역(232)이 할당되고 나면 버디 프리 리스트 관리부(124)는 LIST[11]에서 addr_E를 삭제하고 addr_D -> NULL를 설정한다.Of course, after the
이렇게 함으로써 버디 메모리 할당 절차를 수행하고 나면 최종적으로 완성되는 버디 프리 리스트의 형태는 도 10에 도시된 바와 같이 LIST[15]에 NULL 이 설정되고, LIST[14]에 addr_A -> NULL이 설정되고, LIST[13]에 addr_B -> NULL이 설정되고, LIST[12]에 addr_C -> NULL이 설정되고, LIST[11]에 addr_D -> NULL이 설정된 형태가 된다.By doing this, after performing the buddy memory allocation procedure, the final form of the buddy free list is set to NULL in LIST [15], addr_A-> NULL in LIST [14], as shown in FIG. Addr_B-> NULL is set in LIST [13], addr_C-> NULL is set in LIST [12], and addr_D-> NULL is set in LIST [11].
도 11 및 도 12는 본 발명의 일실시예에 따른 임베디드 시스템의 힙 메모리 할당 방법을 수행하는 동작 흐름도이다.11 and 12 are flowcharts illustrating a method of allocating a heap memory of an embedded system according to an exemplary embodiment of the present invention.
도 11 및 도 12를 참조하면, 임의의 프로그램이 실행됨에 따라 임의의 용량만큼의 힙 메모리 할당이 요청되면 메모리 할당 크기 판단부(121)는 요청된 힙 메모리의 용량에 헤더의 용량인 4바이트를 합하여 그 값을 필요한 메모리의 크기로 인식한다(S1).11 and 12, when an arbitrary amount of heap memory allocation is requested as an arbitrary program is executed, the memory allocation
메모리 할당 크기 판단부(121)는 요청된 힙 메모리의 용량에 헤더의 용량인 4바이트를 합하여 이루어진 필요한 메모리의 크기가 미리 설정되어 있는 임계치보다 큰지 여부를 판단한다(S2).The memory allocation
메모리 할당 크기 판단부(121)에 의한 판단 결과, 필요한 메모리의 크기가 임계치보다 큰 경우에는 시퀀셜 메모리 할당을 위해 시퀀셜 메모리 할당부(122)가 구동된다(S3).As a result of the determination by the memory allocation
시퀀셜 메모리 할당부(122)가 구동되면 시퀀셜 메모리 할당부(122)는 요청된 크기의 메모리에 대하여 힙 메모리의 위쪽부터 시퀀셜 검색을 수행하여 메모리 블록의 헤더 정보를 읽어서 미사용중인 메모리 블록을 찾는다(S4).When the
이때, 시퀀셜 메모리 할당부(122)는 미사용중인 메모리 블록의 헤더 정보를 읽어서 미사용중인 메모리 블록의 용량이 필요한 메모리의 크기보다 큰지를 판단한다(S5).At this time, the sequential
시퀀셜 메모리 할당부(122)는 판단결과 미사용중인 메모리 블록의 용량이 필요한 메모리의 크기보다 큰 경우에는 필요한 메모리의 크기를 수용할 수 있는 메모리의 블록의 수를 계산한다(S6).The
시퀀셜 메모리 할당부(122)는 계산된 블록의 개수로 이루어진 메모리 영역의 헤더의 플래그 필드에 해당 메모리 영역이 할당되었음을 표시하는 더티 플래그를 설정하고, 사이즈 필드에 할당된 메모리의 크기를 설정한다(S7).The sequential
시퀀셜 메모리 할당부(122)는 필요한 메모리를 할당한 후에는 할당된 메모리를 제외한 미사용중인 메모리의 영역을 하나의 미사용중인 메모리 영역으로 관리하여 해당 메모리 영역의 시작 주소에 헤더를 생성하고 생성된 헤더의 플래그 필드와 사이즈 필드의 값을 설정한다(S8).After allocating the necessary memory, the
이때 헤더의 플래그 필드에는 해당 메모리 영역이 미사용중임을 표시하도록 0x00가 설정되고, 사이즈 필드에는 미사용중인 메모리 영역의 크기가 설정된다.In this case, 0x00 is set in the flag field of the header to indicate that the corresponding memory area is not in use, and the size of the unused memory area is set in the size field.
한편, 메모리 할당 크기 판단부(121)에 의한 판단 결과, 필요한 메모리의 크기가 임계치의 이하인 경우에는 시퀀셜 메모리 할당을 위해 버디 메모리 할당부(123)이 구동된다(S9).On the other hand, as a result of the determination by the memory allocation
버디 메모리 할당부(123)가 구동되면 버디 메모리 할당부(123)는 요청된 크기의 메모리를 버디 프리 리스트 관리부(124)에 요청한다(S10). When the
버디 프리 리스트 관리부(124)는 버디 프리 리스트에서 요청된 메모리의 크기를 갖는 메모리 영역의 주소를 검색하여 버디 프리 리스트에 해당하는 크기의 메모리 영역이 있는지 여부를 판단한다(S11).The buddy
판단 결과 버디 프리 리스트에 해당하는 크기의 메모리 영역이 있는 경우, 버디 프리 리스트 관리부(124)는 해당 메모리 영역의 주소를 버디 메모리 할당부(123)에 전송하여 해당 메모리를 할당하고 버디 프리 리스트에서 해당 메모리의 주 소를 삭제하여 버디 프리 리스트를 업데이트한다(S12).As a result of the determination, when there is a memory area having a size corresponding to the buddy free list, the buddy
한편, 판단 결과 버디 프리 리스트에 해당하는 크기의 메모리 영역이 존재하지 않는 경우, 버디 프리 리스트 관리부(124)는 요청된 메모리의 용량을 저장하기 위한 버디 메모리를 확보하기 위해 버디 프리 리스트에서 리스트화된 메모리 영역중에서 임의의 메모리 영역에 대하여 반으로 분할하여 요청된 메모리의 용량을 저장할 수 있는 메모리 영역을 확보한다(S13).On the other hand, if there is no memory area of the size corresponding to the buddy free list, the buddy
이에 따라, 버디 프리 리스트 관리부(124)는 버디 프리 리스트에서 요청된 메모리의 용량을 저장할 수 있는 메모리 영역이 확보되면 해당 메모리의 주소를 버디 메모리 할당부(123)에 전송하여 해당 메모리를 할당하고 해당 메모리 영역의 주소를 버디 프리 리스트에서 삭제하고 버디 프리 리스트를 업데이트한다.Accordingly, when the memory area capable of storing the capacity of the memory requested in the buddy free list is secured, the buddy
본 발명은 바람직한 실시예 및 많은 구체적인 변형 실시예를 참조하여 설명되었다. 그렇지만, 구체적으로 설명된 것과는 다른 많은 기타 실시예들이 또한 본 발명의 사상 및 범위 내에 들어간다는 것을 관련 분야의 당업자들은 이해할 것이다.The present invention has been described with reference to preferred embodiments and many specific variations. However, those skilled in the art will understand that many other embodiments other than those specifically described also fall within the spirit and scope of the invention.
본 발명에 의하면, 힙 메모리를 블록단위로 관리하고, 메모리 요청의 크기를 구분하는 임계치(threshold value)를 정해서 소용량인지 대용량인지를 구분해서 대용량인 경우에는 시퀀셜 메모리 할당 절차를 통해 메모리를 할당하고, 소용량인 경우에는 버디 메모리 할당 절차를 통해 메모리를 할당해준다.According to the present invention, the heap memory is managed in units of blocks, and a threshold value for classifying a size of a memory request is determined to classify whether the memory is small or large and allocates memory through a sequential memory allocation procedure. In case of small capacity, memory is allocated through buddy memory allocation procedure.
이에 따라, 소용량의 메모리 할당이 요청되는 경우 버디 프리 리스트(buddy free list)를 이용해서 프리한 메모리 공간을 신속하게 할당할 수 있음으로 실시간 메모리 할당에 효율적이다.Accordingly, when a small memory allocation is requested, the free memory space can be quickly allocated using a buddy free list, which is efficient for real-time memory allocation.
또한, 본 발명에 의하면, 대용량의 메모리 할당이 요청되는 경우에는 힙 메모리의 위쪽부터 메모리를 할당하고, 소용량의 메모리 할당이 요청되는 경우에는 힙 메모리의 아래쪽부터 메모리를 할당해준다.According to the present invention, when a large memory allocation is requested, the memory is allocated from the top of the heap memory, and when a small memory allocation is requested, the memory is allocated from the bottom of the heap memory.
이에 따라, 소용량의 메모리들이 힙 메모리에 산재적으로 할당되는 것을 방지할 수 있음으로 대용량의 메모리 할당시 산재적으로 미리 할당되어 있는 소용량의 메모리들에 의해 발생할 수 있는 외부 플래그먼트를 효과적으로 줄일 수 있다.Accordingly, it is possible to prevent small amounts of memory from being sporadically allocated to the heap memory, thereby effectively reducing external fragmentation that may be caused by the small amounts of memory that are sporadically preallocated when a large amount of memory is allocated. .
Claims (6)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
KR1020050048612A KR100617859B1 (en) | 2005-06-07 | 2005-06-07 | Method for allocation of heap memory in embedded and system thereof |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
KR1020050048612A KR100617859B1 (en) | 2005-06-07 | 2005-06-07 | Method for allocation of heap memory in embedded and system thereof |
Publications (1)
Publication Number | Publication Date |
---|---|
KR100617859B1 true KR100617859B1 (en) | 2006-08-28 |
Family
ID=37601305
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
KR1020050048612A KR100617859B1 (en) | 2005-06-07 | 2005-06-07 | Method for allocation of heap memory in embedded and system thereof |
Country Status (1)
Country | Link |
---|---|
KR (1) | KR100617859B1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR101058969B1 (en) | 2009-05-21 | 2011-08-23 | 엘에스산전 주식회사 | Memory allocation method and memory allocation device using same |
-
2005
- 2005-06-07 KR KR1020050048612A patent/KR100617859B1/en not_active IP Right Cessation
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR101058969B1 (en) | 2009-05-21 | 2011-08-23 | 엘에스산전 주식회사 | Memory allocation method and memory allocation device using same |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112214329B (en) | Memory management method, device, equipment and computer readable storage medium | |
CN110209348B (en) | Data storage method and device, electronic equipment and storage medium | |
CN110609748B (en) | Memory allocation method, electronic equipment and storage medium | |
CN109558091B (en) | Lookup table storage method and device and computer readable storage medium | |
CN111078410A (en) | Memory allocation method and device, storage medium and electronic equipment | |
CN103716383A (en) | Method and device for accessing shared resources | |
CN111679790A (en) | Remote software development storage space distribution method and device | |
US11928359B2 (en) | Memory swapping method and apparatus | |
US8601232B2 (en) | Memory management device, memory management method, memory management program, computer-readable recording medium recording memory management program and integrated circuit | |
KR100617859B1 (en) | Method for allocation of heap memory in embedded and system thereof | |
CN111444117B (en) | Method and device for realizing fragmentation of storage space, storage medium and electronic equipment | |
EP2326076A1 (en) | Display apparatus and control method thereof | |
CN111078587B (en) | Memory allocation method and device, storage medium and electronic equipment | |
CN111008079A (en) | Process management method, device, storage medium and electronic equipment | |
US7681009B2 (en) | Dynamically updateable and moveable memory zones | |
CN113760325B (en) | Container environment updating method and device | |
CN115629875A (en) | Memory page processing method and device and electronic equipment | |
KR101058969B1 (en) | Memory allocation method and memory allocation device using same | |
US6535969B1 (en) | Method and apparatus for allocating free memory | |
CN115269530A (en) | Data synchronization method, electronic device and computer-readable storage medium | |
CN114489486B (en) | Industry data long storage method, equipment and storage medium | |
KR100671692B1 (en) | Method for garbage collection having individual period for each application program and terminal thereof | |
CN111078407A (en) | Memory management method and device, storage medium and electronic equipment | |
CN110764707A (en) | Data processing method and device | |
CN115190089B (en) | Message storage method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A201 | Request for examination | ||
E701 | Decision to grant or registration of patent right | ||
GRNT | Written decision to grant | ||
FPAY | Annual fee payment |
Payment date: 20120727 Year of fee payment: 7 |
|
FPAY | Annual fee payment |
Payment date: 20130724 Year of fee payment: 8 |
|
FPAY | Annual fee payment |
Payment date: 20140724 Year of fee payment: 9 |
|
FPAY | Annual fee payment |
Payment date: 20150724 Year of fee payment: 10 |
|
LAPS | Lapse due to unpaid annual fee |