JP5012040B2 - Memory allocation method - Google Patents

Memory allocation method Download PDF

Info

Publication number
JP5012040B2
JP5012040B2 JP2007013959A JP2007013959A JP5012040B2 JP 5012040 B2 JP5012040 B2 JP 5012040B2 JP 2007013959 A JP2007013959 A JP 2007013959A JP 2007013959 A JP2007013959 A JP 2007013959A JP 5012040 B2 JP5012040 B2 JP 5012040B2
Authority
JP
Japan
Prior art keywords
area
secured
securing
address space
temporary
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
JP2007013959A
Other languages
Japanese (ja)
Other versions
JP2008181314A (en
Inventor
英一郎 川口
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Corp
Original Assignee
NEC Corp
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 NEC Corp filed Critical NEC Corp
Priority to JP2007013959A priority Critical patent/JP5012040B2/en
Publication of JP2008181314A publication Critical patent/JP2008181314A/en
Application granted granted Critical
Publication of JP5012040B2 publication Critical patent/JP5012040B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Memory System (AREA)

Description

本発明はメモリ割り当て方法に関し、特に、実アドレス空間上で連続領域が確保されることを保障するメモリ割り当て方法に関するものである。   The present invention relates to a memory allocation method, and more particularly to a memory allocation method that ensures that a continuous area is secured in a real address space.

従来より、実メモリ空間の領域を確保する場合、連続する空き領域のサイズと要求サイズを比較し、空き領域のサイズが要求サイズ以上であればその空き領域を割り当て、空き領域のサイズが要求サイズ未満であれば上位アドレスにある空き領域に対して上記処理を繰り返し、最初に見つかった空き領域を割り当てるという処理が行われていた(例えば、特許文献1参照)。
プログラムによっては、仮想アドレス空間において動的に確保したメモリ領域を、実アドレス空間に変換して使用しなければならないケースが存在する。具体的にはBIOSコールするときのスタック領域/ワーク領域や周辺デバイスが使用する領域などがこれに該当する。ここで複数ページから構成される仮想アドレス空間から動的にメモリ確保する場合を考える。今、実メモリ上に使用不可領域があると仮定すると、単純に空き領域を使用した場合、分散してアドレス割り当てを行うことがあり、仮想アドレス空間上で連続して確保した領域が、実アドレス空間上では連続した領域にならない可能性がある。その場合、本領域を実アドレス空間として使用すると、割り当てられた実アドレス空間以外にアクセスすることになり、正しいメモリアクセスができない。
図8にこの例を示す。図8は、仮想アドレス空間3と実アドレス空間4との対応付けを示している。例えば、仮想アドレス空間3上の領域31は、ページV0,V1,V2,V3から構成されている。同様に、実アドレス空間4上の領域41は、ページP0,P1,P2、・・・、P10から構成されている。今、仮に、実アドレス空間上のページP2とページP6が、使用不可領域であると仮定した場合、単純に空き領域を使用する方法のひとつとして、仮想アドレス空間3のページV0に実アドレス空間4のページP1を割り当て、以下同様に、ページV1にページP3を、ページV2にページP5を,ページV3にページP4をそれぞれ割り当てることがあげられる。このとき、仮想アドレス空間3から動的に確保した領域の先頭アドレスと最終アドレスの両方が、ページV2内に収まっていたと仮定すると、実アドレス空間上でもページP5内に収まっているので、この領域を実アドレス空間に変換し利用しても連続しているため問題はない。
しかし、動的に確保した領域の先頭アドレスがページV0内で、最終アドレスがページV1内であった場合、実アドレス空間4上では、それぞれ、P1とP3に該当し、実アドレス空間4上では連続にならないということになる。このとき、この領域を実アドレスに変換して利用した場合、正しいメモリアクセスができない問題が生じる。このことを回避するために、対応する実アドレス空間4上の領域もすべて連続であることを保障してアドレス割り当てを行うことが考えられる。
しかしながら、割り当て容量よりも小さい間隔で「使用不可領域」が存在した場合、「使用不可領域」を回避したアドレス空間を使用しなければならない。その結果、「使用不可領域」に挟まれた領域を有効に利用できない問題がある。この例を示したものが図9となる。ここで、仮に、実アドレス空間4上のページP2とページP6が、使用不可領域であると仮定した場合、前述のように対応する実アドレス空間4上の領域もすべて連続であることを保障しようとすると、ページV0,V1,V2,V3に対して、それぞれ実アドレス空間4上で連続したページP7,P8,P9,P10を対応させなければならない。
これは、ページP0,P1,P3,P4,P5は領域として空いているが、連続して対応づけようとしても、ページP2、または、ページP6の使用不可領域と重複してしまうため、実アドレス空間4上で連続した領域への対応づけができないためである。
特開2001−236249号公報
Conventionally, when allocating the real memory space area, the size of the continuous free area is compared with the requested size, and if the free area size is equal to or larger than the requested size, the free area is allocated, and the free area size is the requested size. If it is less, the above process is repeated for the empty area at the higher address, and the process of assigning the empty area found first is performed (for example, see Patent Document 1).
Depending on the program, there is a case where a memory area dynamically secured in the virtual address space must be converted into a real address space and used. Specifically, this corresponds to a stack area / work area when a BIOS call is made, an area used by a peripheral device, and the like. Here, consider a case where memory is dynamically secured from a virtual address space composed of a plurality of pages. Assuming that there is an unusable area in real memory, if you simply use an empty area, addresses may be allocated in a distributed manner, and the area allocated continuously in the virtual address space is the real address. It may not be a continuous area in space. In this case, if this area is used as a real address space, access is made to other than the allocated real address space, and correct memory access cannot be performed.
FIG. 8 shows an example of this. FIG. 8 shows the correspondence between the virtual address space 3 and the real address space 4. For example, the area 31 on the virtual address space 3 is composed of pages V0, V1, V2, and V3. Similarly, the area 41 on the real address space 4 is composed of pages P0, P1, P2,. If it is assumed that the page P2 and the page P6 in the real address space are unusable areas, as one method of simply using the free area, the real address space 4 is added to the page V0 in the virtual address space 3. In the same manner, page P3 is assigned to page V1, page P5 is assigned to page V2, and page P4 is assigned to page V3. At this time, if it is assumed that both the start address and the final address of the area dynamically secured from the virtual address space 3 are within the page V2, this area is also within the page P5 in the real address space. There is no problem because it is continuous even if it is converted to a real address space and used.
However, when the first address of the dynamically allocated area is in page V0 and the last address is in page V1, it corresponds to P1 and P3 on the real address space 4, respectively. It will not be continuous. At this time, if this area is converted into a real address and used, there is a problem that correct memory access cannot be performed. In order to avoid this, it is conceivable to perform address assignment while ensuring that the corresponding areas on the real address space 4 are all continuous.
However, when “unusable areas” exist at intervals smaller than the allocated capacity, an address space that avoids the “unusable areas” must be used. As a result, there is a problem that an area sandwiched between “unusable areas” cannot be used effectively. An example of this is shown in FIG. Here, if it is assumed that the page P2 and the page P6 on the real address space 4 are unusable areas, it will be ensured that the corresponding areas on the real address space 4 are all continuous as described above. Then, pages P7, P8, P9, and P10 that are continuous on the real address space 4 must be associated with the pages V0, V1, V2, and V3, respectively.
This is because the pages P0, P1, P3, P4, and P5 are vacant as areas, but even if they are continuously associated, they overlap with the unusable areas of the page P2 or the page P6. This is because it is not possible to associate with a continuous area on the space 4.
JP 2001-236249 A

このように、従来のメモリ割り当て方法では、実アドレス空間4上でのページP0,P1,P3,P4,P5は、未使用領域となり、メモリを有効活用できない状態にあるという問題があった。
本発明はこのような状況に鑑みてなされたものであり、連続した実アドレス空間を持てない計算機においても仮想アドレス空間から動的に確保した領域が実アドレス空間上においても連続した領域として確保されることを保障することができるようにするものである。
As described above, the conventional memory allocation method has a problem that the pages P0, P1, P3, P4, and P5 on the real address space 4 are unused areas and the memory cannot be effectively used.
The present invention has been made in view of such a situation, and even in a computer that cannot have a continuous real address space, an area dynamically secured from the virtual address space is secured as a continuous area in the real address space. It is to be able to guarantee that.

本発明の一態様におけるメモリ割り当て方法は、仮想アドレス空間上で確保された連続領域に対応して実アドレス空間上で連続領域が確保されることを保障するメモリ割り当て方法であって、前記仮想アドレス空間上で要求サイズ以上の空き領域を検索する検索ステップと、前記空き領域から前記要求サイズの領域が確保されるとき、前記領域がページ境界を跨ぐか否かを判定する判定ステップと、前記判定の結果、ページ境界を跨ぐと判定された場合、前記領域のうち、ページ境界を跨ぐ最小のサイズの領域を仮領域として確保する仮領域確保ステップと、前記仮領域確保ステップにおいて確保された前記仮領域を除き、再度、前記仮想アドレス空間上において領域の確保が行われる領域確保ステップと、前記領域確保ステップにおいて確保された領域がページ境界を跨がないとき、前記領域を確保領域として確定する領域確定ステップと、前記仮領域を解放する解放ステップとを備えることを特徴とする。
また、前記空き領域から前記要求サイズ分の前記領域を差し引いた残りの領域のサイズが、基準となる最低サイズ以上ない場合、前記空き領域全体が仮領域として確保されるようにすることができる。
また、前記仮領域は、前記領域の最上位アドレスを含む前記仮想アドレス空間上のページの最下位アドレスと、前記領域の最下位アドレスを挟む領域とすることができる。
また、前記領域確保ステップにおいて連続領域が確保できなかった場合、確保失敗とされるようにすることができる。
本発明の一態様におけるメモリ割り当て装置は、仮想アドレス空間上で確保された連続領域に対応して実アドレス空間上で連続領域が確保されることを保障するメモリ割り当て装置であって、前記仮想アドレス空間上で要求サイズ以上の空き領域を検索する検索手段と、前記空き領域から前記要求サイズの領域が確保されるとき、前記領域がページ境界を跨ぐか否かを判定する判定手段と、前記判定の結果、ページ境界を跨ぐと判定された場合、前記領域のうち、ページ境界を跨ぐ最小のサイズの領域を仮領域として確保する仮領域確保手段と、前記仮領域確保手段によって確保された前記仮領域を除き、再度、前記仮想アドレス空間上において領域の確保が行われる領域確保手段と、前記領域確保手段によって確保された領域がページ境界を跨がないとき、前記領域を確保領域として確定する領域確定手段と、前記仮領域を解放する解放手段とを備えることを特徴とする。
また、前記空き領域から前記要求サイズ分の前記領域を差し引いた残りの領域のサイズが、基準となる最低サイズ以上ない場合、前記空き領域全体が仮領域として確保されるようにすることができる。
また、前記仮領域は、前記領域の最上位アドレスを含む前記仮想アドレス空間上のページの最下位アドレスと、前記領域の最下位アドレスを挟む領域とすることができる。
また、前記領域確保手段が連続領域を確保できなかった場合、確保失敗とされるようにすることができる。
本発明の一態様におけるメモリ割り当てプラグラムは、仮想アドレス空間上で確保された連続領域に対応して実アドレス空間上で連続領域が確保されることを保障するメモリ割り当て装置におけるメモリ割り当てプログラムであって、前記仮想アドレス空間上で要求サイズ以上の空き領域を検索する検索ステップと、前記空き領域から前記要求サイズの領域が確保されるとき、前記領域がページ境界を跨ぐか否かを判定する判定ステップと、前記判定の結果、ページ境界を跨ぐと判定された場合、前記領域のうち、ページ境界を跨ぐ最小のサイズの領域を仮領域として確保する仮領域確保ステップと、前記仮領域確保ステップにおいて確保された前記仮領域を除き、再度、前記仮想アドレス空間上において領域の確保が行われる領域確保ステップと、前記領域確保ステップにおいて確保された領域がページ境界を跨がないとき、前記領域を確保領域として確定する領域確定ステップと、前記仮領域を解放する解放ステップとを前記メモリ割り当て装置に実行させることを特徴とする。
また、前記空き領域から前記要求サイズ分の前記領域を差し引いた残りの領域のサイズが、基準となる最低サイズ以上ない場合、前記空き領域全体が仮領域として確保されるようにすることができる。
また、前記仮領域は、前記領域の最上位アドレスを含む前記仮想アドレス空間上のページの最下位アドレスと、前記領域の最下位アドレスを挟む領域とすることができる。
また、前記領域確保ステップにおいて連続領域が確保できなかった場合、確保失敗とされるようにすることができる。
A memory allocation method according to an aspect of the present invention is a memory allocation method for ensuring that a continuous area is secured in a real address space corresponding to a continuous area secured in a virtual address space, the virtual address A search step for searching for a free area that is equal to or larger than the requested size in space; a determination step for determining whether the area crosses a page boundary when an area of the requested size is secured from the free area; and the determination as a result, when it is determined that straddles a page boundary, among the regions, and a temporary area securing step of securing the minimum region size across the page boundary as the temporary area, said temporary reserved in the temporary area securing step Except for the area, again in the area securing step in which the area is secured in the virtual address space and the area securing step. When regions are not cross a page boundary, characterized by comprising a region determination step of determining the area as a reserved area, a release step of releasing the temporary area.
Further, when the size of the remaining area obtained by subtracting the area corresponding to the requested size from the free area is not equal to or smaller than a reference minimum size, the entire free area can be secured as a temporary area.
The temporary area may be an area sandwiching the lowest address of a page on the virtual address space including the highest address of the area and the lowest address of the area.
Further, when the continuous area cannot be secured in the area securing step, the securing may be failed.
A memory allocation device according to an aspect of the present invention is a memory allocation device that ensures that a continuous area is secured in a real address space corresponding to a continuous area secured in a virtual address space, the virtual address A search unit that searches for a free area that is equal to or larger than the requested size in space; a determination unit that determines whether the area crosses a page boundary when the area of the requested size is secured from the free area; and the determination As a result, when it is determined that the page boundary is crossed, a temporary area securing unit that secures, as a temporary area, a minimum size area that crosses the page boundary, and the temporary area secured by the temporary area securing unit. except area, again, the virtual address and the area ensuring means which ensures a region is performed in the space, area page boundary secured by said space securing means When not straddled, characterized in that it comprises a region determining means for determining the area as a reserved area, and a release means for releasing the temporary area.
Further, when the size of the remaining area obtained by subtracting the area corresponding to the requested size from the free area is not equal to or smaller than a reference minimum size, the entire free area can be secured as a temporary area.
The temporary area may be an area sandwiching the lowest address of a page on the virtual address space including the highest address of the area and the lowest address of the area.
In addition, when the area securing unit cannot secure a continuous area, the securing may be failed.
A memory allocation program according to an aspect of the present invention is a memory allocation program in a memory allocation device that ensures that a continuous area is secured in a real address space corresponding to a continuous area secured in a virtual address space. A search step for searching for a free area not less than a requested size in the virtual address space, and a determination step for determining whether or not the area crosses a page boundary when an area of the requested size is secured from the free area when the result of the determination, if it is determined that straddles a page boundary, among the regions, and a temporary area securing step of securing the minimum region size across the page boundary as the temporary area, secured in the temporary area securing step An area reservation step in which an area is reserved again in the virtual address space, except for the temporary area that has been When flop and, an area reserved in the area securing step does not cross a page boundary, executes an area determination step of determining the area as a reserved area, a release step of releasing the temporary area in the memory allocation unit It is characterized by making it.
Further, when the size of the remaining area obtained by subtracting the area corresponding to the requested size from the free area is not equal to or smaller than a reference minimum size, the entire free area can be secured as a temporary area.
The temporary area may be an area sandwiching the lowest address of a page on the virtual address space including the highest address of the area and the lowest address of the area.
Further, when the continuous area cannot be secured in the area securing step, the securing may be failed.

本発明のメモリ割り当て方法によれば、仮想アドレス空間から動的に確保した領域を実アドレス空間上でも連続したものとして扱うことが可能となる。即ち、仮想アドレス空間上で動的に確保した連続領域が実アドレス空間上でも連続していることを保障することができる。   According to the memory allocation method of the present invention, it is possible to treat an area dynamically secured from the virtual address space as continuous in the real address space. That is, it is possible to ensure that the continuous area dynamically secured in the virtual address space is continuous in the real address space.

本発明は、仮想アドレス空間において動的に確保されるメモリ領域が、実アドレス空間においても連続領域であることを保障し、メモリ空間を効率的に利用できるようにするものである。なお、本発明は、アプリケーション毎のページ管理ができないソフトウェアや、連続した実メモリ空間が取れない計算機において有効である。   The present invention ensures that the memory area that is dynamically secured in the virtual address space is a continuous area in the real address space, so that the memory space can be used efficiently. It should be noted that the present invention is effective in software that cannot manage pages for each application or a computer that cannot provide continuous real memory space.

図1は、本発明が適用されるコンピュータの構成例を示している。図1において、記憶領域確保処理2は、仮想アドレス空間から動的にメモリを確保するものであり、オペレーティングシステム、もしくは、アプリケーション1から動的メモリ確保の要求を受けた際、実際にメモリを確保する処理を行い、その結果を要求元に返す機能を有している。   FIG. 1 shows a configuration example of a computer to which the present invention is applied. In FIG. 1, the storage area securing process 2 dynamically secures memory from the virtual address space, and actually secures memory when a request for securing dynamic memory is received from the operating system or application 1. And a function for returning the result to the request source.

記憶領域確保処理2は、前処理21と第一記憶領域確保手段22と第二記憶領域確保手段23を有している。前処理21では、確保対象の領域中の空き領域を検索する機能をもっており、その結果から、第一記憶領域確保手段22と第二記憶領域確保手段23を選択する機能も有している。   The storage area securing process 2 includes a pre-process 21, a first storage area securing unit 22, and a second storage area securing unit 23. The preprocessing 21 has a function of searching for an empty area in the area to be secured, and also has a function of selecting the first storage area securing means 22 and the second storage area securing means 23 from the result.

第一記憶領域確保手段22と第二記憶領域確保手段23の違いは、検索された空き領域の容量と実際に確保する領域の容量の関係に起因して処理がわかれるものである。第一記憶領域確保手段22が選択された場合、最初に、前処理21で検出された空き領域から、要求容量を採取した場合のメモリ領域アドレスを計算する。この計算されたメモリ領域の先頭と最後のアドレスが仮想アドレス空間を管理するページ境界を跨いでいなければ、この動的メモリ確保は、物理アドレス空間上も連続領域であることを保障できるため、第一通常確保手段221に進み、実際にメモリ確保を行う。   The difference between the first storage area securing means 22 and the second storage area securing means 23 is that the processing is determined due to the relationship between the capacity of the searched free area and the capacity of the actually reserved area. When the first storage area securing unit 22 is selected, first, the memory area address when the requested capacity is collected from the free area detected in the preprocessing 21 is calculated. If the start and end addresses of this calculated memory area do not straddle the page boundary managing the virtual address space, this dynamic memory allocation can guarantee that the physical address space is also a continuous area. Proceeding to the first normal securing means 221, the memory is actually secured.

逆に、計算されたメモリ領域の先頭と最後のアドレスがページ境界を跨いでいた場合、動的メモリ確保は、物理アドレス空間上も連続領域であることを保障できないため、第一回避確保手段222に進む。第一回避確保手段222では、このページ境界を跨ぐ領域に仮領域を配置し、再帰的に記憶領域確保処理2に進み、再確保を試みる。   On the other hand, if the calculated first and last addresses of the memory area cross the page boundary, the dynamic memory reservation cannot guarantee that the physical address space is a continuous area. Proceed to The first avoidance securing means 222 arranges a temporary area in an area straddling the page boundary, recursively advances to the storage area securing process 2 and tries to secure again.

再確保において、第一通常確保手段221、もしくは、第二通常確保手段232で実アドレス空間上も連続である領域を確保できた場合には、再帰的に記憶領域確保処理2をコールした第一回避確保手段222に確保できた先頭アドレスと共に確保成功として戻る。再帰的な実行から戻った回避確保手段222は、先に確保した仮領域を解放し、再確保において、確保できた領域のアドレス要求元に返却する。   In re-allocation, when the first normal allocation unit 221 or the second normal allocation unit 232 can allocate an area that is continuous in the real address space, the storage area allocation process 2 is called recursively. It returns as a successful reservation together with the start address that can be secured in the avoidance securing means 222. The avoidance securing unit 222 that has returned from the recursive execution releases the temporary area that has been secured first, and returns it to the address requester of the secured area in the re-allocation.

なお、再確保処理は、2度目だけでなく確保できるまで試みるが、最大で(ページ数−1)回繰り返されることになる。また、ページ境界を跨ぐ領域に仮領域を配置しなければならないのは、再確保を試みた際、当該領域において再度確保しようとしてしまうのを回避するためである。   Note that the re-allocation processing is attempted not only for the second time but also until it can be allocated, but is repeated at most (number of pages-1) times. Also, the provisional area must be arranged in the area that crosses the page boundary in order to avoid re-allocation in the area when re-allocation is attempted.

他方、第二記憶領域確保手段23が選択された場合、最初に、前処理21で検出された空き領域を使用する領域として確保する。この領域が仮想アドレス空間を管理するページ境界を跨いでいなければ、この動的メモリ確保は、物理アドレス空間上も連続領域であることを保障できるため、第二通常確保手段231に進み、確保領域として確定させる。   On the other hand, when the second storage area securing means 23 is selected, first, the free area detected in the preprocessing 21 is secured as an area to be used. If this area does not straddle the page boundary that manages the virtual address space, the dynamic memory allocation can be guaranteed to be a continuous area in the physical address space. Confirm as an area.

逆に、このメモリ領域の先頭と最後のアドレスがページ境界を跨いでいた場合、動的メモリ確保は、物理アドレス空間上も連続領域であることを保障できないため、第二回避確保手段232に進む。第二回避確保手段232では、このページ境界を跨ぐ領域を仮領域とし、再帰的に記憶領域確保処理2に進み、再確保を試みる。   On the other hand, if the beginning and end addresses of this memory area straddle the page boundary, the dynamic memory allocation cannot guarantee that the physical address space is a continuous area, so the process proceeds to the second avoidance securing means 232. . In the second avoidance securing means 232, an area straddling the page boundary is set as a temporary area, and the process proceeds recursively to the storage area securing process 2 to try to secure again.

第一回避確保手段222と同様に、再確保において、第一通常確保手段221、もしくは、第二通常確保手段232で実アドレス空間上も連続である領域を確保できた場合には、再帰的に記憶領域確保処理2をコールした第二回避確保手段232に確保できた先頭アドレスと共に確保成功として戻る。   Similar to the first avoidance securing means 222, when the first normal securing means 221 or the second normal securing means 232 can secure a continuous area in the real address space in the re-reserving, recursively. It returns as a successful reservation together with the head address that can be secured in the second avoidance securing means 232 that called the storage area securing process 2.

再帰的な実行から戻った回避確保手段232は、先に確保した仮領域を解放し、再確保において、確保できた領域のアドレス要求元に返却する。   The avoidance securing unit 232 that has returned from the recursive execution releases the provisional area secured first, and returns it to the address requester of the secured area in the re-allocation.

以上の動作により、ページ境界を跨ぐ動的メモリ確保を回避することができ、実アドレス空間における連続性も保障できるようになる。   With the above operation, it is possible to avoid securing dynamic memory across page boundaries, and to ensure continuity in the real address space.

図1を参照すると、本実施の形態は、オペレーティングシステム、もしくは、アプリケーション1と記憶領域確保処理2とを含む。オペレーティングシステム、もしくは、アプリケーション1のオペレーティングシステムの種別に制限はなく、オペレーティングシステムは、オペレーティングシステムの管理するワーク領域から、例えば、タスク領域、セマフォ領域、タイマ領域などの動的なメモリ確保要求や、ヒープ領域からの動的メモリ確保要求を実施する。同様にアプリケーションからもヒープ領域からの動的なメモリ確保要求、たとえば、C言語でのmalloc()関数コールなどが実施される。   Referring to FIG. 1, the present embodiment includes an operating system or application 1 and a storage area securing process 2. There is no limitation on the type of the operating system or operating system of the application 1, and the operating system, for example, a dynamic memory allocation request such as a task area, a semaphore area, or a timer area from the work area managed by the operating system, Implement a dynamic memory allocation request from the heap area. Similarly, a dynamic memory allocation request from the heap area, for example, a malloc () function call in C language is executed from the application.

記憶領域確保処理2は、前処理21と、第一記憶領域確保手段22と、第二記憶領域確保手段23とを含む。記憶領域確保処理2では、オペレーティングシステム、もしくは、アプリケーション1からの動的なメモリ確保要求を受け付け、指定された領域からの動的なメモリ確保を実行し、確保が成功した場合には、その確保された先頭アドレスをオペレーティングシステム、もしくは、アプリケーション1に返却する機能を有する。また、確保が失敗した場合には、確保失敗を通知する機能を有する。   The storage area securing process 2 includes pre-processing 21, first storage area securing means 22, and second storage area securing means 23. In the storage area securing process 2, a dynamic memory securing request from the operating system or the application 1 is received, the dynamic memory securing from the designated area is executed, and if the securing succeeds, the securing is performed A function of returning the head address to the operating system or application 1. In addition, it has a function of notifying the securing failure when securing fails.

前処理21では、指定された領域の中から、要求容量を満たす空き領域を検索し、第一記憶領域確保手段22か第二記憶領域確保手段23のどちらを実行するか判断する機能を備えている。ここでは、第一記憶領域確保手段22か第二記憶領域確保手段23かの選択基準は、検索された空き領域から今回の要求容量を確保しても、残りの空き領域がさらなる確保要求に応えられる場合には、第一記憶領域確保手段22を使用し、応えられない場合は、第二記憶領域確保手段23を使用するものとする。第一記憶領域確保手段22は、第一通常確保手段221と第一回避確保手段222を有し、確保を行う予定である領域のアドレス計算をする機能も保持する。   The pre-processing 21 has a function of searching for a free area satisfying the requested capacity from the designated areas and determining whether to execute the first storage area securing means 22 or the second storage area securing means 23. Yes. Here, the selection criterion of the first storage area securing unit 22 or the second storage area securing unit 23 is that the remaining free area responds to a further securing request even if the requested capacity is secured from the searched free area. If the answer is yes, the first storage area securing means 22 is used, and if not, the second storage area securing means 23 is used. The first storage area securing unit 22 includes a first normal securing unit 221 and a first avoidance securing unit 222, and also has a function of calculating an address of an area scheduled to be secured.

第一通常確保手段221は、今回、確保する領域が、ページ境界を跨がない領域であった場合に、実際に、検出された領域から要求容量の動的メモリ確保を実行する機能と、得られた動的メモリ領域のアドレスを第一記憶領域確保手段22に通知する機能を有する。   The first normal securing means 221 has a function to execute the dynamic memory securing of the requested capacity from the detected area when the area to be secured this time is an area that does not cross the page boundary. A function of notifying the address of the obtained dynamic memory area to the first storage area securing means 22.

第一回避確保手段222は、確保する領域が、ページ境界を跨ぐ領域であった場合、当該領域を跨ぐ最小容量の仮領域を配置する機能と再帰的に記憶領域確保処理2を呼び出す機能と、記憶領域確保処理2の処理が終ったときに仮領域を解放する機能と、再帰的に実行することによって得られた動的メモリ領域のアドレス、もしくは、確保失敗したことを第一記憶領域確保手段22に通知する機能を有する。   The first avoidance securing means 222, when the area to be secured is an area that crosses the page boundary, a function that arranges a temporary area with the minimum capacity across the area and a function that recursively calls the storage area securing process 2; The function of releasing the temporary area when the storage area securing process 2 is finished, and the address of the dynamic memory area obtained by executing recursively, or the first storage area securing means that the securing has failed 22 is notified.

第二記憶領域確保手段23は、第一記憶領域確保手段22に対し、検索された空き領域の容量が異なるため、機能も異なっている。第二記憶領域確保手段23も、第二通常確保手段231と第二回避確保手段232を有する。   The second storage area securing means 23 is different in function from the first storage area securing means 22 because the capacity of the searched free area is different. The second storage area securing unit 23 also includes a second normal securing unit 231 and a second avoidance securing unit 232.

まず、第二記憶領域確保手段23は、検索された空き領域全体を要求サイズの領域として確保する。その後、確保した領域が、ページ境界を跨がない領域であった場合には、第二通常確保手段231を選択し、跨ぐ領域であった場合には、第二回避確保手段232を選択する機能を備える。   First, the second storage area securing unit 23 secures the entire searched free area as a requested size area. Thereafter, when the secured area is an area that does not cross the page boundary, the second normal securing means 231 is selected, and when the secured area is the straddling area, the second avoidance securing means 232 is selected. Is provided.

第二通常確保手段231は、確保した領域が、ページ境界を跨がない領域であった場合に、その領域を要求容量の動的メモリ確保として確定する機能と、得られた動的メモリ領域のアドレスを第二記憶領域確保手段23に通知する機能を有する。   The second normal securing means 231 has a function of determining the secured area as dynamic memory securing of the requested capacity when the secured area is an area that does not cross the page boundary, and the obtained dynamic memory area It has a function of notifying the address to the second storage area securing means 23.

第二回避確保手段232は、確保した領域が、ページ境界を跨ぐ領域であった場合、当該領域を仮領域とする機能と、再帰的に記憶領域確保処理2を呼び出す機能と、記憶領域確保処理2の処理が終ったときに仮領域を解放する機能と、再帰的に実行することによって得られた動的メモリ領域のアドレス、もしくは、確保失敗したことを第二記憶領域確保手段23に通知する機能を有する。   The second avoidance securing means 232, when the secured area is an area that crosses the page boundary, a function that makes the area a temporary area, a function that recursively calls the storage area securing process 2, and a storage area securing process Notifies the second storage area securing means 23 of the function of releasing the temporary area when the processing of 2 is completed and the address of the dynamic memory area obtained by recursively executing or the allocation failure It has a function.

次に、図1乃至図4、及び図5のフローチャートを参照して本発明の実施の形態の動作について詳細に説明する。図2は、仮想アドレス空間において確保された連続領域(ページV0,V1,V2,V3)に対応して、実アドレス空間上でも連続領域(ページP7、P8,P9,P10)を確保することができるが、「使用不可領域(ページP2,P6)」で挟まれた領域(ページP3,P4,P5)が無駄になること、および、未使用な領域(ページP3,P4,P5)は存在するが、実アドレス空間上、仮想アドレス空間上で確保された連続領域(ページV0,V1,V2,V3)に対応する連続領域を確保することができない状態を示している。   Next, the operation of the embodiment of the present invention will be described in detail with reference to the flowcharts of FIGS. 1 to 4 and FIG. FIG. 2 shows that continuous areas (pages P7, P8, P9, P10) can be secured in the real address space corresponding to the continuous areas (pages V0, V1, V2, V3) secured in the virtual address space. Yes, but the area (pages P3, P4, P5) sandwiched between the “unusable areas (pages P2, P6)” is wasted, and there are unused areas (pages P3, P4, P5). Shows a state in which a continuous area corresponding to continuous areas (pages V0, V1, V2, and V3) secured in the real address space and the virtual address space cannot be secured.

図3は、本発明の解決すべき課題を模式的に示している。動的メモリ確保によって、仮想アドレス空間上で確保された領域のページV0が実アドレス空間上のページP1に対応し、ページV1がページP3に対応し、ページV2がページP5に対応し、ページV3がページP4に対応するとき、仮想アドレス空間上のページV3内の領域#1は、実アドレス空間上では、ページP4内に割り当てられる。この場合、領域#1は仮想アドレス空間上でページを跨いでいないので、実アドレス空間上でも連続領域であることが保障される。一方、仮想アドレス空間上で確保された領域#2は、仮想アドレス空間上でページV0とV1を跨いでいるので、実アドレス空間上では、連続領域であることが保障されず、この例では、「使用不可領域(ページP2)」を挟んでページP1とP3に分割されて割り当てられる。即ち、実アドレス空間上において分割され、連続領域とはならない。   FIG. 3 schematically shows the problem to be solved by the present invention. Due to the dynamic memory allocation, the page V0 in the area allocated in the virtual address space corresponds to the page P1 in the real address space, the page V1 corresponds to the page P3, the page V2 corresponds to the page P5, and the page V3. Corresponds to page P4, area # 1 in page V3 in the virtual address space is allocated in page P4 in the real address space. In this case, since the area # 1 does not straddle pages in the virtual address space, it is guaranteed that the area # 1 is a continuous area even in the real address space. On the other hand, since the area # 2 secured in the virtual address space straddles the pages V0 and V1 in the virtual address space, it is not guaranteed to be a continuous area in the real address space. In this example, It is divided and assigned to pages P1 and P3 across the “unusable area (page P2)”. That is, it is divided on the real address space and does not become a continuous area.

図4は、図3に示した課題を解決する方法を示す模式図である。図4(a)は、仮想アドレス空間上で新規の領域が確保される前の状態を示している。図4(b)は、仮想アドレス空間上においてページV1,V2を跨ぐ領域が確保領域として確保されようとしている状態を示している。図4(c)は、仮想アドレス空間上において、ページV1,V2を跨ぐ領域に仮領域を確保した状態を示している。ただし、仮領域は、ページ境界を跨ぐ最小のサイズの領域とされる。この例では、使用中の領域は、ページV0からV1の途中までを占め、仮領域は、使用中の領域の最上位アドレスの上位側の次のアドレスから、ページV2の最下位アドレスまでの領域となる。   FIG. 4 is a schematic diagram showing a method for solving the problem shown in FIG. FIG. 4A shows a state before a new area is secured in the virtual address space. FIG. 4B shows a state in which an area straddling pages V1 and V2 is about to be secured as a secured area in the virtual address space. FIG. 4C shows a state where a temporary area is secured in an area straddling pages V1 and V2 in the virtual address space. However, the temporary area is an area having the minimum size across the page boundary. In this example, the area in use occupies the middle of pages V0 to V1, and the temporary area is the area from the next address on the upper side of the highest address of the area in use to the lowest address of page V2. It becomes.

図4(d)は、要求サイズの確保領域を再度取得した状態を示している。仮領域として確保された領域は、要求サイズの領域確保の対象外とされる。このため、この例では、確保領域は、仮領域の上位側の次のアドレスから確保され、ページV2内に収まっている。図4(e)は、確保領域が取得できた後、仮領域が解放された状態を示している。仮想アドレス空間上で連続領域として確保された確保領域は、ページを跨いでいないので、実アドレス空間上でも連続領域であることが保障される。   FIG. 4D shows a state in which the required size securing area is acquired again. The area secured as the temporary area is not subject to securing the area of the required size. For this reason, in this example, the secured area is secured from the next address on the upper side of the temporary area and is contained in the page V2. FIG. 4E shows a state in which the temporary area is released after the reserved area has been acquired. Since the secured area secured as a continuous area in the virtual address space does not straddle a page, it is guaranteed that the secured area is also a continuous area in the real address space.

以下、図5のフローチャートを参照して本実施の形態の動作について説明する。まず、オペレーティングシステム、もしくは、アプリケーション1から動的メモリ確保要求が発行される(ステップS1)。記憶領域確保処理2は、オペレーティングシステム、もしくは、アプリケーション1からメモリ確保要求を受け取ると、前処理21にて仮想アドレス空間上において確保対象領域中の空き領域を検索する(ステップS2、S3,S9)。一般に、空き領域の割り当て方法には、先頭一致(First−Fit)、最良一致(Best−Fit)、最悪一致(Worst−Fit)があるが、ここでは、先頭一致を例に説明し、最良一致(Best−Fit)、最悪一致(Worst−Fit)については後述する。   The operation of the present embodiment will be described below with reference to the flowchart of FIG. First, a dynamic memory allocation request is issued from the operating system or application 1 (step S1). When the storage area securing process 2 receives a memory securing request from the operating system or the application 1, the pre-process 21 searches for a free area in the secured area in the virtual address space (steps S2, S3, and S9). . In general, free space allocation methods include a first match (First-Fit), a best match (Best-Fit), and a worst match (Worst-Fit). (Best-Fit) and worst match (Worst-Fit) will be described later.

先頭一致で検索するため、検索した空き領域のうち、要求容量以上の領域が見つかった場合には、その容量が、要求容量と等しいか否かを確認する(ステップS4)。なお、最後の領域まで検索して、見つからなかったときは確保失敗となる(ステップS10)。   Since the search is performed with the head match, when an area larger than the requested capacity is found among the searched free areas, it is confirmed whether or not the capacity is equal to the requested capacity (step S4). If the last area is searched and not found, securing fails (step S10).

ステップS4では、要求容量と等しいか否かを確認するが、厳密には、当該空き領域から今回の要求容量分を差し引いた残りの容量が、管理ブロックを含む最低容量以上か否かを確認している。すなわち、差し引いた残りの容量に、別の要求による領域確保が可能な最低限度の容量が残っているか否かを確認している。これは、最低限度の容量が残っていない領域を空き領域として残すことができないためである。   In step S4, it is confirmed whether or not it is equal to the requested capacity. Strictly speaking, it is confirmed whether or not the remaining capacity obtained by subtracting the current requested capacity from the free area is equal to or larger than the minimum capacity including the management block. ing. That is, it is checked whether or not the remaining capacity after the subtraction has a minimum capacity that can secure an area according to another request. This is because an area where the minimum capacity does not remain cannot be left as an empty area.

要求容量と等しくなかった場合、すなわち、検索された空き領域から今回の要求容量を差し引いても、最低限度の容量が残っている場合、前処理21から、第一記憶領域確保手段22に処理が進む。第一記憶領域確保手段22では、検索された空き領域から、要求容量を採取した場合のメモリ領域アドレスを計算する。   If it is not equal to the requested capacity, that is, if the minimum capacity remains even if the current requested capacity is subtracted from the searched free area, the process from the pre-processing 21 to the first storage area securing means 22 is performed. move on. The first storage area securing means 22 calculates the memory area address when the required capacity is collected from the searched free area.

この計算されたメモリ領域の先頭と最後のアドレスがページ境界を跨いでいるか否かを確認する(ステップS51)。跨いでいなければ、この動的メモリ確保は、物理アドレス空間上も連続領域であることを保障できるため、第一通常確保手段221に進み、実際にメモリ確保を行う(ステップS82)。そして最後に、確保できた動的メモリ領域の先頭アドレスを、メモリの要求元に返す(ステップS102)。   It is confirmed whether or not the calculated first and last addresses of the memory area cross the page boundary (step S51). If not straddling, since it can be ensured that this dynamic memory allocation is a continuous area in the physical address space, the process proceeds to the first normal allocation means 221 and actual memory allocation is performed (step S82). Finally, the start address of the secured dynamic memory area is returned to the memory request source (step S102).

ステップS51で、ページ境界を跨ぐと判断された場合、この動的メモリ確保は、物理アドレス空間上、連続領域であることを保障できないため、第一回避確保手段222に進む。第一回避確保手段222では、まず、ページ境界を跨ぐサイズのうち、最小のサイズを計算する。即ち、ページ境界を跨ぐ最小の領域のサイズ(最小サイズ)を計算する。そして、その最小サイズで、一旦仮領域を確保する(ステップS61)。これは、再度、確保を試みたときに、同じエリアの確保を試みることを避けるためである。   If it is determined in step S51 that the page boundary is crossed, the dynamic memory allocation cannot be guaranteed to be a continuous area in the physical address space, and the process proceeds to the first avoidance securing unit 222. The first avoidance securing unit 222 first calculates the minimum size among the sizes straddling the page boundary. In other words, the size (minimum size) of the minimum area across the page boundary is calculated. Then, a temporary area is temporarily secured with the minimum size (step S61). This is to avoid trying to secure the same area when attempting to secure again.

仮領域を確保した後、本アルゴリズムを同じ要求容量で再帰的に実行する(ステップS81)。再帰的に実行するのはステップS2からとなる。これは、最初の確保を試みた領域に架空の領域を配置し、再度、同じ状態に陥るのを避けた状態において同一容量の確保要求をすることを意味する。再帰的な確保要求によって、前述のステップS82、もしくは、後述のステップS84でメモリ確保ができた場合には、2回目の再試行で要求容量の動的メモリ確保ができたことになる。   After securing the temporary area, the present algorithm is recursively executed with the same required capacity (step S81). Recursive execution starts from step S2. This means that an imaginary area is arranged in the area where the first securing is attempted, and a request for securing the same capacity is made in a state where the same state is avoided again. If the memory can be secured in the above-described step S82 or later-described step S84 by the recursive securing request, the dynamic memory securing of the requested capacity can be secured in the second retry.

逆に2回目の再帰的な確保要求において、失敗した場合でも、再度、再帰的に本アルゴリズムを実行することで可能な限り再確保を試みる。再試行は、領域がページ境界を跨ぐごとに行われるので、最大で(ページ数−1)回の再試行が行われる可能性がある(最初の確保要求を数えるとページ数分が最大値)。   Conversely, even if the second recursive reservation request fails, re-reservation is attempted as much as possible by executing this algorithm again recursively. Since the retry is performed every time the region crosses the page boundary, there may be a maximum of (number of pages-1) retries (the number of pages is the maximum value when counting the first allocation request). .

当然ながら、再試行中に他の確保できる可能性のある空き領域がなければ、確保失敗の通知を返却することになるが、いずれにしても最大再試行回数は(ページ数−1)回となる。再帰的な確保処理から返ってくると、第一回避確保手段222に戻り、先に確保した仮領域を解放する(ステップS91)。そして、最後に再帰的な実行から得られた結果を返す(ステップS101)。   Of course, if there is no other free area that can be secured during the retry, a notification of failure to secure is returned, but in any case, the maximum number of retries is (number of pages minus 1). Become. When returning from the recursive securing process, the process returns to the first avoidance securing unit 222 to release the provisional area secured previously (step S91). Finally, the result obtained from the recursive execution is returned (step S101).

他方、ステップS4において、要求容量と等しいと判断された場合、すなわち、当該空き領域から今回の要求容量分(要求サイズ分)の領域を差し引いた残りの領域の容量(サイズ)が、管理ブロックを含む最低容量(基準となる最低サイズ)以上ない場合、前処理21から、第二記憶領域確保手段23に処理が進む。   On the other hand, if it is determined in step S4 that it is equal to the requested capacity, that is, the capacity (size) of the remaining area obtained by subtracting the area for the current requested capacity (for the requested size) from the free area is the management block. If there is no more than the minimum capacity (minimum standard size) to be included, the process proceeds from the pre-processing 21 to the second storage area securing means 23.

第二記憶領域確保手段23では、検索された空き領域を使用する領域として確保する(ステップS53)。次に、この確保された領域の先頭と最後のアドレスがページ境界を跨いでいるか否かを確認する(ステップS63)。   The second storage area securing means 23 secures the searched free area as an area to be used (step S53). Next, it is confirmed whether or not the start and end addresses of this reserved area cross the page boundary (step S63).

跨いでいなければ、この動的メモリ確保は、物理アドレス空間上も連続領域であることを保障できるため、第二通常確保手段231に進み、当該領域を要求容量を満たす領域として確定させる(ステップS84)。そして、動的メモリ領域の先頭アドレスを、メモリの要求元に返す(ステップS104)。   If it does not straddle, this dynamic memory allocation can guarantee that the physical address space is also a continuous area, so the process proceeds to the second normal allocation means 231 to determine the area as an area satisfying the required capacity (step S84). Then, the start address of the dynamic memory area is returned to the memory request source (step S104).

ステップS63で、ページ境界を跨ぐと判断された場合、この動的メモリ確保は、物理アドレス空間上、連続領域であることを保障できないため、第二回避確保手段232に進む。第二回避確保手段232では、当該領域を仮領域として確定させる(ステップS73)。これも、ステップS61と同様に、再度、確保を試みたときに、同じエリアの確保を実行することを避けるためである。   If it is determined in step S63 that the page boundary is crossed, the dynamic memory allocation cannot be guaranteed to be a continuous area in the physical address space, and the process proceeds to the second avoidance securing unit 232. The second avoidance ensuring unit 232 determines the area as a temporary area (step S73). This is also for avoiding securing the same area when securing is attempted again, as in step S61.

仮領域を確保した後、本アルゴリズムを同じ要求容量で再帰的に実行する(ステップS83)。そして、再帰的な実行から返ったときに、仮領域を解放する(ステップS93)。最後に、再帰的な実行の結果を要求元に返して終了する(ステップS103)。以上が、本実施の形態の動作である。   After securing the temporary area, the present algorithm is recursively executed with the same required capacity (step S83). Then, when returning from the recursive execution, the temporary area is released (step S93). Finally, the result of the recursive execution is returned to the request source and the process ends (step S103). The above is the operation of the present embodiment.

本実施の形態により、次のような効果が得られる。第1の効果は、メモリを有効活用できることにある。その理由は、アプリケーション毎のページ管理ができないソフトウェアや連続した実アドレス空間を持てない計算機においても、仮想アドレス空間から動的に確保した領域を実アドレス空間上も連続したものとして扱えるためである。   According to the present embodiment, the following effects can be obtained. The first effect is that the memory can be effectively used. The reason is that even in software that cannot manage pages for each application or a computer that does not have a continuous real address space, an area dynamically secured from the virtual address space can be treated as continuous in the real address space.

次に、本発明の他の実施の形態について説明する。空き領域の割り当て方法には、一般に次の3つがある。
(1)先頭一致(First−Fit):空き領域中の最初の実行可能領域に割り当て
(2)最良一致(Best−Fit):空き領域中の実行可能領域のうち、もっとも小さな領域に割り当て
(3)最悪一致(Worst−Fit):空き領域中の実行可能領域のうち、もっとも大きな領域に割り当て
Next, another embodiment of the present invention will be described. There are generally the following three methods for allocating free areas.
(1) First match (First-Fit): assigned to the first executable area in the free area (2) Best match (Best-Fit): assigned to the smallest of the executable areas in the free area (3 ) Worst-Fit: assigned to the largest of the executable areas in the free area

前述の図5では、「先頭一致」による例を図示したが、本発明の考え方は、上記3つの割り当て方法によらず、すべてにおいて適用可能である。いずれも本発明の本質にかかわるところに差分はないが、図6に「最良一致」によるフローチャートを示す。図5に示した「先頭一致」の場合と同様に、オペレーティングシステム、もしくは、アプリケーション1から動的メモリ確保要求が発行される(ステップS1)。   In FIG. 5 described above, an example of “first match” is illustrated, but the concept of the present invention can be applied to all of the above three allocation methods. In either case, there is no difference in the essence of the present invention, but FIG. 6 shows a flowchart of “best match”. As in the case of “first match” shown in FIG. 5, a dynamic memory allocation request is issued from the operating system or application 1 (step S1).

記憶領域確保処理2は、オペレーティングシステム、もしくは、アプリケーション1からメモリ確保要求を受け取ると、前処理21にて確保対象領域中の空き領域を検索する(ステップA2、A9)。   When the storage area securing process 2 receives a memory securing request from the operating system or the application 1, the pre-process 21 searches for a free area in the secured area (steps A2 and A9).

「最良一致」で検索するため、すべての空き領域を検索し、その中で必要容量を満たし、かつ、最も小さな領域を検出する(ステップA3)。この条件に合う領域が見つかった場合には、その容量が、要求容量と等しいか否かを確認する(ステップS4)。以降の処理は、先の「先頭一致」の場合と同様であるのでその説明は省略する。なお、条件を満たす領域が見つからなかったときは確保失敗となる(ステップS10)。   In order to search for “best match”, all free areas are searched, and the smallest area that satisfies the required capacity is detected (step A3). If a region meeting this condition is found, it is confirmed whether or not the capacity is equal to the required capacity (step S4). Since the subsequent processing is the same as that in the case of “first match”, the description thereof is omitted. It should be noted that if a region that satisfies the condition is not found, securing fails (step S10).

図7は、「最悪一致」によるフローチャートを示している。図5に示した「先頭一致」の場合と同様に、オペレーティングシステム、もしくは、アプリケーション1から動的メモリ確保要求が発行される(ステップS1)。   FIG. 7 shows a flowchart of “worst match”. As in the case of “first match” shown in FIG. 5, a dynamic memory allocation request is issued from the operating system or application 1 (step S1).

記憶領域確保処理2は、オペレーティングシステム、もしくは、アプリケーション1からメモリ確保要求を受け取ると、前処理21にて確保対象領域中の空き領域を検索する(ステップB2、B9)。   When the storage area securing process 2 receives a memory securing request from the operating system or the application 1, the pre-process 21 searches for a free area in the secured area (steps B2 and B9).

「最良一致」で検索するため、すべての空き領域を検索し、その中で必要容量を満たし、かつ、最も大きな領域を検出する(ステップB3)。この条件に合う領域が見つかった場合には、その容量が、要求容量と等しいか否かを確認する(ステップS4)。以降の処理は、先の「先頭一致」の場合と同様であるのでその説明は省略する。なお、条件を満たす領域が見つからなかったときは確保失敗となる(ステップS10)。   In order to search for “best match”, all the empty areas are searched, and the largest area among them is detected and the largest area is detected (step B3). If a region meeting this condition is found, it is confirmed whether or not the capacity is equal to the required capacity (step S4). Since the subsequent processing is the same as that in the case of “first match”, the description thereof is omitted. It should be noted that if a region that satisfies the condition is not found, securing fails (step S10).

なお、上記実施の形態の構成及び動作は例であって、本発明の趣旨を逸脱しない範囲で適宜変更することができることは言うまでもない。   It should be noted that the configuration and operation of the above-described embodiment are examples, and it goes without saying that they can be changed as appropriate without departing from the spirit of the present invention.

本発明は、小規模から大規模までのあらゆるコンピュータに適用可能であるが、特に、アプリケーション毎のページ管理ができないソフトウェアを実装した計算機や連続した実メモリ空間が取れない計算機において有効である。また、メモリを有効利用できるため、昨今、幅広い製品が出されている組み込みシステム分野においても効力を発揮するものである。   The present invention can be applied to all kinds of computers from small to large scales, but is particularly effective in a computer in which software that cannot manage pages for each application is installed or a computer that cannot obtain a continuous real memory space. In addition, since the memory can be used effectively, it is effective in the field of embedded systems where a wide range of products have been released recently.

本発明が適用されるコンピュータの構成例を示すブロック図である。It is a block diagram which shows the structural example of the computer to which this invention is applied. 仮想アドレス空間において確保された連続領域に対応して、実アドレス空間上で確保される領域を示す図である。It is a figure which shows the area | region ensured on the real address space corresponding to the continuous area ensured in the virtual address space. 本発明の解決すべき課題を模式的に示す図である。It is a figure which shows typically the subject which this invention should solve. 図3に示した課題を解決する方法を示す模式図である。It is a schematic diagram which shows the method of solving the subject shown in FIG. 本実施の形態の動作を説明するためのフローチャートである。It is a flowchart for demonstrating operation | movement of this Embodiment. 「最良一致」による動作の例を示すフローチャートである。It is a flowchart which shows the example of the operation | movement by "best match." 「最悪一致」による動作の例を示すフローチャートである。It is a flowchart which shows the example of the operation | movement by "worst coincidence." 仮想アドレス空間と実アドレス空間との対応付けの例を示す図であるIt is a figure which shows the example of matching with virtual address space and real address space 「使用不可領域」に挟まれた領域を有効に利用できない例を示す図である。It is a figure which shows the example which cannot use effectively the area | region pinched | interposed into the "unusable area".

符号の説明Explanation of symbols

1 オペレーティングシステム、もしくは、アプリケーション
2 記憶領域確保処理
3 仮想アドレス空間
4 実アドレス空間
21 前処理
22 第一記憶領域確保手段
23 第二記憶領域確保手段
31 仮想アドレス空間上の領域
41 実アドレス空間上の領域
221 第一通常確保手段
222 第一回避確保手段
231 第二通常確保手段
232 第二回避確保手段
DESCRIPTION OF SYMBOLS 1 Operating system or application 2 Storage area reservation process 3 Virtual address space 4 Real address space 21 Pre-processing 22 First storage area reservation means 23 Second storage area reservation means 31 Area on virtual address space 41 On real address space Area 221 First normal securing means 222 First avoidance securing means 231 Second normal securing means 232 Second avoidance securing means

Claims (12)

仮想アドレス空間上で確保された連続領域に対応して実アドレス空間上で連続領域が確保されることを保障するメモリ割り当て方法であって、
前記仮想アドレス空間上で要求サイズ以上の空き領域を検索する検索ステップと、
前記空き領域から前記要求サイズの領域が確保されるとき、前記領域がページ境界を跨ぐか否かを判定する判定ステップと、
前記判定の結果、ページ境界を跨ぐと判定された場合、前記領域のうち、ページ境界を跨ぐ最小のサイズの領域を仮領域として確保する仮領域確保ステップと、
前記仮領域確保ステップにおいて確保された前記仮領域を除き、再度、前記仮想アドレス空間上において領域の確保が行われる領域確保ステップと、
前記領域確保ステップにおいて確保された領域がページ境界を跨がないとき、前記領域を確保領域として確定する領域確定ステップと、
前記仮領域を解放する解放ステップと
を備えることを特徴とするメモリ割り当て方法。
A memory allocation method for ensuring that a continuous area is secured in a real address space corresponding to a continuous area secured in a virtual address space,
A search step of searching for a free area of a requested size or more on the virtual address space;
A determination step of determining whether or not the area crosses a page boundary when an area of the required size is secured from the free area; and
A result of the determination, if it is determined that straddles a page boundary, among the regions, and a temporary area securing step of securing the area of the smallest size across the page boundary as the temporary area,
An area securing step in which an area is secured on the virtual address space again, except for the provisional area secured in the provisional area securing step;
When the area secured in the area securing step does not cross a page boundary, an area confirming step for confirming the area as a secured area;
A memory allocation method comprising: a releasing step of releasing the temporary area.
前記空き領域から前記要求サイズ分の前記領域を差し引いた残りの領域のサイズが、基準となる最低サイズ以上ない場合、前記空き領域全体が仮領域として確保される
ことを特徴とする請求項1に記載のメモリ割り当て方法。
The entire free area is secured as a temporary area when the size of the remaining area obtained by subtracting the area for the requested size from the free area is not equal to or smaller than a reference minimum size. The memory allocation method described.
前記仮領域は、前記領域の最上位アドレスを含む前記仮想アドレス空間上のページの最下位アドレスと、前記領域の最下位アドレスを挟む領域である
ことを特徴とする請求項1に記載のメモリ割り当て方法。
The memory allocation according to claim 1, wherein the temporary area is an area that sandwiches the lowest address of a page on the virtual address space including the highest address of the area and the lowest address of the area. Method.
前記領域確保ステップにおいて連続領域が確保できなかった場合、確保失敗とされる
ことを特徴とする請求項1乃至3のいずれかに記載のメモリ割り当て方法。
The memory allocation method according to any one of claims 1 to 3, wherein when the continuous area cannot be secured in the area securing step, securing fails.
仮想アドレス空間上で確保された連続領域に対応して実アドレス空間上で連続領域が確保されることを保障するメモリ割り当て装置であって、
前記仮想アドレス空間上で要求サイズ以上の空き領域を検索する検索手段と、
前記空き領域から前記要求サイズの領域が確保されるとき、前記領域がページ境界を跨ぐか否かを判定する判定手段と、
前記判定の結果、ページ境界を跨ぐと判定された場合、前記領域のうち、ページ境界を跨ぐ最小のサイズの領域を仮領域として確保する仮領域確保手段と、
前記仮領域確保手段によって確保された前記仮領域を除き、再度、前記仮想アドレス空間上において領域の確保が行われる領域確保手段と、
前記領域確保手段によって確保された領域がページ境界を跨がないとき、前記領域を確保領域として確定する領域確定手段と、
前記仮領域を解放する解放手段と
を備えることを特徴とするメモリ割り当て装置。
A memory allocation device that ensures that a continuous area is secured on a real address space in correspondence with a continuous area secured on a virtual address space,
Search means for searching for a free area of the requested size or more in the virtual address space;
Determination means for determining whether or not the area crosses a page boundary when the area of the required size is secured from the free area;
A result of the determination, if it is determined that straddles a page boundary, among the regions, and a temporary area securing means to secure the area of the smallest size across the page boundary as the temporary area,
Excluding the temporary area secured by the temporary area securing means, an area securing means for securing the area again on the virtual address space;
When the area secured by the area securing means does not cross a page boundary, area confirming means for confirming the area as a secured area;
A memory allocation device comprising: release means for releasing the temporary area.
前記空き領域から前記要求サイズ分の前記領域を差し引いた残りの領域のサイズが、基準となる最低サイズ以上ない場合、前記空き領域全体が仮領域として確保される
ことを特徴とする請求項5に記載のメモリ割り当て装置。
The entire free area is secured as a temporary area when the size of the remaining area obtained by subtracting the area for the requested size from the free area is not equal to or smaller than a reference minimum size. The memory allocation device described.
前記仮領域は、前記領域の最上位アドレスを含む前記仮想アドレス空間上のページの最下位アドレスと、前記領域の最下位アドレスを挟む領域である
ことを特徴とする請求項5に記載のメモリ割り当て装置。
The memory allocation according to claim 5, wherein the temporary area is an area that sandwiches the lowest address of a page on the virtual address space including the highest address of the area and the lowest address of the area. apparatus.
前記領域確保手段が連続領域を確保できなかった場合、確保失敗とされる
ことを特徴とする請求項5乃至7のいずれかに記載のメモリ割り当て装置。
The memory allocation device according to any one of claims 5 to 7, wherein when the area securing unit cannot secure a continuous area, the securing is failed.
仮想アドレス空間上で確保された連続領域に対応して実アドレス空間上で連続領域が確保されることを保障するメモリ割り当て装置におけるメモリ割り当てプログラムであって、
前記仮想アドレス空間上で要求サイズ以上の空き領域を検索する検索ステップと、
前記空き領域から前記要求サイズの領域が確保されるとき、前記領域がページ境界を跨ぐか否かを判定する判定ステップと、
前記判定の結果、ページ境界を跨ぐと判定された場合、前記領域のうち、ページ境界を跨ぐ最小のサイズの領域を仮領域として確保する仮領域確保ステップと、
前記仮領域確保ステップにおいて確保された前記仮領域を除き、再度、前記仮想アドレス空間上において領域の確保が行われる領域確保ステップと、
前記領域確保ステップにおいて確保された領域がページ境界を跨がないとき、前記領域を確保領域として確定する領域確定ステップと、
前記仮領域を解放する解放ステップとを前記メモリ割り当て装置に実行させる
ことを特徴とするメモリ割り当てプログラム。
A memory allocation program in a memory allocation device for ensuring that a continuous area is secured on a real address space corresponding to a continuous area secured on a virtual address space,
A search step of searching for a free area of a requested size or more on the virtual address space;
A determination step of determining whether or not the area crosses a page boundary when an area of the required size is secured from the free area; and
A result of the determination, if it is determined that straddles a page boundary, among the regions, and a temporary area securing step of securing the area of the smallest size across the page boundary as the temporary area,
An area securing step in which an area is secured on the virtual address space again, except for the provisional area secured in the provisional area securing step;
When the area secured in the area securing step does not cross a page boundary, an area confirming step for confirming the area as a secured area;
A memory allocation program that causes the memory allocation device to execute a release step of releasing the temporary area.
前記空き領域から前記要求サイズ分の前記領域を差し引いた残りの領域のサイズが、基準となる最低サイズ以上ない場合、前記空き領域全体が仮領域として確保される
ことを特徴とする請求項9に記載のメモリ割り当てプログラム。
The entire free area is secured as a temporary area when the size of the remaining area obtained by subtracting the area for the requested size from the free area is not equal to or smaller than a reference minimum size. The memory allocation program described.
前記仮領域は、前記領域の最上位アドレスを含む前記仮想アドレス空間上のページの最下位アドレスと、前記領域の最下位アドレスを挟む領域である
ことを特徴とする請求項9に記載のメモリ割り当てプログラム。
The memory allocation according to claim 9, wherein the temporary area is an area that sandwiches a lowest address of a page on the virtual address space including a highest address of the area and a lowest address of the area. program.
前記領域確保ステップにおいて連続領域が確保できなかった場合、確保失敗とされる
ことを特徴とする請求項9乃至11のいずれかに記載のメモリ割り当てプログラム。
The memory allocation program according to any one of claims 9 to 11, wherein when the continuous area cannot be secured in the area securing step, the securing is failed.
JP2007013959A 2007-01-24 2007-01-24 Memory allocation method Expired - Fee Related JP5012040B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2007013959A JP5012040B2 (en) 2007-01-24 2007-01-24 Memory allocation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2007013959A JP5012040B2 (en) 2007-01-24 2007-01-24 Memory allocation method

Publications (2)

Publication Number Publication Date
JP2008181314A JP2008181314A (en) 2008-08-07
JP5012040B2 true JP5012040B2 (en) 2012-08-29

Family

ID=39725174

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2007013959A Expired - Fee Related JP5012040B2 (en) 2007-01-24 2007-01-24 Memory allocation method

Country Status (1)

Country Link
JP (1) JP5012040B2 (en)

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS59119386A (en) * 1982-12-25 1984-07-10 富士通株式会社 Buffer area controlling system
JPH0293962A (en) * 1988-09-30 1990-04-04 Nec Corp System for forming space memory continued by real address
JPH04145554A (en) * 1990-10-08 1992-05-19 Hitachi Ltd Real memory assigning system
JP2621761B2 (en) * 1993-05-31 1997-06-18 日本電気株式会社 Memory management method
US6986016B2 (en) * 2002-09-30 2006-01-10 International Business Machines Corporation Contiguous physical memory allocation

Also Published As

Publication number Publication date
JP2008181314A (en) 2008-08-07

Similar Documents

Publication Publication Date Title
CN108334396B (en) Data processing method and device, and resource group creation method and device
US20130138886A1 (en) Scheduler, multi-core processor system, and scheduling method
JP2011165164A (en) System and method for qos-based storage tiering and migration technique
JPH0628053B2 (en) Resource allocation control method for multiprocessor system
JP4576452B2 (en) Operating system and information processing apparatus
CN107305548B (en) Task allocation method and device for controlling web crawler
JP2007122664A (en) Information processing method and information processor
JP4407956B2 (en) Information processing method and information processing apparatus
KR20090108868A (en) Virtual machine management system and method for managing processor resources thereof
EP3208709B1 (en) Batch processing method and device for system invocation commands
CN110750336A (en) OpenStack virtual machine memory hot-expanding method
KR20070090649A (en) Apparatus and method for providing cooperative scheduling on multi-core system
CA2547078A1 (en) Memory management in a computer system using different swapping criteria
US20030018682A1 (en) Computer system and computer-readable record medium
US8001341B2 (en) Managing dynamically allocated memory in a computer system
CN111104218B (en) Storage system data synchronization method, device, equipment and readable storage medium
JP5012040B2 (en) Memory allocation method
US9158551B2 (en) Activating and deactivating Operating System (OS) function based on application type in manycore system
CN105677481A (en) Method and system for processing data and electronic equipment
JP5996110B2 (en) Computer system and control method
WO2014188642A1 (en) Scheduling system, scheduling method, and recording medium
CN115794362A (en) Resource allocation method, cloud host and computer-readable storage medium
JP2014078214A (en) Schedule system, schedule method, schedule program, and operating system
JP5699665B2 (en) Server apparatus, process execution method, and program
JP2019179414A (en) Information processing device

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20091214

RD01 Notification of change of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7421

Effective date: 20111110

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20120221

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20120406

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20120508

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20120521

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20150615

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Ref document number: 5012040

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

LAPS Cancellation because of no payment of annual fees