JP3353376B2 - Storage area management method - Google Patents
Storage area management methodInfo
- Publication number
- JP3353376B2 JP3353376B2 JP09804493A JP9804493A JP3353376B2 JP 3353376 B2 JP3353376 B2 JP 3353376B2 JP 09804493 A JP09804493 A JP 09804493A JP 9804493 A JP9804493 A JP 9804493A JP 3353376 B2 JP3353376 B2 JP 3353376B2
- Authority
- JP
- Japan
- Prior art keywords
- hole
- block
- size
- flag
- last
- 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
Links
Landscapes
- Memory System (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Description
【0001】[0001]
【産業上の利用分野】本発明は、OS内の処理時間を保
証することを目的としたリアルタイムOSに関し、特に
任意サイズのメモリ割付及び解放を可能とするリアルタ
イムOSのメモリ管理方式に関する。BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a real-time OS for guaranteeing a processing time in an OS, and more particularly to a real-time OS memory management system capable of allocating and releasing memory of an arbitrary size.
【0002】[0002]
【従来の技術】一般にリアルタイムOSでは、メモリの
効率的な管理及び利用者の要求に対する高速な応答性を
確保するために、メモリをある固定サイズのブロックで
区切り、利用者へ現在割り当てている使用中ブロック
と、割当てていない空きブロック(または使用可能ブロ
ック)とに分けて管理している。メモリ割り当て要求時
には要求サイズを満たす連続した空きブロック(以降一
つ以上の連続した空きブロックをホールと呼ぶ)を検出
し、要求サイズ分を利用者へ割り当てる。残部は新しい
ホールとして管理する。メモリ解放要求時には全空きブ
ロック中での解放位置を検出し、ブロックの断片化を防
止するため、解放要求のあるメモリ域の前後のホールと
連続しているならば結合し、新しいホールとして管理す
る。2. Description of the Related Art In general, in a real-time OS, in order to efficiently manage a memory and ensure a high-speed response to a user's request, the memory is divided into blocks of a fixed size, and the memory currently allocated to the user is used. The management is divided into a middle block and an unallocated empty block (or usable block). At the time of a memory allocation request, a continuous free block satisfying the requested size (hereinafter, one or more continuous free blocks is called a hole) is detected, and the requested size is allocated to the user. The rest will be managed as a new hall. At the time of a memory release request, the release position in all free blocks is detected, and in order to prevent block fragmentation, if it is continuous with holes before and after the memory area where the release is requested, it is combined and managed as a new hole .
【0003】従来、このようなホールの管理として、1
989年4月21日株式会社アスキー出版の「MINI
Xオペレーティングシステム」242ページ〜244ペ
ージに記載の方式がある。この方式の1例として、図1
5にリアルタイムOSの保持する管理データと、メモリ
との関係を示す。図15において、1はメモリを概念的
に示したもので、斜線部分がホール、白抜き部分が既に
割当済みのメモリブロックである。41は1つのホール
に対して1つ対応付けられているホール管理テーブルで
あり、そのホールのサイズ及び次のホールを指すポイン
タを持つ。3は上記ホール管理テーブル41からなるリ
ストの先頭を指すフリーリストである。リアルタイムO
Sはメモリ確保要求が発生するとフリーリスト3をもと
に検索し、要求サイズを満たすホールを検出する。この
検出したホールが要求サイズと等しい時には、フリーリ
スト3からホールを取り出し、利用者へ割り当てる。ま
た、検出したホールが要求サイズより大きい時には、要
求サイズ分利用者へ割り当て、ホールのサイズから要求
サイズを差し引く。一方、メモリの解放要求が発生する
とフリーリスト3を順に検索し、解放ホールの前後に連
続するホールがあるかを検出する。前後に連続するホー
ルがある場合にはそのホールをフリーリスト3から取り
外し、解放ホールと連結した後、再度フリーリスト3へ
繋げる。[0003] Conventionally, such a management of a hall has been performed as follows.
April 21, 989 Ascii Publishing Co., Ltd. "MINI
X operating system "on pages 242 to 244. As an example of this method, FIG.
5 shows the relationship between the management data held by the real-time OS and the memory. In FIG. 15, reference numeral 1 denotes a concept of a memory. A hatched portion is a hole, and a white portion is a memory block already allocated. Reference numeral 41 denotes a hole management table associated with one hole, and has a size of the hole and a pointer pointing to the next hole. Reference numeral 3 denotes a free list indicating the head of the list including the hole management table 41. Real-time O
When the memory reservation request is issued, S searches the free list 3 based on the free list 3 and detects holes satisfying the requested size. When the detected hole is equal to the required size, the hole is taken out from the free list 3 and assigned to the user. If the detected hole is larger than the required size, the requested size is allocated to the user, and the required size is subtracted from the hole size. On the other hand, when a memory release request occurs, the free list 3 is searched in order to detect whether there is a continuous hole before and after the released hole. If there is a continuous hole before and after, the hole is removed from the free list 3, connected to the open hole, and then connected to the free list 3 again.
【0004】[0004]
【発明が解決しようとする課題】ところが上記メモリ管
理方式においては、メモリの割当時には要求サイズを満
たすホールを検出するために、また解放時には、前後の
ホールとの連結のために解放メモリ域の解放位置を検出
するために、フリーリストの探索が必要であった。その
ため、フリーリストの先頭近くに所望のホールが繋がれ
ている場合には高速だが、最後尾に近いホールで初めて
所望のホールが検出される場合には検索時間が長くな
り、CPUの占有時間が長くなるという問題があった。 However, the above-mentioned memory tube
In the logical system, the required size is
In order to detect a hole to add, and when releasing,
Detecting the release position of the freed memory area for connection with the hole
To do so, it was necessary to search for a free list. That
Therefore, the desired hole is connected near the head of the free list.
If you are fast, but first in the hole near the end
If the desired hole is detected, the search time will be longer.
Therefore, there is a problem that the occupation time of the CPU becomes long.
【0005】[0005]
【0006】[0006]
【課題を解決するための手段】請求項1に記載の発明に
係る記憶領域管理方式は、記憶装置を固定長サイズのブ
ロックに分割して、使用中のブロックと未使用のブロッ
クに分け、一つ以上の連続した未使用のブロックをホー
ルとして管理する記憶領域管理方式において、下記の要
素を有する記憶領域管理方式。 (a)前記ホールをリストとして管理するためのフリー
リスト (b)分割されたブロックに対応して存在し、ホ−ルの
サイズまたは少なくとも1つの連続した使用中のブロッ
クのサイズと、次ホールの先頭を指すポインターおよび
ホールの後尾ブロックか否かを示すフラグとを格納する
ブロック管理テーブル (c)記憶領域の解放時に解放するブロックの直前のブ
ロックの前記フラグと、前記解放するブロックによって
成るホールの最後尾ブロックの直後の、ブロックまたは
ホールの最後尾ブロックの、フラグとを参照してそのブ
ロックがホールの最後尾ブロックか否かを判定する手段 (d)前記フラグの状態を判定する手段により判定した
結果、直前のブロックが当該ホールの最後尾ブロックで
あれば、前記直前のホールの先頭ブロック管理データに
格納されているサイズに自ホールのサイズを加え、直前
のホールの先頭ブロック管理データのフラグをクリア
し、自ホールの最後尾ブロック管理データのフラグに最
後尾の旨を示すフラグを設定し、直前のブロックが最後
尾ブロックでなければ、自ホールをフリーリストの最後
尾に挿入し、自ホールの最後尾ブロックの直後のブロッ
クまたはホールの最後尾ブロックのフラグが最後尾を示
していなければ、そのまま処理を終了し、最後尾を示し
ていれば、自ホールの先頭ブロック管理データに格納さ
れているサイズに直後のホールのサイズを加え、自ホー
ルの最後尾ブロック管理データのフラグをクリアするメ
ンテナンス手段。According to the first aspect of the present invention, a storage area management system divides a storage device into fixed-length blocks and divides the storage device into used blocks and unused blocks. A storage area management method for managing one or more consecutive unused blocks as holes, the storage area management method having the following elements. (A) present in correspondence to the free list (b) divided blocks for managing the hole as a list, ho - Le
Size or at least one continuous busy block
Phrases and size of the immediately preceding blanking blocks to be released upon release of the block management table (c) storage area for storing a flag indicating whether the tail block pointer and holes to the beginning of the next hole
By the flag of the lock and the releasing block
Block or immediately after the last block of the hole
Last tail block, a result of the block by referring to the flag is determined by means for determining the status of the last block of determining whether means; (d) flags the holes, blocks the hole of the previous hole If it is the last block of the hole ,
The size of the self-holes in addition to the size stored, clears the flag of the first block the management data immediately before the hall, a flag indicating the fact of the most <br/> tail flag of the last block management data of its own holes If the previous block is not the last block, the own hole is inserted at the end of the free list, and the flag of the block immediately after the last block of the own hole or the flag of the last block of the hole indicates the last. If not, the process is terminated.If the end is indicated, the data is stored in the first block management data of the own hole.
Are added the size of the immediately following hole size is, the maintenance means for clearing the end of the block management data flag of its own hole.
【0007】請求項2に記載の発明に係る記憶領域管理
方式は、記憶装置を固定長サイズのブロックに分割し
て、使用中のブロックと未使用のブロックに分け、一つ
以上の連続した未使用のブロックをホールとして管理す
る記憶領域管理方式において、下記の要素を有するもの
である。 (a)前記ホールをリストとして管理するN個のフリー
リストからなるフリーリスト群 (b)前記フリーリストよりポイントされ、ホールを管
理する少なくともそのサイズ、次のホールを示すための
ポインターおよび対応する記憶装置上のアドレスから成
るホール管理データ群 (c)前記フリーリスト群のk番目のフリーリストには
下記の式を満足するホールを管理する前記ホール管理デ
ータをポインターで接続する手段 0≦k≦N、 2k ≦ ホールのサイズ <2k+1 (d)記憶領域の割当処理時において下記の式を満足す
るフリーリストnにポイントされている先頭のホールを
割り当てる手段。 1≦n≦N、 2n-1 ≦ 割り当てる記憶サイズ <2
n In the storage area management method according to the second aspect of the present invention, a storage device is divided into fixed-length blocks, and is divided into used blocks and unused blocks. The storage area management system that manages used blocks as holes has the following elements. (A) a free list group composed of N free lists managing the holes as a list; (b) at least the size of a hole pointed by the free list and managing the holes, a pointer for indicating the next hole, and a corresponding storage. (C) A means for connecting the hole management data for managing holes satisfying the following expression to the k-th free list in the free list group by a pointer: 0 ≦ k ≦ N 2k ≦ hole size <2 k + 1 (d) means for allocating the first hole pointed to the free list n which satisfies the following expression at the time of storage area allocation processing. 1 ≦ n ≦ N, 2 n−1 ≦ storage size to be allocated <2
n
【0008】請求項3に記載の発明に係る記憶領域管理
方式は、前記請求項2に記載の発明に加えて、前記フリ
ーリスト群の各々に前記ホール管理データが存在するか
否かを示すフラグを有するリスト管理テーブルを前記フ
リーリスト群に対応して設けたものである。According to a third aspect of the present invention, in addition to the second aspect, a flag indicating whether or not the hole management data exists in each of the free list groups. Is provided in correspondence with the free list group.
【0009】[0009]
【作用】請求項1に記載の発明に係る記憶領域管理方式
においては、分割されたブロックと1対1に対応するブ
ロック管理テーブルにサイズ等と共に使用中か否かを示
すフラグを設けたことに特徴がある。このことにより、
記憶領域の解放時に解放する領域の前後のブロックのフ
ラグを参照して解放処理を行うことができるので処理の
高速化が図れる。In the storage area management method according to the first aspect of the present invention, the block management table corresponding to the divided blocks on a one-to-one basis is provided with a flag indicating whether the block is being used together with the size and the like. There are features. This allows
When the storage area is released, the release processing can be performed by referring to the flags of the blocks before and after the area to be released, so that the processing can be sped up.
【0010】請求項2に記載の発明に係る記憶領域管理
方式においては、ホールのサイズを(2n ≦ ホールの
サイズ <2n+1 )の区分で分類し、nを指標として持
つフリーリストの群である冪乗番号リストを設けたこと
に特徴がある。このようにして記憶領域の割り当て要求
時には要求サイズを満たすホールの繋がれている冪乗番
号リストを要求サイズから求め、そのリストの先頭ホー
ルを所望のホールとしてリストからはずし、要求サイズ
を割り当てた後、残部を再度冪乗番号リストへ返却す
る。記憶領域の解放要求時には、解放要求の前後のホー
ルと連結可能であれば、連結し、その後解放領域のサイ
ズから繋げるべき冪乗番号リストを求め、そのリストの
最後尾に繋げる。このようにして特に記憶領域の割り当
て処理の高速化が図れる。In the storage area management method according to the second aspect of the present invention, the size of a hole is classified into (2 n ≦ hole size <2 n + 1 ), and a free list having n as an index is defined. It is characterized in that a power-number list, which is a group, is provided. In this way, at the time of the storage area allocation request, a list of the exponential numbers of the holes satisfying the request size is obtained from the request size, the first hole of the list is removed from the list as a desired hole, and after the request size is allocated. , And return the remainder to the power number list again. When a storage area release request is made, if a hole can be connected to holes before and after the release request, the holes are connected, and then a power-up number list to be connected is obtained from the size of the release area, and connected to the end of the list. In this way, particularly, the speed of the storage area allocation processing can be increased.
【0011】請求項3に記載の発明に係る記憶領域管理
方式においては、請求項2に記載の発明に加えて、フリ
ーリスト群の各々に対応したリスト管理テーブルを設け
たことに特徴がある。このことにより所望のホールの繋
がれている冪乗番号リストを検出するために、冪乗リス
トの探索ではなく、リスト管理テーブルのフラグチェッ
クにより可能として、更なる処理の高速化を可能とす
る。The storage area management method according to the third aspect of the present invention is characterized in that, in addition to the second aspect, a list management table corresponding to each free list group is provided. As a result, in order to detect a power-number list to which a desired hole is connected, it is possible to check the flag of the list management table instead of searching for the power-number list, thereby making it possible to further speed up the processing.
【0012】[0012]
実施例1 本発明の1実施例について説明する。図1は、本発明に
係る記憶領域管理方式における、管理データ及びメモリ
との関連図であり、図において1は概念的に記述したメ
モリで、従来例と同じく一定サイズのブロックに分割さ
れ、使用中のブロック(白抜き部分)と未使用のブロッ
ク(斜線部分)に分かれ、連続した未使用ブロックは1
つのホールとして管理されている。Embodiment 1 An embodiment of the present invention will be described. FIG. 1 is a diagram showing a relationship between management data and a memory in a storage area management system according to the present invention. In FIG. 1, reference numeral 1 denotes a conceptually described memory which is divided into blocks of a fixed size as in the conventional example and used. The middle block (open area) and the unused block (shaded area) are divided into 1
It is managed as one hall.
【0013】2は上記ブロックの個々に対応付けられた
ブロック管理データ群で、次のホールの先頭ブロックの
ブロック管理データを指し示すnextと、ホールのサ
イズを示すsizeと、ホールの最後尾ブロックならF
が、それ以外ならUが、格納されているflagの情報
から構成される。Reference numeral 2 denotes a block management data group associated with each of the above blocks. Next indicates the block management data of the first block of the next hole, size indicates the size of the hole, and F indicates the last block of the hole.
Otherwise, U is composed of the stored flag information.
【0014】3はホールを繋げたリストの先頭ブロック
管理データを指し示すフリーリストである。本実施例に
おいてメモリの割り付け発生時の処理は従来例と同じ
く、フリーリストの検索によって所望のホールを検出す
る。Reference numeral 3 denotes a free list indicating the first block management data of the list connecting the holes. In the present embodiment, the process at the time of occurrence of memory allocation detects a desired hole by searching a free list as in the conventional example.
【0015】次にメモリ領域の解放要求が発生した時の
メモリ管理の動作について図1及び図2のフローチャー
トに沿って説明する。図1において例えばブロック22
(対応するブロック管理データは図1のB22)の解放
要求が発生した場合、まず、ブロック22の直前のブロ
ック21のブロック管理データB21の情報を調べ(ス
テップ10)、flag情報がFであるため(ステップ
11)、直前のホールと連結するために図3のフローチ
ャートに示す処理を行なう(ステップ12)。Next, the operation of memory management when a memory area release request is issued will be described with reference to the flowcharts of FIGS. In FIG. 1, for example, block 22
When the release request of (corresponding block management data is B22 in FIG. 1) is generated, first, the information of the block management data B21 of the block 21 immediately before the block 22 is checked (step 10), and the flag information is F. (Step 11) The processing shown in the flowchart of FIG. 3 is performed to connect to the immediately preceding hole (Step 12).
【0016】次に、ブロック22の直後のブロック23
のブロック管理データB23のsize情報から求めら
れるブロック32のブロック管理データB32を調べ
(ステップ13)、flag情報がFであるため(ステ
ップ14)、直後のホールと連結するために図4のフロ
ーチャートに示す処理を行ない(ステップ15)、解放
処理を完了する。Next, a block 23 immediately after the block 22
The block management data B32 of the block 32 obtained from the size information of the block management data B23 is checked (step 13). Since the flag information is F (step 14), the flowchart shown in FIG. The processing shown is performed (step 15), and the release processing is completed.
【0017】また、ブロック15(対応するブロック管
理データは図1のB15)の解放要求が発生した場合、
ステップ11にてブロック14のブロック管理データB
14のflag情報がFでないため、ステップ16でフ
リーリストの先頭にブロック管理データB15を繋げ、
flag情報をFに変更する。また、ステップ14にて
ブロック16のブロック管理データB16のflag情
報がFでないため、そのまま解放処理を完了する。図5
にブロック15の解放処理を実施した後のブロック管理
テーブルとメモリの関係図を示す。When a release request for block 15 (corresponding block management data is B15 in FIG. 1) is issued,
In step 11, block management data B of block 14
Since the flag information of No. 14 is not F, the block management data B15 is linked to the head of the free list in step 16, and
Change the flag information to F. Since the flag information of the block management data B16 of the block 16 is not F in step 14, the release processing is completed as it is. FIG.
FIG. 11 shows a relationship diagram between the block management table and the memory after the release processing of the block 15 is performed.
【0018】次に図2のステップ12における直前のホ
ール(ブロック21)との連結を図3のフローチャート
に沿って説明する。直前のホールとの連結は、直前のホ
ールの先頭ブロック管理データB21のnext情報を
そのまま利用することにより、フリーリストへの挿入は
不要となる。Next, the connection with the immediately preceding hole (block 21) in step 12 of FIG. 2 will be described with reference to the flowchart of FIG. The connection with the immediately preceding hole does not require insertion into the free list by using the next information of the head block management data B21 of the immediately preceding hole as it is.
【0019】そこでまず、直前のホールの先頭ブロック
管理データB21のsize情報に解放領域のサイズ1
を加える(ステップ20)。そして、ブロック管理デー
タB21のflag情報をクリアし(ステップ21)、
解放領域の最後尾ブロック管理データB22のflag
情報にFをセットし(ステップ22)、直前ホールとの
連結処理を完了する。First, the size of the free area is set to 1 in the size information of the head block management data B21 of the immediately preceding hole.
Is added (step 20). Then, the flag information of the block management data B21 is cleared (step 21).
Flag of the last block management data B22 of the release area
F is set in the information (step 22), and the connection processing with the immediately preceding hole is completed.
【0020】次に図2のステップ15における直後のホ
ール(ブロック23〜32)との連結を図4のフローチ
ャートに沿って説明する。図2のステップ11による直
前のホールとの連結処理の有無に係わらず、解放領域は
既にフリーリストに繋がれているため、フリーリストで
利用するnext情報は解放領域の先頭ブロック管理デ
ータB21ものを利用すれば良い。Next, the connection with the holes (blocks 23 to 32) immediately after step 15 in FIG. 2 will be described with reference to the flowchart in FIG. Since the free area is already linked to the free list irrespective of the connection processing with the immediately preceding hole in step 11 of FIG. 2, the next information used in the free list is the first block management data B21 of the free area. Just use it.
【0021】そこでまず、直後のホールの先頭ブロック
管理データB23をフリーリストからはずし(ステップ
30)、解放領域の先頭ブロック管理データB21のs
ize情報にブロック管理データB23のsize情報
である10を加える(ステップ31)。そして、解放領
域の最後尾ブロック管理データB22のflag情報を
クリアする(ステップ32)。図6にブロック22を解
放処理した結果、得られるブロック管理テーブルとメモ
リの関連図を示す。Therefore, first, the head block management data B23 of the immediately following hole is removed from the free list (step 30), and s of the head block management data B21 of the release area is removed.
10 which is the size information of the block management data B23 is added to the size information (step 31). Then, the flag information of the last block management data B22 in the release area is cleared (step 32). FIG. 6 is a diagram showing the relationship between the block management table and the memory obtained as a result of releasing the block 22.
【0022】実施例2 次に本発明に係る他の実施例について説明する。図7
は、本実施例に係るメモリ管理における、管理データ及
びメモリとの関連図であり、図において1はメモリを示
し、割当済みの使用中メモリブロック(白抜部分)と、
未使用ブロックの集まりであるホール(斜線部分)で満
たされている。41は、従来例と同じくホールを管理す
るための管理データで、少くともホールのサイズとメモ
リブロックを示すアドレス及びリストを構成するための
ポインタからなる。Embodiment 2 Next, another embodiment according to the present invention will be described. FIG.
FIG. 2 is a diagram showing a relationship between management data and a memory in the memory management according to the present embodiment. In the figure, reference numeral 1 denotes a memory;
It is filled with holes (shaded area), which are collections of unused blocks. Reference numeral 41 denotes management data for managing holes as in the conventional example, and includes at least an address indicating a hole size and a memory block, and a pointer for forming a list.
【0023】42は、フリーリスト群であり、ホールの
サイズを2n 〜2n+1 で区切り、各n毎に一つのフリー
リストを構成している。ここでは説明を簡単にするため
に、図7に示すように、メモリは32のブロックから構
成され、サイズ1、2、5、6、10のホールがそれぞ
れ一つずつ存在しているものと仮定する。また、フリー
リストの個数は、32=25 であるため5つのリストか
ら構成すれば良く、フリーリスト0にはサイズ1のホー
ルが、フリーリスト1にはサイズ2〜3のホールが、フ
リーリスト2にはサイズ4〜7のホールが、フリーリス
ト3にはサイズ8〜15のホールが、フリーリスト4に
はサイズ16〜31のホールがそれぞれ繋がれる。Reference numeral 42 denotes a free list group, which divides the hole size by 2 n to 2 n + 1 , and forms one free list for each n. For the sake of simplicity, it is assumed that the memory is composed of 32 blocks and that there is one hole of each of sizes 1, 2, 5, 6, and 10, as shown in FIG. I do. Since the number of free lists is 32 = 2 5 , the list may be composed of five lists. A free list 0 has a size 1 hole, a free list 1 has a size 2-3 hole, and a free list has a free list. 2, the holes 4 to 7 are connected to the free list 3, the holes 8 to 15 are connected to the free list 4, and the holes 16 to 31 are connected to the free list 4.
【0024】このような状態において、サイズ5のメモ
リ割り当て要求が発生した時の動作を図7及び図8のフ
ローチャートに沿って説明する。まず、サイズ5の割当
を確実に満たすことのできるホールを持つフリーリスト
の番号を求める(ステップ50)。この時、求めるフリ
ーリストの番号をnとすれば、2n-1 ≦要求サイズ<2
n を満たすnを求めれば良い。これは5を2進表記した
時の最上位ビット番号に1を加えた値、即ちn=3とな
る。The operation when a memory allocation request of size 5 occurs in such a state will be described with reference to the flowcharts of FIGS. First, the number of a free list having holes that can surely satisfy the allocation of size 5 is obtained (step 50). At this time, assuming that the number of the desired free list is n, 2 n-1 ≦ request size <2
What is necessary is just to find n that satisfies n. This is a value obtained by adding 1 to the most significant bit number when 5 is expressed in binary, that is, n = 3.
【0025】次にステップ50にて求めたn=3がフリ
ーリストの番号の上限を越えているかをチェックする
(ステップ51)。本実施例の場合フリーリストの番号
の上限値は4であり、nは上限値を越えていないため、
フリーリスト3にホールが繋がれているかをチェックす
る(ステップ52)。本実施例では、フリーリスト3に
はホールが繋がれているため、フリーリスト3の先頭の
ホール管理データを取り外し(ステップ53)、このホ
ールのサイズが要求サイズ5より大きいかをチェックす
る(ステップ54)。本実施例の場合、ホール管理デー
タのサイズは10であり、要求サイズ5より大きいた
め、ホール管理データのサイズを要求サイズ分減算して
5にセットする(ステップ55)。次に、この残ホール
管理データを繋げるべきフリーリストの番号を求める
(ステップ56)。この時、求めるフリーリストの番号
をnとすれば、2n ≦ホールの残サイズ<2n+1 を満た
すnを求めれば良い。これは5を2進表記した時の最上
位ビット番号の値、即ちn=2となる。Next, it is checked whether n = 3 obtained in step 50 exceeds the upper limit of the number of the free list (step 51). In the case of this embodiment, the upper limit of the free list number is 4, and n does not exceed the upper limit.
It is checked whether a hole is connected to the free list 3 (step 52). In this embodiment, since holes are connected to the free list 3, the first hole management data of the free list 3 is removed (step 53), and it is checked whether the size of this hole is larger than the required size 5 (step 53). 54). In the case of the present embodiment, the size of the hole management data is 10 and is larger than the required size 5, so the size of the hole management data is subtracted by the required size and set to 5 (step 55). Next, the number of the free list to which the remaining hole management data is to be linked is obtained (step 56). At this time, assuming that the number of the free list to be obtained is n, n that satisfies 2 n ≦ the remaining hole size <2 n + 1 may be obtained. This is the value of the most significant bit number when 5 is represented in binary, that is, n = 2.
【0026】次にステップ56にて求めたn=2から、
フリーリスト2の最後尾に残ホールを繋げ(ステップ5
7)、メモリ割当処理を完了する。図10に以上の処理
をした後のホール管理データとメモリの関係図を示す。Next, from n = 2 obtained in step 56,
Connect the remaining hole to the end of free list 2 (Step 5
7), the memory allocation processing is completed. FIG. 10 shows the relationship between the hole management data and the memory after the above processing.
【0027】一方、サイズ10のメモリ割り当て要求が
発生した場合には、ステップ50にてn=4となり、ス
テップ52ではフリーリスト4にホールが繋がれていな
いため、ステップ58に進む。ステップ58ではnに1
を加えてn=5にし、nの値が上限を越えていないかを
チェックする(ステップ51)。本実施例の場合、上限
値4をnが越えるため、ステップ59にすすむ。ステッ
プ59ではフリーリスト(n−1)=3を探索し、サイ
ズ10を満たすホールがあるかを探索する。探索の結
果、サイズ10を満たすホールがない場合は、要求サイ
ズのメモリ割り付けができないことを利用者へ通知す
る。On the other hand, if a memory allocation request of size 10 occurs, n = 4 in step 50, and in step 52, since no holes are connected to the free list 4, the process proceeds to step 58. In step 58, 1 is set to n.
Is added to make n = 5, and it is checked whether the value of n exceeds the upper limit (step 51). In the case of this embodiment, since n exceeds the upper limit value 4, the process proceeds to step 59. In step 59, the free list (n-1) = 3 is searched for a hole satisfying the size 10. If there is no hole satisfying the size 10 as a result of the search, the user is notified that the memory of the requested size cannot be allocated.
【0028】本実施例の場合ホール管理データが要求サ
イズ10を満たすため、ステップ53へ進み、ホール管
理データをフリーリスト4からはずす。次にホール5の
サイズと要求サイズを比較する(ステップ54)。その
結果、ホール5のサイズと要求サイズはとはもに10で
等しいため、そのまま割付処理を終了する。図11にサ
イズ10のメモリ割当てを実施した後のホール管理デー
タとメモリの関係図を示す。In the case of this embodiment, since the hole management data satisfies the required size 10, the process proceeds to step 53, and the hole management data is removed from the free list 4. Next, the size of the hole 5 is compared with the required size (step 54). As a result, since the size of the hole 5 and the required size are both equal to 10, the allocation process is terminated. FIG. 11 shows a relationship diagram between the hole management data and the memory after the memory allocation of size 10 is performed.
【0029】次に図7の状態において、ブロック22の
解放要求が発生した場合について、図7及び図9のフロ
ーチャートに沿って説明する。まず、従来例と同じよう
にホール管理データ群をたどってブロック22の直前に
ホールが存在するかを検出する(ステップ60)。もし
直前にホールが存在しなければそのままステップ61へ
進む。本実施例の場合には、ホール4が存在するため、
ステップ61にてホール4を管理するホール管理データ
(本実施例の場合フリーリスト0がポイントしている)
をフリーリスト0からはずす。その後、ブロック22を
ホール4と連結し、サイズ2のホールとする(ステップ
62)。次にブロック22の直後にホールが存在するか
を検出する(ステップ63)。もし、直後にホールが存
在しなければそのままステップ64へ進む。本実施例の
場合には、ホール5が存在するため、ステップ64にて
ホール5を管理するホール管理データをフリーリスト3
からはずす。その後、ブロック21〜22をホール5と
連結し、サイズ12のホールとする。Next, a case where a request to release the block 22 occurs in the state of FIG. 7 will be described with reference to the flowcharts of FIGS. First, the hole management data group is traced to detect whether a hole exists immediately before the block 22 as in the conventional example (step 60). If there is no hole immediately before, the process proceeds directly to step 61. In the case of this embodiment, since the hole 4 exists,
Hole management data for managing hole 4 in step 61 (free list 0 points in this embodiment)
From the free list 0. Thereafter, the block 22 is connected to the hole 4 to form a size 2 hole (step 62). Next, it is detected whether a hole exists immediately after the block 22 (step 63). If there is no hole immediately after, the process proceeds directly to step 64. In the case of this embodiment, since the hole 5 exists, the hole management data for managing the hole 5 is stored in the free list 3 in step 64.
Remove from Thereafter, the blocks 21 to 22 are connected to the hole 5 to form a hole of size 12.
【0030】次に連結の完了したホールをつなげるべき
フリーリストの番号を求める(ステップ66)。この
時、求めるフリーリストの番号をnとすれば、2n ≦ホ
ールの残サイズ<2n+1 を満たすnを求めれば良い。こ
れは12を2進表記した時の最上位ビット番号の値、即
ちn=3となる。Next, the number of the free list to which the connected holes are to be connected is determined (step 66). At this time, assuming that the number of the free list to be obtained is n, n that satisfies 2 n ≦ the remaining hole size <2 n + 1 may be obtained. This is the value of the most significant bit number when 12 is represented in binary, that is, n = 3.
【0031】次にステップ66にて求めたn=3から、
フリーリスト3の最後尾に連結したホールをつなげ(ス
テップ67)、メモリ解放処理を完了する。図12にブ
ロック22の解放処理を実施した後のホール管理データ
とメモリの関係図を示す。Next, from n = 3 obtained in step 66,
The connected holes are connected to the end of the free list 3 (step 67), and the memory release processing is completed. FIG. 12 shows a relationship diagram between the hole management data and the memory after the release processing of the block 22 is performed.
【0032】実施例3 次に本発明に係る他の実施例について説明する。図13
は、請求項第3項に係るメモリ管理における、管理デー
タ及びメモリとの関連図であり、図において、1〜42
は実施例2における図7のものと同じ、71はフリーリ
スト群42の各フリーリストに1対1に対応したリスト
管理ビット列を示すリスト管理テーブルであり、対応す
るフリーリストにホール管理データがつながれている場
合には1が、つながれていない場合には0がセットされ
ている。Embodiment 3 Next, another embodiment according to the present invention will be described. FIG.
Is a diagram showing the relationship between management data and memory in the memory management according to claim 3;
7 is the same as that in FIG. 7 in the second embodiment. Reference numeral 71 denotes a list management table indicating a list management bit string corresponding to each free list in the free list group 42 on a one-to-one basis. Hole management data is connected to the corresponding free list. 1 is set when they are connected, and 0 is set when they are not connected.
【0033】このような状態におけるメモリ割り付け処
理を図14のフローチャートに沿って説明する。図14
においてステップ50〜ステップ59は、図8のフロー
チャートと同じ処理である。The memory allocation processing in such a state will be described with reference to the flowchart of FIG. FIG.
Steps 50 to 59 are the same processes as those in the flowchart of FIG.
【0034】ステップ51にて、ステップ50で求めた
nが上限を越えていない場合、ビット番号nよりリスト
管理テーブルをサーチし、最初にビットが“1”である
ビット番号を求める(ステップ80)。求めるビットが
リスト管理テーブルにない場合には(ステップ81)ス
テップ59に進み、以降実施例2と同じ動作をする。In step 51, if n obtained in step 50 does not exceed the upper limit, the list management table is searched from bit number n, and the bit number whose bit is "1" is obtained first (step 80). . If the bit to be found is not in the list management table (step 81), the process proceeds to step 59, and the same operation as in the second embodiment is performed thereafter.
【0035】ステップ81にて求めるビットがリスト管
理テーブルにあった場合にはステップ53に進み、以降
実施例2と同じ動作をする。If the bit to be determined in step 81 is found in the list management table, the flow advances to step 53, and the same operation as in the second embodiment is performed thereafter.
【0036】[0036]
【発明の効果】以上のように本発明では、リアルタイム
OSでのメモリの管理単位であるブロックに、1つづつ
管理データを対応させ、この管理データに対応するブロ
ックが割当済みか利用可能かを判定する情報を持たせ、
割当済みメモリ域の解放要求発生時には、前後のホール
との連結の必要性の有無を、解放域の直前のブロックに
対応する管理データと、直後のブロックに対応する管理
データの情報を調べれば良い構成にしたので、メモリ解
放要求時での繰り返し処理の回避を実現することができ
る。As described above, according to the present invention, the management data is made to correspond one by one to the block which is the management unit of the memory in the real-time OS, and it is determined whether the block corresponding to the management data has been allocated or is available. Have information to judge,
When a release request for the allocated memory area occurs, the necessity of connection with the preceding and following holes can be checked by checking the management data corresponding to the block immediately before the release area and the management data corresponding to the block immediately after the release area. With the configuration, it is possible to avoid repetitive processing at the time of a memory release request.
【0037】[0037]
【0038】[0038]
【図1】本発明の実施例1に係る管理データとメモリの
関係図である。FIG. 1 is a diagram illustrating a relationship between management data and a memory according to a first embodiment of the present invention.
【図2】本発明の実施例1に係るメモリ解放処理を示す
フローチャートである。FIG. 2 is a flowchart illustrating a memory release process according to the first embodiment of the present invention.
【図3】図2における直前のホールとの連結処理を示す
フローチャートである。FIG. 3 is a flowchart showing a connection process with the immediately preceding hole in FIG. 2;
【図4】図2における直後のホールとの連結処理を示す
フローチャートである。FIG. 4 is a flowchart showing a connection process with a hole immediately after in FIG. 2;
【図5】本発明の実施例1におけるブロック15のメモ
リ領域解放処理後のブロック管理テーブルとメモリの関
係図である。FIG. 5 is a diagram illustrating a relationship between a block management table and a memory after a memory area release process of a block 15 according to the first embodiment of the present invention.
【図6】本発明の実施例1におけるブロック22のメモ
リ領域解放後のブロック管理テーブルとメモリの関係図
である。FIG. 6 is a diagram illustrating a relationship between a block management table and a memory after a memory area of a block 22 is released according to the first embodiment of the present invention.
【図7】本発明の実施例2に係るホール管理データとメ
モリの関係図である。FIG. 7 is a diagram illustrating a relationship between hole management data and a memory according to the second embodiment of the present invention.
【図8】本発明の実施例2に係るメモリ割当処理を示す
フローチャートである。FIG. 8 is a flowchart illustrating a memory allocation process according to the second embodiment of the present invention.
【図9】本発明の実施例2に係るメモリ解放処理を示す
フローチャートである。FIG. 9 is a flowchart illustrating a memory release process according to the second embodiment of the present invention.
【図10】本発明の実施例2におけるサイズ5のメモリ
領域割当後のホール管理データとメモリの関係図であ
る。FIG. 10 is a diagram illustrating the relationship between the hole management data and the memory after the allocation of the memory area of size 5 according to the second embodiment of the present invention.
【図11】本発明の実施例2におけるサイズ10のメモ
リ領域割当後のホール管理データとメモリの関係図であ
る。FIG. 11 is a diagram illustrating the relationship between the hole management data and the memory after the allocation of the memory area of size 10 according to the second embodiment of the present invention.
【図12】本発明の実施例2におけるブロック22のメ
モリ領域割当後のホール管理データとメモリの関係図で
ある。FIG. 12 is a diagram illustrating a relationship between the hole management data and the memory after the memory area is allocated to the block 22 according to the second embodiment of the present invention.
【図13】本発明の実施例3に係るホール管理データと
メモリの関係図である。FIG. 13 is a diagram illustrating a relationship between hole management data and a memory according to the third embodiment of the present invention.
【図14】本発明の実施例3に係るメモリ割当処理を示
すフローチャートである。FIG. 14 is a flowchart illustrating a memory allocation process according to a third embodiment of the present invention.
【図15】従来のメモリ管理に係るホール管理データと
メモリの関係図である。FIG. 15 is a diagram showing the relationship between hole management data and memory according to conventional memory management.
1 メモリ 2 ブロック管理テーブル 3 フリーリスト 41 ホール管理データ群 42 フリーリスト群 71 リスト管理テーブル 1 Memory 2 Block Management Table 3 Free List 41 Hole Management Data Group 42 Free List Group 71 List Management Table
フロントページの続き (56)参考文献 特開 平4−236639(JP,A) 特開 平4−219836(JP,A) 特開 平3−265944(JP,A) 特開 平4−349546(JP,A) 特開 昭58−171780(JP,A) 特開 平2−193231(JP,A) ANDREW S.TANENBAU M著,坂本 文監修,大西照代翻訳,M INIXオペレーティングシステム,日 本,株式会社アスキー,1990年9月1 日,P241−P244 (58)調査した分野(Int.Cl.7,DB名) G06F 12/00 501 G06F 12/02 510 Continuation of the front page (56) References JP-A-4-236639 (JP, A) JP-A-4-219836 (JP, A) JP-A-3-265944 (JP, A) JP-A-4-349546 (JP) JP-A-58-171780 (JP, A) JP-A-2-193231 (JP, A) ANDREW S., et al. TANENBAUM, supervised by Bunka Sakamoto, supervised by Teruyo Onishi, MINIX operating system, Japan, ASCII Corporation, September 1, 1990, P241-P244 (58) Fields investigated (Int. Cl. 7 , DB name) G06F 12/00 501 G06F 12/02 510
Claims (1)
割して、使用中のブロックと未使用のブロックに分け、
一つ以上の連続した未使用のブロックをホールとして管
理する記憶領域管理方式において、下記の要素を有する
記憶領域管理方式。 (a)前記ホールをリストとして管理するためのフリー
リスト (b)分割されたブロックに対応して存在し、ホ−ルの
サイズまたは少なくとも1つの連続した使用中のブロッ
クのサイズと、次ホールの先頭を指すポインターおよび
ホールの後尾ブロックか否かを示すフラグとを格納する
ブロック管理テーブル (c)記憶領域の解放時に解放するブロックの直前のブ
ロックの前記フラグと、前記解放するブロックによって
成るホールの最後尾ブロックの直後の、ブロックまたは
ホールの最後尾ブロックの、フラグとを参照してそのブ
ロックがホールの最後尾ブロックか否かを判定する手段 (d)前記フラグの状態を判定する手段により判定した
結果、直前のブロックが当該ホールの最後尾ブロックで
あれば、前記直前のホールの先頭ブロック管理データに
格納されているサイズに自ホールのサイズを加え、直前
のホールの先頭ブロック管理データのフラグをクリア
し、自ホールの最後尾ブロック管理データのフラグに最
後尾の旨を示すフラグを設定し、直前のブロックが最後
尾ブロックでなければ、自ホールをフリーリストの最後
尾に挿入し、 自ホールの最後尾ブロックの直後のブロックまたはホー
ルの最後尾ブロックのフラグが最後尾を示していなけれ
ば、そのまま処理を終了し、最後尾を示していれば、自
ホールの先頭ブロック管理データに格納されているサイ
ズに直後のホールのサイズを加え、自ホールの最後尾ブ
ロック管理データのフラグをクリアするメンテナンス手
段。1. A storage device is divided into fixed-length blocks, and is divided into used blocks and unused blocks.
A storage area management method for managing one or more continuous unused blocks as holes, the storage area management method having the following elements. (A) present in correspondence to the free list (b) divided blocks for managing the hole as a list, ho - Le
Size or at least one continuous busy block
Phrases and size of the immediately preceding blanking blocks to be released upon release of the block management table (c) storage area for storing a flag indicating whether the tail block pointer and holes to the beginning of the next hole
By the flag of the lock and the releasing block
Block or immediately after the last block of the hole
Last tail block, a result of the block by referring to the flag is determined by means for determining the status of the last block of determining whether means; (d) flags the holes, blocks the hole of the previous hole If it is the last block of the hole ,
The size of the self-holes in addition to the size stored, clears the flag of the first block the management data immediately before the hall, a flag indicating the fact of the most <br/> tail flag of the last block management data of its own holes If the previous block is not the last block, insert your own hole at the end of the free list and enter the block or hole immediately after the last block of your own hole.
If the flag of the last block of the hole does not indicate the last, the processing is terminated as it is. If the flag of the last block indicates the last, the processing immediately follows the size stored in the first block management data of the own hole. Maintenance means to add the size of the hole and clear the flag of the last block management data of the own hole.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP09804493A JP3353376B2 (en) | 1993-04-23 | 1993-04-23 | Storage area management method |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP09804493A JP3353376B2 (en) | 1993-04-23 | 1993-04-23 | Storage area management method |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JPH06309197A JPH06309197A (en) | 1994-11-04 |
| JP3353376B2 true JP3353376B2 (en) | 2002-12-03 |
Family
ID=14209153
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP09804493A Expired - Fee Related JP3353376B2 (en) | 1993-04-23 | 1993-04-23 | Storage area management method |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP3353376B2 (en) |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP4691348B2 (en) * | 2004-10-26 | 2011-06-01 | 三菱電機株式会社 | Storage area management program and message management program |
| JP4158121B2 (en) | 2006-05-18 | 2008-10-01 | コニカミノルタビジネステクノロジーズ株式会社 | Memory management method |
Family Cites Families (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPS58171780A (en) * | 1982-03-31 | 1983-10-08 | Fujitsu Ltd | Managing method of main storage |
| JPH02193231A (en) * | 1989-01-20 | 1990-07-30 | Fujitsu Ltd | File space free area management system |
| JPH03265944A (en) * | 1990-03-15 | 1991-11-27 | Fujitsu Ltd | File control system |
| JPH04219836A (en) * | 1990-12-20 | 1992-08-10 | Nec Corp | Block control system |
| JPH04236639A (en) * | 1991-01-21 | 1992-08-25 | Nec Corp | File space management system |
| JPH04349546A (en) * | 1991-05-28 | 1992-12-04 | Hitachi Ltd | Shared memory pool management method |
-
1993
- 1993-04-23 JP JP09804493A patent/JP3353376B2/en not_active Expired - Fee Related
Non-Patent Citations (1)
| Title |
|---|
| ANDREW S.TANENBAUM著,坂本 文監修,大西照代翻訳,MINIXオペレーティングシステム,日本,株式会社アスキー,1990年9月1日,P241−P244 |
Also Published As
| Publication number | Publication date |
|---|---|
| JPH06309197A (en) | 1994-11-04 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP4250190B2 (en) | Efficient storage of objects in the file system | |
| JP2001236249A (en) | Device and method for managing memory | |
| EP0446940A2 (en) | Dynamic data storage system | |
| JPH10198587A (en) | Method and apparatus for indirect addressing of a file system | |
| WO1998028744A1 (en) | Optimizing access to multiplexed data streams | |
| US20040128463A1 (en) | Apparatus and method for controlling memory allocation for variable size packets | |
| US6442553B1 (en) | Hash system and hash method for transforming records to be hashed | |
| US5829018A (en) | Apparatus and method for writing data from a cache to a storage device | |
| US20030018689A1 (en) | Method, system, and computer program product for managing a re-usable resource with linked list groups | |
| WO1997029429A1 (en) | Cam accelerated buffer management | |
| CN108304259A (en) | EMS memory management process and system | |
| US6629114B2 (en) | Method, system, and computer program product for managing a re-usable resource | |
| JP3353376B2 (en) | Storage area management method | |
| EP0333181B1 (en) | Data string retrieval apparatus | |
| KR950033947A (en) | How to Allocate Printer and Cache Memory Space | |
| JPH0652060A (en) | Lru list control system | |
| CN116450639B (en) | Data processing methods, data processing devices, electronic devices, and readable storage media | |
| EP1327194A2 (en) | A data structure, memory allocator and memory management system | |
| CN115344217A (en) | A data storage method, device, equipment and readable storage medium | |
| EP0117906B1 (en) | Key-accessed file organization | |
| CN113741787A (en) | Data storage method, device, equipment and medium | |
| JP2874810B2 (en) | Key memory allocation method | |
| JPH0744564B2 (en) | Communication control device | |
| KR20030044498A (en) | Data Structure, Block Assignment and Record Retrieval Method of Main Memory DataBase Management System | |
| JPH1051469A (en) | Atm switch |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20080927 Year of fee payment: 6 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20080927 Year of fee payment: 6 |
|
| FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20090927 Year of fee payment: 7 |
|
| LAPS | Cancellation because of no payment of annual fees |