JP3356090B2 - Memory management method, memory management device, and recording medium - Google Patents

Memory management method, memory management device, and recording medium

Info

Publication number
JP3356090B2
JP3356090B2 JP34797098A JP34797098A JP3356090B2 JP 3356090 B2 JP3356090 B2 JP 3356090B2 JP 34797098 A JP34797098 A JP 34797098A JP 34797098 A JP34797098 A JP 34797098A JP 3356090 B2 JP3356090 B2 JP 3356090B2
Authority
JP
Japan
Prior art keywords
memory
block
address
start address
unused
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
JP34797098A
Other languages
Japanese (ja)
Other versions
JP2000163309A (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 JP34797098A priority Critical patent/JP3356090B2/en
Publication of JP2000163309A publication Critical patent/JP2000163309A/en
Application granted granted Critical
Publication of JP3356090B2 publication Critical patent/JP3356090B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明はメモリ管理方法およ
びメモリ管理装置、並びに記録媒体に関し、特に、OS
内の処理時間を保証することを目的としたリアルタイム
OSにおいて、任意サイズのメモリ割り付け、及び解放
を可能とするメモリ管理方法およびメモリ管理装置、並
びに記録媒体に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a memory management method, a memory management device, and a recording medium, and more particularly, to an operating system (OS).
The present invention relates to a memory management method, a memory management device, and a recording medium that enable allocation and release of a memory of an arbitrary size in a real-time OS intended to guarantee processing time in the memory.

【0002】[0002]

【従来の技術】一般に、リアルタイムOSのメモリ管理
方式は、メモリをある固定サイズで区切り、タスクから
のメモリ獲得、解放要求に応じて動的にメモリの割付を
行い、使用メモリブロック、未使用メモリブロック別に
管理するようになっている。
2. Description of the Related Art In general, a memory management method of a real-time OS is such that a memory is divided into a certain fixed size, and a memory is dynamically allocated in response to a memory acquisition / release request from a task. They are managed by block.

【0003】従来、このようなメモリブロックの管理方
法は、例えば、特開平6−309197に開示されてい
るように、次のようなものであった。即ち、タスクから
のメモリ獲得要求が発生すると、必要とされるサイズを
満たす空きメモリブロックを検出し、タスクに割り当て
る。一方、メモリの解放要求が発生すると、メモリブロ
ックの断片化を防止するため、全ての空きメモリブロッ
クでの解放位置を検出する。そして、解放要求のあるメ
モリブロックの前後に、連続する空きメモリブロックが
ある場合、それらの空きメモリブロックと連結して、1
つの空きメモリブロックとして管理する。
Conventionally, such a memory block management method is as follows, for example, as disclosed in Japanese Patent Laid-Open No. Hei 6-309197. That is, when a memory acquisition request from a task occurs, a free memory block satisfying a required size is detected and assigned to the task. On the other hand, when a memory release request is issued, a release position in all empty memory blocks is detected in order to prevent fragmentation of the memory blocks. If there are consecutive free memory blocks before and after the memory block requested to be released, the free memory blocks are linked to these free memory blocks.
It is managed as two free memory blocks.

【0004】[0004]

【発明が解決しようとする課題】しかしながら、従来の
メモリ管理方式においては、メモリ解放時にメモリの断
片化を防ぐために、前後の空きメモリブロックと連結す
る必要があり、全メモリを検索してメモリブロックの解
放位置を検出するので、CPUの占有時間が長くなると
いう課題があった。
However, in the conventional memory management system, it is necessary to connect the memory blocks before and after the empty memory block in order to prevent the memory from being fragmented when the memory is released. Since the release position is detected, the occupation time of the CPU becomes long.

【0005】その理由は、空きメモリブロックの先頭の
近くに所望の空きメモリブロックが繋がっているいる場
合には高速に処理されるが、最後尾近くに所望の空きメ
モリブロックが検出された場合には、検出時間が長くな
るためである。
[0005] The reason is that when a desired free memory block is connected near the beginning of a free memory block, processing is performed at high speed. However, when a desired free memory block is detected near the end of the free memory block. Is because the detection time becomes longer.

【0006】本発明の目的は、上述の点に鑑み、タスク
によってメモリが解放されたとき、全メモリ領域から解
放位置を検出するときの検索回数を減少させ、CPUの
占有時間を短くすることにより、メモリ解放処理の高速
化を実現するとともに、リアルタイムOSの性能を向上
させることができるようにするものである。
SUMMARY OF THE INVENTION In view of the above, it is an object of the present invention to reduce the number of searches for detecting a release position from the entire memory area when a memory is released by a task, thereby shortening the occupation time of the CPU. It is intended to realize high-speed memory release processing and to improve the performance of a real-time OS.

【0007】[0007]

【課題を解決するための手段】請求項1に記載のメモリ
管理方法は、タスクからの要求に応じて、タスクに対し
てメモリの割り付けおよび解放を行うメモリ管理方法で
あって、メモリを、割り付けが行われている使用メモリ
と、解放されている未使用メモリとに分割してブロック
単位で管理し、使用メモリをメモリを獲得した順番に繋
ぎ、未使用メモリをアドレス順に繋ぎ、使用メモリの所
定のブロックを解放するとき、解放されるブロックの先
頭アドレスを保存し、保存しているブロックの先頭アド
レスを基準にして、次のブロックの解放位置の検出を行
場合、解放される次のブロックの先頭アドレスが、保
存されている先頭アドレスより大きいか否かが判定さ
れ、解放される次のブロックの先頭アドレスが、保存さ
れている先頭アドレスより大きくないと判定されたと
き、アドレスがより小さい方向に、メモリ解放位置の検
索を行い、解放される次のブロックのアドレスが、保存
されている先頭アドレスより大きいと判定されたとき、
アドレスがより大きい方向に、メモリ解放位置の検索を
行い、各ブロックは、少なくとも、そのブロックに繋が
れている次のブロックの先頭アドレスと、そのブロック
の前のブロックの先頭アドレスと、そのブロックのユー
ザ使用可能領域の先頭アドレスと、そのブロックのユー
ザ使用可能領域の終了アドレスとからなるテーブルによ
り管理され、使用メモリは、使用メモリの先頭のブロッ
クの先頭アドレスと、使用メモリの最後のブロックの先
頭アドレスからなるテーブルにより管理され、未使用メ
モリは、未使用メモリの先頭のブロックの先頭アドレス
と、未使用メモリの最後のブロックの先頭アドレスから
なるテーブルにより管理されることを特徴とする。請求
項2に記載のメモリ管理装置は、タスクからの要求に応
じて、タスクに対してメモリの割り付けおよび解放を行
うメモリ管理装置であって、メモリを、割り付けが行わ
れている使用メモリと、解放されている未使用メモリと
に分割してブロック単位で管理し、使用メモリを、メモ
リを獲得した順番に繋ぎ、未使用メモリを、アドレス順
に繋ぐメモリ管理手段と、使用メモリの所定のブロック
を解放するとき、解放されるブロックの先頭アドレスを
保存する保存手段と、保存手段によって保存されている
ブロックの先頭アドレスを基準にして、次のブロックの
解放位置の検出を行う場合、解放される次のブロックの
先頭アドレスが、保存手段によって保存されている先頭
アドレスより大きいか否かが判定され、解放される次の
ブロックの先頭アドレスが、保存手段によって保存され
ている先頭アドレスより大きくないと判定されたとき、
アドレスがより小さい方向に、メモリ解放位置の検索を
行い、解放される次のブロックのアドレスが、保存手段
によって保存されている先頭アドレスより大きいと判定
されたとき、アドレスがより大きい方向に、メモリ解放
位置の検索を行う検出手段とを備え、各ブロックは、少
なくとも、そのブロックに繋がれている次のブロックの
先頭アドレスと、そのブロックの前のブロックの先頭ア
ドレスと、そのブロックのユーザ使用可能領域の先頭ア
ドレスと、そのブロックのユーザ使用可能領域の終了ア
ドレスとからなるテーブルにより管理され、使用メモリ
は、使用メモリの先頭のブロックの先頭アドレスと、使
用メモリの最後のブロックの先頭アドレスからなるテー
ブルにより管理され、未使用メモリは、未使用メモリの
先頭のブロックの先頭アドレスと、未使用メモリの最後
のブロックの先頭アドレスからなるテーブルにより管理
されることを特徴とする。請求項3に記載の記録媒体
は、タスクからの要求に応じて、タスクに対してメモリ
の割り付けおよび解放を行うメモリ管理方法をコンピュ
ータに実行させるためのプログラムを記録したコンピュ
ータ読み取り可能な記録媒体であって、メモリを、割り
付けが行われている使用メモリと、解放されている未使
用メモリとに分割してブロック単位で管理し、使用メモ
リをメモリを獲得した順番に繋ぎ、未使用メモリをアド
レス順に繋ぎ、使用メモリの所定のブロックを解放する
とき、解放されるブロックの先頭アドレスを保存し、保
存しているブロックの先頭アドレスを基準にして、次の
ブロックの解放位置の検出を行う場合、解放される次の
ブロックの先頭アドレスが、保存されている先頭アドレ
スより大きいか否かが判定され、解放される次のブロッ
クの先頭アドレスが、保存されている先頭アドレスより
大きくないと判定されたとき、アドレスがより小さい方
向に、メモリ解放位置の検索を行い、解放される次のブ
ロックのアドレスが、保存されている先頭アドレスより
大きいと判定されたとき、アドレスがより大きい方向
に、メモリ解放位置の検索を行い、各ブロックは、少な
くとも、そのブロックに繋がれている 次のブロックの先
頭アドレスと、そのブロックの前のブロックの先頭アド
レスと、そのブロックのユーザ使用可能領域の先頭アド
レスと、そのブロックのユーザ使用可能領域の終了アド
レスとからなるテーブルにより管理され、使用メモリ
は、使用メモリの先頭のブロックの先頭アドレスと、使
用メモリの最後のブロックの先頭アドレスからなるテー
ブルにより管理され、未使用メモリは、未使用メモリの
先頭のブロックの先頭アドレスと、未使用メモリの最後
のブロックの先頭アドレスからなるテーブルにより管理
されるメモリ管理方法をコンピュータに実行させるため
のプログラムを記録したことを特徴とする。本発明に係
るメモリ管理方法およびメモリ管理装置、並びに記録媒
体においては、メモリを、割り付けが行われている使用
メモリと、解放されている未使用メモリとに分割してブ
ロック単位で管理し、使用メモリをメモリを獲得した順
番に繋ぎ、未使用メモリをアドレス順に繋ぎ、使用メモ
リの所定のブロックを解放するとき、解放されるブロッ
クの先頭アドレスを保存し、保存しているブロックの先
頭アドレスを基準にして、次のブロックの解放位置の検
出を行う場合、解放される次のブロックの先頭アドレス
が、保存されている先頭アドレスより大きいか否かが判
定され、解放される次のブロックの先頭アドレスが、保
存されている先頭アドレスより大きくないと判定された
とき、アドレスがより小さい方向に、メモリ解放位置の
検索を行い、解放される次のブロックのアドレスが、保
存されている先頭アドレスより大きいと判定されたと
き、アドレスがより大きい方向に、メモリ解放位置の検
索を行い、各ブロックは、少なくとも、そのブロックに
繋がれている次のブロックの先頭アドレスと、そのブロ
ックの前のブロックの先頭アドレスと、そのブロックの
ユーザ使用可能領域の先頭アドレスと、そのブロックの
ユーザ使用可能領域の終了アドレスとからなるテーブル
により管理され、使用メモリは、使用メモリの先頭のブ
ロックの先頭アドレスと、使用メモリの最後のブロック
の先頭アドレスからなるテーブルにより管理され、未使
用メモリは、未使用メモリの先頭のブロックの先頭アド
レスと、未使用メモリの最後のブロックの先頭アドレス
からなるテーブルにより管理される。
According to a first aspect of the present invention, there is provided a memory management method for allocating and releasing a memory to a task in response to a request from the task. The memory is divided into used memory that has been used and unused memory that has been released, and is managed in block units. The used memory is connected in the order in which the memory was acquired, the unused memory is connected in the order of the addresses, and the used memory is determined. When releasing a block, save the start address of the block to be released and, based on the start address of the stored block, detect the release position of the next block. If the start address is
It is determined whether the address is
The start address of the next block to be released and released is stored.
Is determined not to be greater than the starting address
Memory release position in the direction of smaller addresses.
The address of the next block to be searched and released is saved.
Is determined to be larger than the starting address
Search for a memory release position in the direction of larger address.
Do, each block is at least connected to that block
Start address of the next block that is
The start address of the block before
Start address of the user-usable area and the user
Table that contains the end address of the
Memory is used, and the used memory is the first block of the used memory.
Start address of the memory and the end of the last block of the used memory
It is managed by a table consisting of the
Memory is the start address of the first block of unused memory
And from the start address of the last block of unused memory
It is characterized by being managed by a table . Claim
Item 2 is a memory management device for allocating and releasing memory to a task in response to a request from the task, wherein the memory is allocated to a used memory that has been allocated, and a memory to be released. is managed in block units is divided into unused memory is a memory used, joint technique in order that won memory, the unused memory, and tether memory management unit in address order, a given block of memory used when releasing the, based on a storage means for storing the start address of the block to be released, the head address of a block stored by the storage means, when performing detection of the release position of the next block, is released Of the next block
The start address is the start address stored by the storage unit
The next address to be released
The start address of the block is stored by the storage means.
If it is determined that the address is not larger than
Search for a memory release position in the direction of smaller addresses.
The address of the next block to be released
Is determined to be larger than the first address stored by
When the address is released, the memory is released in the larger direction
E Bei and detection means for searching for positions, each block is small
At least, the next block connected to that block
Start address and start address of the block before that block
Dress and the first address of the user-usable area of that block.
Dress and the end address of the user usable area of that block.
Is managed by a table consisting of dresses and used memory
Is the start address of the first block of the used memory and the
Data consisting of the start address of the last block of the
Unused memory is managed by the
Start address of the first block and end of unused memory
Managed by a table consisting of the start addresses of the blocks
It is characterized by being performed. The recording medium according to claim 3.
Memory for the task, as requested by the task
Memory management methods for allocating and releasing
Computer that stores programs to be executed by
Data readable recording medium, the memory of which is
Used memory that has been allocated, and unused memory that has been released.
Memory and manage it in block units.
Memory in the order in which they acquired memory, and add unused memory.
And release the specified block of the used memory
When the start address of the released block is saved,
Based on the start address of the existing block,
When detecting the release position of a block, the next
The start address of the block is
The next block to be released.
The start address of the
When it is determined that the address is not large, the one with the smaller address
Search for the memory release location in the
Lock address is higher than the stored first address
When it is determined that the address is larger, the direction of the address is larger
Then, a search for the memory release location is performed, and each block is
At least, the end of the next block connected to that block
Start address and start address of the block before that block
Address and the start address of the user-usable area of the block.
Address and the end address of the user-usable area for that block.
Is managed by a table consisting of
Is the start address of the first block of the used memory and the
Data consisting of the start address of the last block of the
Unused memory is managed by the
Start address of the first block and end of unused memory
Managed by a table consisting of the start addresses of the blocks
The computer to perform the required memory management method
Is recorded. In the memory management method, the memory management device, and the recording medium according to the present invention, the memory is divided into a used memory that has been allocated and an unused memory that has been released, and is managed in units of blocks. When the memory is connected in the order in which the memory was acquired, the unused memory is connected in the order of the addresses, and when the predetermined block of the used memory is released, the start address of the released block is stored, and the start address of the stored block is used as a reference. When detecting the release position of the next block, the start address of the next block to be released
Is greater than the stored start address.
The start address of the next block that is
Is determined not to be greater than the existing start address
When the address becomes smaller,
The address of the next block to be searched and released is stored.
Is determined to be larger than the existing start address
Memory release position in the direction of larger addresses.
Do a search and each block at least
Start address of the next connected block and its block
Address of the block before the block and the
The start address of the user usable area and the block
Table consisting of the end address of the user usable area
Is used, and the used memory is the first block of the used memory.
Lock start address and last block of used memory
Is managed by a table consisting of
Memory is the first address of the first block of unused memory.
Address and the start address of the last block of unused memory
Is managed by a table consisting of

【0008】[0008]

【発明の実施の形態】以下、本発明の実施の形態につい
て図面を参照して詳細に説明する。図1は、本発明のメ
モリ管理方法が適用されるマイクロコンピュータの一実
施の形態のハードウェア(HW)構成例を示すブロック
図である。同図に示すように、マイクロコンピュータ
は、CPU(central processing
unit)1と、A/D(アドレス/データ)バス9を
介してCPU1に接続されたメモリコントローラ5、タ
イマコントローラ6、割り込みコントローラ7とから構
成されている。
Embodiments of the present invention will be described below in detail with reference to the drawings. FIG. 1 is a block diagram showing an example of a hardware (HW) configuration of a microcomputer to which a memory management method according to the present invention is applied. As shown in FIG. 1, the microcomputer includes a CPU (central processing).
1 includes a memory controller 5, a timer controller 6, and an interrupt controller 7 connected to the CPU 1 via an A / D (address / data) bus 9.

【0009】また、マイクロコンピュータは、CPU1
を動作させる命令コードを格納したROM(read
only memory)2と、CPU1の動作に必要
な各種データを一時的に記憶したり、プログラムをロー
ドするためのメインメモリ(RAM(random a
ccess memory))(以下では単に、メモリ
という)3と、データを保存するための記憶装置4とを
備えている。
Further, the microcomputer has a CPU 1
(Read) that stores the instruction code for operating
only memory 2 and a main memory (RAM (random memory) for temporarily storing various data necessary for the operation of the CPU 1 and loading a program.
(access memory)) (hereinafter, simply referred to as a memory) 3 and a storage device 4 for storing data.

【0010】次に、上記HW構成で動作するソフトウェ
ア(SW)の構成例について、図2の機能ブロック図を
参照して説明する。図1のHW構成で動作するSWは、
図1の割り込みコントローラ7から発生された割り込み
を処理する割り込みハンドラ10と、CPU1内で発生
する例外を処理する例外ハンドラ11を制御し、さら
に、必要な処理が記述された複数のユーザ14のタスク
を制御するリアルタイムOS(operating s
ystem)12とを備えている。また、リアルタイム
OS12には、メモリ解放位置管理機構13が設けられ
ている。
Next, an example of the configuration of software (SW) operating in the HW configuration will be described with reference to the functional block diagram of FIG. SW operating in the HW configuration of FIG.
An interrupt handler 10 for processing an interrupt generated from the interrupt controller 7 of FIG. 1 and an exception handler 11 for processing an exception generated in the CPU 1 are controlled by a plurality of users 14 in which necessary processing is described. OS (operating s) that controls
system 12). Further, the real-time OS 12 is provided with a memory release position management mechanism 13.

【0011】リアルタイムOS12は、発生した外部事
象にリアルタイムに対応して、動作させるべきタスクを
判別し、そのタスクに動作権を渡すことにより、システ
ムの円滑な運用を制御するようになされている。さら
に、リアルタイムOS12は、上述したように、メモリ
解放位置管理機構13を備えており、タスクによって解
放されたメモリブロックを管理するようになされてい
る。
The real-time OS 12 determines a task to be operated in real time in response to an external event that has occurred, and transfers an operation right to the task, thereby controlling the smooth operation of the system. Further, as described above, the real-time OS 12 includes the memory release position management mechanism 13, and manages the memory block released by the task.

【0012】次に、図1に示した実施の形態の動作につ
いて説明する。上記実施の形態において、CPU1は、
タイマコントローラ6による一定時間毎の割り込みや、
外部割り込み要因とつながった割り込みコントローラ7
からの割り込みなどの様々な外部要因に対して、適切な
処理を行っていく必要がある。
Next, the operation of the embodiment shown in FIG. 1 will be described. In the above embodiment, the CPU 1
Interruption by the timer controller 6 at fixed time intervals,
Interrupt controller 7 connected to external interrupt factor
It is necessary to perform appropriate processing for various external factors such as interrupts from the Internet.

【0013】これを実現するために、CPU1上で動作
するソフトウェアは、図2に示したように、リアルタイ
ムOS12によって制御されるようになっている。そし
て、リアルタイムOS12は、発生した事象を処理する
タスクを複数管理し、発生した様々な事象に対して、必
要なタスク14を判断し、実行させる。
In order to realize this, software operating on the CPU 1 is controlled by a real-time OS 12 as shown in FIG. Then, the real-time OS 12 manages a plurality of tasks for processing the generated event, and determines and executes a necessary task 14 for various generated events.

【0014】タスク14は、最低限必要なワーク領域を
静的に確保するが、一時的に必要なメモリは必要なとき
に動的に獲得、解放する。必要なときに必要なタスク1
4がメモリ3を使用することで、メモリ容量を節約でき
る。
The task 14 statically secures a minimum required work area, but dynamically acquires and releases a temporarily required memory dynamically when required. Task 1 when you need it
By using the memory 3, the memory capacity can be saved.

【0015】図3に示すように、メモリ3はリアルタイ
ムOS12が管理しており、タスク14はメモリ3の獲
得、解放をリアルタイムOS12を介して行う。タスク
14からメモリ獲得要求が発生すると、リアルタイムO
S12のメモリ制御部23は、空きメモリブロックを検
索して要求サイズを満たすブロックを検出し、要求を行
ったタスク14に対して、検出されたメモリブロックア
ドレスを渡すことによりメモリブロックを与える。
As shown in FIG. 3, the memory 3 is managed by the real-time OS 12, and the task 14 acquires and releases the memory 3 via the real-time OS 12. When a memory acquisition request is issued from task 14, real-time O
The memory control unit 23 in S12 searches for a free memory block to detect a block that satisfies the request size, and gives the detected memory block address to the task 14 that has issued the request, thereby giving the memory block an address.

【0016】メモリ解放位置管理機構13には、直近
(最も最近)に解放したメモリブロックの先頭アドレス
が保持されているが、このメモリ解放位置管理機構13
によって、メモリブロックが解放される度にメモリブロ
ックアドレスが更新され、最も最近に解放されたメモリ
ブロックのアドレスが保持される。
The head address of the memory block released most recently (most recently) is held in the memory release position management mechanism 13.
Thus, each time a memory block is released, the memory block address is updated, and the address of the most recently released memory block is held.

【0017】タスク14からメモリ解放要求が発生した
とき、リアルタイムOS12は、メモリブロック14の
解放位置を検索する必要があるが、メモリ解放位置管理
機構13から、先に保存されたメモリブロックの先頭ア
ドレスを取り出して、いま解放されるメモリブロックの
先頭アドレスと比較する。この比較によって、いま、解
放されるメモリブロックの先頭アドレスと、先に解放さ
れたメモリブロックとが連続している場合、高速に解放
位置を検出することが可能となる。
When a memory release request is issued from the task 14, the real-time OS 12 needs to search for the release position of the memory block 14, but the memory release position management mechanism 13 sends the start address of the previously saved memory block. And compares it with the start address of the memory block to be released. By this comparison, if the head address of the memory block to be released and the previously released memory block are continuous, the release position can be detected at high speed.

【0018】また、メモリ解放処理が連続しない場合、
例えば、メモリ解放処理の途中にメモリ獲得処理が実行
されるような場合、メモリ獲得処理において、メモリ解
放位置管理機構13で保存しているメモリブロック先頭
アドレスを予め決められた初期値に戻し、次にメモリ解
放要求が発生した場合は、従来通りの検索を行うことと
する。
If the memory release processing is not continuous,
For example, when the memory acquisition process is performed during the memory release process, in the memory acquisition process, the head address of the memory block stored in the memory release position management mechanism 13 is returned to a predetermined initial value, and the next When a memory release request is issued, the conventional search is performed.

【0019】図4は、メモリブロック管理テーブルの構
成例を示す図である。メモリ3はそれまでにタスク14
によって要求されたメモリブロックのサイズに分割され
ている。それぞれのメモリブロックには、メモリブロッ
ク管理テーブルが備わっていて、メモリブロック管理テ
ーブルは次のブロックの先頭アドレスを指し示す次のブ
ロック31と、前のブロックの先頭アドレスを指し示す
前のブロック32と、タスクによって使用可能なメモリ
領域の範囲を示す先頭アドレス33及び最終アドレス3
4と、メモリブロックの状態を示すブロック使用状況フ
ラグ(以下では、単にフラグという)35から構成され
ている。フラグ35に“F(Free)”が格納されて
いるときは空きメモリであることを示しており、“U
(Used)”が格納されているときは使用中メモリで
あることを示している。
FIG. 4 is a diagram showing a configuration example of the memory block management table. Memory 3 has already been assigned to task 14
Is divided into the size of the requested memory block. Each memory block is provided with a memory block management table. The memory block management table includes a next block 31 indicating the start address of the next block, a previous block 32 indicating the start address of the previous block, and a task. Address 33 and last address 3 indicating the range of the memory area usable by
4 and a block use status flag (hereinafter simply referred to as a flag) 35 indicating the state of the memory block. When "F (Free)" is stored in the flag 35, it indicates that the memory is free and "U (Free)" is set.
When (Used) "is stored, it indicates that the memory is in use.

【0020】図5は、メモリ管理テーブルとメモリブロ
ックの関連を示す図である。空きブロックはアドレス順
に繋がれており、使用中のブロックはブロックが獲得さ
れた順に繋がれている。空きメモリ全体を管理する空き
メモリ管理テーブル41は、空きメモリの先頭ブロック
のアドレスを保持するフィールドである空きメモリ先頭
ブロック42と、空きメモリの最終ブロックのアドレス
を保持するフィールドである空きメモリ最終ブロック4
3を備えており、メモリ先頭ブロック42は空きメモリ
の先頭ブロックを、空きメモリ最終ブロック43は空き
メモリの最終ブロックをそれぞれ指し示している。
FIG. 5 is a diagram showing the relationship between the memory management table and the memory blocks. Empty blocks are connected in order of address, and blocks in use are connected in the order in which the blocks were acquired. The free memory management table 41 for managing the entire free memory includes a free memory first block 42 which is a field for holding the address of the first block of the free memory, and a free memory last block which is a field for holding the address of the last block of the free memory. 4
3, the memory head block 42 indicates the head block of the free memory, and the free memory last block 43 indicates the last block of the free memory.

【0021】また、使用メモリ全体を管理する使用メモ
リ管理テーブル44は、使用メモリの先頭ブロックのア
ドレスを保持するフィールドである使用メモリ先頭ブロ
ック45と、使用メモリの最終ブロックのアドレスを保
持するフィールドである使用メモリ最終ブロック46を
備えており、使用メモリ先頭ブロック45は使用メモリ
の先頭ブロックを、使用メモリ最終ブロック46は使用
メモリの最終ブロックをそれぞれ指し示している。
The used memory management table 44 for managing the entire used memory includes a used memory first block 45 which is a field for holding the address of the first block of the used memory, and a field for holding the address of the last block of the used memory. A certain used memory last block 46 is provided. The used memory head block 45 indicates the head block of the used memory, and the used memory last block 46 indicates the last block of the used memory.

【0022】図6は、メモリ3とメモリ解放位置管理機
構13の関係を示す図である。同図に示すように、メモ
リ3の最も最近解放された空きメモリブロックは、メモ
リ解放位置管理機構13内のメモリ解放位置ポインタで
指し示されている。
FIG. 6 is a diagram showing the relationship between the memory 3 and the memory release position management mechanism 13. As shown in the figure, the most recently released free memory block in the memory 3 is indicated by a memory release position pointer in the memory release position management mechanism 13.

【0023】タスク14は、必要なときにメモリ3を動
的に獲得、解放するが、図3に示すように、リアルタイ
ムOS12がメモリ3を管理しているため、タスク14
はメモリ3の獲得、解放をリアルタイムOS12を介し
て行う。タスク14からメモリ獲得要求が発生すると、
リアルタイムOS12は、図5で示されるような空きメ
モリ管理テーブル41の空きメモリ先頭ブロック42か
らメモリブロックを辿って、タスク14が要求するメモ
リサイズ(要求サイズ)を満たす空きメモリブロックを
検出する。
The task 14 dynamically acquires and releases the memory 3 when necessary. Since the real-time OS 12 manages the memory 3 as shown in FIG.
Performs acquisition and release of the memory 3 via the real-time OS 12. When a memory acquisition request is issued from task 14,
The real-time OS 12 detects a free memory block that satisfies the memory size (request size) requested by the task 14 by tracing the memory block from the free memory head block 42 of the free memory management table 41 as shown in FIG.

【0024】メモリブロックのサイズは、次式(1)よ
り求められる。
The size of the memory block is obtained from the following equation (1).

【0025】 メモリブロックサイズ=(最終アドレス34)−(先頭アドレス33) ・・・(1)Memory block size = (last address 34) − (start address 33) (1)

【0026】空きメモリブロックが要求サイズを満たし
ている場合、そのメモリブロックをタスク14に与えて
処理を終了する。一方、要求サイズが満たされていない
場合、次のブロック31を順次たどり、式(1)により
メモリブロックのサイズを算出し、要求サイズを満たす
メモリブロックが検出できるまで検索する。
If the free memory block satisfies the required size, the memory block is given to the task 14 and the process is terminated. On the other hand, if the required size is not satisfied, the next block 31 is sequentially traced, the size of the memory block is calculated by the equation (1), and the search is performed until a memory block satisfying the required size is detected.

【0027】メモリ解放位置管理機構13は、メモリブ
ロックの先頭アドレスを保持しているが、このメモリ解
放位置管理機構13によってメモリブロックが解放され
る度に、メモリブロックアドレスを更新し、最も最近解
放されたメモリブロックのアドレスを保持するようにし
ている。
The memory release position management mechanism 13 holds the head address of a memory block. Every time a memory block is released by the memory release position management mechanism 13, the memory block address is updated and the memory block address is updated most recently. The address of the memory block is held.

【0028】タスク14からのメモリ解放要求が発生し
たとき、リアルタイムOS12は、ブロックの断片化を
防ぐためにメモリブロックの解放位置を検索する必要が
ある。このとき、メモリ解放位置管理機構13から、先
に保存されたメモリブロックの先頭アドレスを取り出し
て、解放されるメモリブロックの先頭アドレスと比較す
る。この比較によって、いま、解放しようとしているメ
モリブロックが、先に解放されたメモリブロックと連続
している場合、解放位置を検索する必要がないため、高
速に解放位置を検出することができる。
When a memory release request is issued from the task 14, the real-time OS 12 needs to search for a release position of a memory block in order to prevent block fragmentation. At this time, the head address of the previously saved memory block is extracted from the memory release position management mechanism 13 and compared with the head address of the memory block to be released. By this comparison, if the memory block to be released is continuous with the previously released memory block, it is not necessary to search for the release position, so that the release position can be detected at high speed.

【0029】また、メモリ関連の処理において、メモリ
解放処理が連続しない場合、例えば、メモリ解放処理の
後にメモリ獲得処理が実行されるようなとき、メモリ獲
得処理において、メモリ解放位置管理機構13で保存し
ているメモリブロック先頭アドレスを予め決められた初
期値NULLに戻す。そして、次にメモリ解放要求が発
生した場合は、従来通り、空きメモリ先頭ブロック42
からの検索を行うこととする。
In the memory-related processing, when the memory release processing is not continuous, for example, when the memory acquisition processing is executed after the memory release processing, the memory release position management mechanism 13 saves the data in the memory acquisition processing. The memory block start address is returned to a predetermined initial value NULL. Then, when a memory release request is generated next, the free memory first block 42
Search from.

【0030】これは、メモリ獲得要求が発生した場合、
連続したアドレスのメモリブロックが解放される可能性
も低くなり、また、メモリ解放位置管理機構13で管理
しているアドレスからメモリ3が獲得される可能性があ
り、処理が複雑になり、これによって、リアルタイムO
S12の性能が低下しないようにするためである。
This is because when a memory acquisition request occurs,
The possibility that a memory block of a continuous address is released is reduced, and the memory 3 may be acquired from an address managed by the memory release position management mechanism 13, which complicates the processing. , Real-time O
This is to prevent the performance of S12 from deteriorating.

【0031】メモリ解放要求が発生すると、リアルタイ
ムOS12は、図7のフローチャートに示すように、ス
テップ61において、メモリ解放位置管理機構13に保
持されているアドレスが、初期値NULLであるかどう
かの確認が行われる。そして、メモリ解放位置管理機構
13に保持されているアドレスがNULLである場合、
ステップ65に進む。
When a memory release request is generated, the real-time OS 12 checks in step 61 whether the address held in the memory release position management mechanism 13 is the initial value NULL, as shown in the flowchart of FIG. Is performed. When the address held in the memory release position management mechanism 13 is NULL,
Proceed to step 65.

【0032】ステップ65においては、従来通り、空き
メモリ管理テーブル41の空きメモリ先頭ブロック42
から順に解放位置を検索する。次式(2)を満たす場合
は、解放された空きメモリブロックの先頭アドレスを、
空きメモリ管理テーブル41の空きメモリ先頭ブロック
42に登録して、空きメモリブロックの次のブロック3
1に、それまで空きメモリ管理テーブル41の空きメモ
リ先頭ブロック42に登録されていたアドレスを登録す
る。また、それまで、空きメモリ管理テーブル41の空
きメモリ先頭ブロック42のアドレスで指定される空き
メモリブロックの前のブロック32に、いま解放された
メモリブロックの先頭アドレスを登録する。
At step 65, the free memory start block 42 of the free memory management table 41 is
The release position is searched in order from. If the following expression (2) is satisfied, the start address of the released free memory block is
Registered in the free memory head block 42 of the free memory management table 41, the next block 3 of the free memory block
1, the address registered in the free memory head block 42 of the free memory management table 41 is registered. Until that time, the head address of the currently released memory block is registered in the block 32 before the free memory block specified by the address of the free memory head block 42 in the free memory management table 41.

【0033】 (空きメモリ先頭ブロック42に格納されているアドレス)>(解放されるメ モリブロックの先頭アドレス) ・・・(2)(Address stored in free memory first block 42)> (first address of memory block to be released) (2)

【0034】一方、ステップ61において、メモリ解放
位置管理機構13により保持されているアドレスが初期
値NULLであり、かつ式(2)を満たさない場合、次
式(3)を満たす間は、空きメモリ先頭ブロックから、
解放位置を検索する。即ち、空きメモリの先頭ブロック
から、順次、各ブロックの次のブロック31に格納され
ている先頭アドレスと、解放するメモリブロックの先頭
アドレスを比較して、初めて次式(4)を満たすとき、
そのブロックの直前が解放位置となる。そして、ステッ
プ65の処理が終了すると、ステップ66に進み、上記
解放位置に解放されたメモリブロックを挿入する。
On the other hand, in step 61, if the address held by the memory release position management mechanism 13 is the initial value NULL and does not satisfy the expression (2), the free memory is held until the following expression (3) is satisfied. From the first block,
Find the release position. That is, the head address stored in the next block 31 of each block is sequentially compared with the head address of the memory block to be released from the head block of the free memory, and when the following expression (4) is satisfied for the first time,
The release position is immediately before the block. When the processing in step 65 is completed, the process proceeds to step 66, where the released memory block is inserted into the release position.

【0035】 (解放されるメモリブロックの先頭アドレス)>(次のブロック31の先頭ア ドレス) ・・・(3)(Start address of memory block to be released)> (Start address of next block 31) (3)

【0036】 (次のブロック31の先頭アドレス)>(解放されるメモリブロックの先頭ア ドレス) ・・・(4)(Start address of next block 31)> (Start address of memory block to be released) (4)

【0037】一方、メモリ解放位置管理機構13が保持
しているアドレスが初期値NULLでない場合、解放さ
れたメモリブロックは、メモリ解放位置管理機構13が
保持しているアドレスの近辺に存在する可能性が高い。
従って、メモリ解放位置管理機構13内のポインタが示
すアドレスを基準にして、解放されるメモリブロックの
解放位置を、次式(5)、又は次式(6)で、予めより
近い方を求めることにより、解放位置を検出する。
On the other hand, when the address held by the memory release position management mechanism 13 is not the initial value NULL, the released memory block may exist near the address held by the memory release position management mechanism 13. Is high.
Therefore, based on the address indicated by the pointer in the memory release position management mechanism 13, the release position of the memory block to be released is determined in advance by the following equation (5) or (6). To detect the release position.

【0038】 (メモリ解放位置管理機構保存アドレス)>(解放されるメモリブロックの先 頭アドレス) ・・・(5)(Memory release position management mechanism storage address)> (first address of memory block to be released) (5)

【0039】 (解放されるメモリブロックの先頭アドレス)>(メモリ解放位置管理機構保 存アドレス) ・・・(6)(Start address of memory block to be released)> (Address stored in memory release position management mechanism) (6)

【0040】即ち、ステップ62において、解放された
メモリブロックのアドレスが、メモリ解放位置管理機構
13に保存されているアドレスより大きいか否かが判定
される。解放されたメモリブロックのアドレスが、メモ
リ解放位置管理機構13に保存されているアドレスより
大きくない(小さい)(上記式(5)を満たす)と判定
された場合、ステップ63に進み、アドレスがより小さ
い方向に、メモリ解放位置の検索を行う。
That is, in step 62, it is determined whether or not the address of the released memory block is larger than the address stored in the memory release position management mechanism 13. If it is determined that the address of the released memory block is not larger (smaller) than the address stored in the memory release position management mechanism 13 (satisfies the above expression (5)), the process proceeds to step 63, where the address becomes higher. Searches the memory release position in the smaller direction.

【0041】一方、解放されたメモリブロックのアドレ
スが、メモリ解放位置管理機構13に保存されているア
ドレスより大きい(上記式(6)を満たす)と判定され
た場合、ステップ64に進み、アドレスがより大きい方
向に、メモリ解放位置の検索を行う。
On the other hand, if it is determined that the address of the released memory block is larger than the address stored in the memory release position management mechanism 13 (satisfies the above expression (6)), the process proceeds to step 64, where the address is determined. Search for a memory release position in the larger direction.

【0042】そして、解放位置を検出した後、ステップ
66において、検出された解放位置に解放されたメモリ
ブロックが挿入される。次に、ステップ67において、
解放位置メモリブロックの前のブロック32に格納され
ているアドレスで示される前のメモリブロックの終了ア
ドレス34と、解放されたメモリブロックの先頭アドレ
スが一致するか否か、即ち、挿入したメモリブロックに
隣接する空きメモリブロックが存在するか否かが判定さ
れる。
After detecting the release position, in step 66, the released memory block is inserted into the detected release position. Next, in step 67,
Whether the end address 34 of the previous memory block indicated by the address stored in the block 32 before the release position memory block matches the start address of the released memory block, that is, whether the inserted memory block It is determined whether there is an adjacent free memory block.

【0043】その結果、解放位置のメモリブロックの前
のブロック32に格納されているアドレスで示される前
のメモリブロックの終了アドレス34と、解放されたメ
モリブロックの先頭アドレスが一致する、即ち、挿入し
たメモリブロックに隣接する空きメモリブロックが存在
すると判定された場合、ステップ68に進み、前のブロ
ック32に格納されているアドレスで示される空きメモ
リブロックと結合する。
As a result, the end address 34 of the previous memory block indicated by the address stored in the block 32 before the memory block at the release position matches the start address of the released memory block, that is, the insertion address. If it is determined that there is a free memory block adjacent to the selected memory block, the process proceeds to step 68, where the free memory block indicated by the address stored in the previous block 32 is combined.

【0044】また、解放位置のメモリブロックの次のブ
ロック31に格納されているアドレスで示される次のメ
モリブロックの先頭アドレスと、解放されたメモリブロ
ックの終了アドレス34が一致する場合、次のブロック
31に格納されているアドレスで示される次のメモリブ
ロックと結合する。そして、新たに、1つの空きメモリ
ブロックとする。
If the start address of the next memory block indicated by the address stored in the block 31 next to the memory block at the release position matches the end address 34 of the released memory block, the next block It is linked with the next memory block indicated by the address stored in 31. Then, a new free memory block is set.

【0045】そして、ステップ69において、上述した
ようにして結合してできたこの空きメモリブロックの先
頭アドレスを、メモリ解放位置管理機構13に保持させ
るようにする。
Then, in step 69, the head address of the free memory block formed as described above is held by the memory release position management mechanism 13.

【0046】また、ステップ67において、挿入したメ
モリブロックに隣接する空きメモリブロックが存在しな
いと判定された場合、挿入したメモリブロックの先頭ア
ドレスをメモリ解放位置管理機構13に記憶させる。
If it is determined in step 67 that there is no free memory block adjacent to the inserted memory block, the head address of the inserted memory block is stored in the memory release position management mechanism 13.

【0047】以上説明したように、上記実施の形態によ
り、以下のような効果を得ることができる。即ち、メモ
リブロックが連続して解放される場合、メモリブロック
解放位置を検索する回数が減少するため、メモリ解放処
理が占有するCPU1の時間を短縮することができ、リ
アルタイムOS12の処理能力を高めることができる。
その理由は、解放した最新のメモリブロックの先頭アド
レスが保存されているため、メモリブロックの解放位置
を検出するために必要なメモリブロック検索回数を減少
させることができるからである。
As described above, the following effects can be obtained by the above embodiment. That is, when memory blocks are successively released, the number of times of searching for the memory block release position is reduced, so that the time of the CPU 1 occupied by the memory release processing can be reduced, and the processing capability of the real-time OS 12 can be increased. Can be.
The reason is that, since the head address of the latest released memory block is stored, the number of memory block searches required to detect the release position of the memory block can be reduced.

【0048】なお、メモリブロックのサイズは固定で分
割されているメモリブロック管理方式で、メモリ解放位
置管理機構を備えるようにしても良い。
The memory block size may be fixed and divided by a memory block management method, and a memory release position management mechanism may be provided.

【0049】また、上記実施の形態では、メモリ空間
を、使用中のメモリと空きメモリの2つに分けた場合に
ついて説明したが、メモリを別の用途で使用しても良
い。
Further, in the above embodiment, the case where the memory space is divided into the used memory and the free memory has been described, but the memory may be used for another purpose.

【0050】さらに、上記実施の形態においては、本発
明をマイクロコンピュータに追うようする場合について
説明したが、これに限定されるものではない。
Further, in the above embodiment, the case where the present invention is followed by a microcomputer has been described, but the present invention is not limited to this.

【0051】[0051]

【発明の効果】以上の如く、本発明のメモリ管理方法お
よびメモリ管理装置、並びに記録媒体によれば、メモリ
を、割り付けが行われている使用メモリと、解放されて
いる未使用メモリとに分割してブロック単位で管理し、
使用メモリをメモリを獲得した順番に繋ぎ、未使用メモ
リをアドレス順に繋ぎ、使用メモリの所定のブロックを
解放するとき、解放されるブロックの先頭アドレスを保
存し、保存しているブロックの先頭アドレスを基準にし
て、次のブロックの解放位置の検出を行う場合、解放さ
れる次のブロックの先頭アドレスが、保存されている先
頭アドレスより大きいか否かが判定され、解放される次
のブロックの先頭アドレスが、保存されている先頭アド
レスより大きくないと判定されたとき、アドレスがより
小さい方向に、メモリ解放位置の検索を行い、解放され
る次のブロックのアドレスが、保存されている先頭アド
レスより大きいと判定されたとき、アドレスがより大き
い方向に、メモリ解放位置の検索を行い、各ブロック
は、少なくとも、そのブロックに繋がれている次のブロ
ックの先頭アドレスと、そのブロックの前のブロックの
先頭アドレスと、そのブロックのユーザ使用可能領域の
先頭アドレスと、そのブロックのユーザ使用可能領域の
終了アドレスとからなるテーブルにより管理され、使用
メモリは、使用メモリの先頭のブロックの先頭アドレス
と、使用メモリの最後のブロックの先頭アドレスからな
るテーブルにより管理され、未使用メモリは、未使用メ
モリの先頭のブロックの先頭アドレスと、未使用メモリ
の最後のブロックの先頭アドレスからなるテーブルによ
り管理されるようにしたので、全メモリ領域から解放位
置を検出するときの検索回数を減少させ、CPUの占有
時間を短くすることができ、メモリ解放処理の高速化を
実現するとともに、リアルタイムOSの性能を向上させ
ることができる。
As described above, according to the memory management method, the memory management device, and the recording medium of the present invention, the memory is divided into the used memory allocated and the unused memory released. And manage them in blocks,
When the used memory is connected in the order in which the memory was acquired, the unused memory is connected in the order of the addresses, and when releasing a predetermined block of the used memory, the leading address of the released block is stored, and the leading address of the saved block is stored. as a reference, the case of detecting the release position of the next block, is released
The start address of the next block is
It is determined whether the address is greater than the head address and the next
The start address of the block is
Address is not greater than the address,
In the smaller direction, search for the memory release location and release
The address of the next block is
Address is larger than the address
Search for the memory release position in the direction
Is at least the next block connected to that block.
Block start address and the block before that block
The start address and the user-usable area of the block
The start address and the user-usable area of the block
Used and managed by a table consisting of end addresses
Memory is the start address of the first block of the used memory
From the start address of the last block of the used memory.
Unused memory is managed by a table
Start address of the first block of memory and unused memory
Table consisting of the start address of the last block of
The number of searches for detecting a release position from all memory areas can be reduced, the time occupied by the CPU can be shortened, the memory release processing can be speeded up, and the real-time OS can be managed. Performance can be improved.

【図面の簡単な説明】[Brief description of the drawings]

【図1】本発明のメモリ管理方法が適用されるマイクロ
コンピュータの一実施の形態のハードウェア構成を示す
図である。
FIG. 1 is a diagram showing a hardware configuration of an embodiment of a microcomputer to which a memory management method of the present invention is applied.

【図2】本発明のメモリ管理方法が適用されるマイクロ
コンピュータの一実施の形態のソフトウェア構成を示す
図である。
FIG. 2 is a diagram illustrating a software configuration of an embodiment of a microcomputer to which a memory management method according to the present invention is applied;

【図3】タスクとリアルタイムOS12のメモリ獲得、
解放処理を説明する図である。
FIG. 3 shows a task and memory acquisition of the real-time OS 12,
It is a figure explaining release processing.

【図4】メモリブロック管理テーブルの構成例を示す図
である。
FIG. 4 is a diagram illustrating a configuration example of a memory block management table.

【図5】メモリ管理テーブル41,44とメモリブロッ
クの関係を示す図である。
FIG. 5 is a diagram showing a relationship between memory management tables 41 and 44 and memory blocks.

【図6】メモリ3とメモリ解放位置管理機構13の関係
を示す図である。
FIG. 6 is a diagram showing a relationship between a memory 3 and a memory release position management mechanism 13.

【図7】メモリ解放処理の処理手順を説明するフローチ
ャートである。
FIG. 7 is a flowchart illustrating a processing procedure of a memory release processing.

【符号の説明】[Explanation of symbols]

1 CPU 2 ROM 3 メインメモリ 4 記憶装置 5 メモリコントローラ 6 タイマコントローラ 7 割り込みコントローラ 9 A/Dバス 10 割り込みハンドラ 11 例外ハンドラ 12 リアルタイムOS 13 メモリ解放位置管理機構 14 タスク 23 メモリ制御部 31 次のブロック 32 前のブロック 33 先頭アドレス 34 最終アドレス 35 ブロック使用状況フラグ 41 空きメモリ管理テーブル 42 空きメモリ先頭ブロック 43 空きメモリ最終ブロック 44 使用メモリ管理テーブル 45 使用メモリ先頭ブロック 46 使用メモリ最終ブロック DESCRIPTION OF SYMBOLS 1 CPU 2 ROM 3 Main memory 4 Storage device 5 Memory controller 6 Timer controller 7 Interrupt controller 9 A / D bus 10 Interrupt handler 11 Exception handler 12 Real-time OS 13 Memory release position management mechanism 14 Task 23 Memory control unit 31 Next block 32 Previous block 33 Start address 34 End address 35 Block use status flag 41 Free memory management table 42 Free memory first block 43 Free memory last block 44 Used memory management table 45 Used memory first block 46 Used memory last block

───────────────────────────────────────────────────── フロントページの続き (58)調査した分野(Int.Cl.7,DB名) G06F 12/02 540 ──────────────────────────────────────────────────続 き Continued on front page (58) Field surveyed (Int. Cl. 7 , DB name) G06F 12/02 540

Claims (3)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 タスクからの要求に応じて、前記タスク
に対してメモリの割り付けおよび解放を行うメモリ管理
方法であって、 前記メモリを、割り付けが行われている使用メモリと、
解放されている未使用メモリとに分割してブロック単位
で管理し、 前記使用メモリをメモリを獲得した順番に繋ぎ、前記未
使用メモリをアドレス順に繋ぎ、 前記使用メモリの所定のブロックを解放するとき、解放
されるブロックの先頭アドレスを保存し、 保存している前記ブロックの先頭アドレスを基準にし
て、次のブロックの解放位置の検出を行う場合、解放さ
れる次のブロックの先頭アドレスが、保存されている前
記先頭アドレスより大きいか否かが判定され、解放され
る次のブロックの先頭アドレスが、保存されている前記
先頭アドレスより大きくないと判定されたとき、アドレ
スがより小さい方向に、メモリ解放位置の検索を行い、
解放される次のブロックのアドレスが、保存されている
前記先頭アドレスより大きいと判定されたとき、アドレ
スがより大きい方向に、メモリ解放位置の検索を行い、 前記各ブロックは、少なくとも、そのブロックに繋がれ
ている次のブロックの先頭アドレスと、そのブロックの
前のブロックの先頭アドレスと、そのブロックのユーザ
使用可能領域の先頭アドレスと、そのブロックのユーザ
使用可能領域の終了アドレスとからなるテーブルにより
管理され、 前記使用メモリは、前記使用メモリの先頭のブロックの
先頭アドレスと、前記使用メモリの最後のブロックの先
頭アドレスからなるテーブルにより管理され、 前記未使用メモリは、前記未使用メモリの先頭のブロッ
クの先頭アドレスと、前記未使用メモリの最後のブロッ
クの先頭アドレスからなるテーブルにより管理される
とを特徴とするメモリ管理方法。
1. A memory management method for allocating and releasing memory to a task in response to a request from the task, comprising:
When the memory is divided into free unused memories and managed in block units, the used memories are connected in the order in which the memories are acquired, the unused memories are connected in the order of addresses, and a predetermined block of the used memory is released. If the save the start address of the block to be released, based on the head address of the block that stores, to detect the release position of the next block, is released
Before the next block is saved.
It is determined whether the address is greater than the
The start address of the next block is
If it is determined that the address is not larger than the start address,
Search for the memory release position in the direction where the
The address of the next block to be freed is saved
If it is determined that the address is larger than the start address,
A search for a memory release position is performed in a direction in which the blocks are larger, and each block is connected to at least the block.
Address of the next block that is
Start address of previous block and user of that block
Start address of usable area and user of that block
According to the table consisting of the end address of the usable area
Managed, and the used memory is the first block of the used memory.
Start address and the end of the last block of the used memory
The unused memory is managed by a table including a head address, and the unused memory is a block at the head of the unused memory.
Block start address and the last block of the unused memory.
A memory management method characterized in that the memory management method is managed by a table including a head address of the memory.
【請求項2】 タスクからの要求に応じて、前記タスク
に対してメモリの割り付けおよび解放を行うメモリ管理
装置であって、 前記メモリを、割り付けが行われている使用メモリと、
解放されている未使用メモリとに分割してブロック単位
で管理し、前記使用メモリを、メモリを獲得した順番に
ぎ、前記未使用メモリを、アドレス順に繋ぐメモリ管
理手段と、 前記使用メモリの所定のブロックを解放するとき、解放
されるブロックの先頭アドレスを保存する保存手段と、 前記保存手段によって保存されている前記ブロックの先
頭アドレスを基準にして、次のブロックの解放位置の検
出を行う場合、解放される次のブロックの先頭アドレス
が、前記保存手段によって保存されている前記先頭アド
レスより大きいか否かが判定され、解放される次のブロ
ックの先頭アドレスが、前記保存手段によって保存され
ている前記先頭アドレスより大きくないと判定されたと
き、アドレスがより小さい方向に、メモリ解放位置の検
索を行い、解放される次のブロックのアドレスが、前記
保存手段によって保存されている前記先頭アドレスより
大きいと判定されたとき、アドレスがより大きい方向
に、メモリ解放位置の検索を行う検出手段とを備え、 前記各ブロックは、少なくとも、そのブロックに繋がれ
ている次のブロックの先頭アドレスと、そのブロックの
前のブロックの先頭アドレスと、そのブロックのユーザ
使用可能領域の先頭アドレスと、そのブロックのユーザ
使用可能領域の終了アドレスとからなるテーブルにより
管理され、 前記使用メモリは、前記使用メモリの先頭のブロックの
先頭アドレスと、前記使用メモリの最後のブロックの先
頭アドレスからなるテーブルにより管理され、 前記未使用メモリは、前記未使用メモリの先頭のブロッ
クの先頭アドレスと、前記未使用メモリの最後のブロッ
クの先頭アドレスからなるテーブルにより管理される
とを特徴とするメモリ管理装置。
2. A memory management device for allocating and releasing memory for a task in response to a request from a task, comprising: a memory used for the allocation;
Divided into the unused memory being freed managed in block units, the use memory, <br/> sequentially acquiring the memory tied technique, the unused memory, tether memory tube in address order
Management means; storage means for storing a start address of a released block when releasing a predetermined block of the used memory; and, based on a start address of the block stored by the storage means, When detecting the release position of a block, the start address of the next block to be released
Is the first address stored by the storage means.
The next block to be released.
The start address of the lock is stored by the storage means.
Is determined not to be greater than the starting address
Memory release position in the direction of smaller addresses.
The address of the next block to be searched and released is
From the start address stored by the storage means
When it is determined that the address is larger, the direction of the address is larger
In, e Bei and detection means for searching the memory release position, wherein each block, at least, is connected to the block
Address of the next block that is
Start address of previous block and user of that block
Start address of usable area and user of that block
According to the table consisting of the end address of the usable area
Managed, and the used memory is the first block of the used memory.
Start address and the end of the last block of the used memory
The unused memory is managed by a table including a head address, and the unused memory is a block at the head of the unused memory.
Block start address and the last block of the unused memory.
A memory management device characterized in that the memory management device is managed by a table including a head address of the memory.
【請求項3】 タスクからの要求に応じて、前記タスク
に対してメモリの割り付けおよび解放を行うメモリ管理
方法をコンピュータに実行させるためのプログラムを記
録したコンピュータ読み取り可能な記録媒体であって、 前記メモリを、割り付けが行われている使用メモリと、
解放されている未使用メモリとに分割してブロック単位
で管理し、 前記使用メモリをメモリを獲得した順番に繋ぎ、前記未
使用メモリをアドレス順に繋ぎ、 前記使用メモリの所定のブロックを解放するとき、解放
されるブロックの先頭アドレスを保存し、 保存している前記ブロックの先頭アドレスを基準にし
て、次のブロックの解放位置の検出を行う場合、解放さ
れる次のブロックの先頭アドレスが、保存されている前
記先頭アドレスより大きいか否かが判定され、解放され
る次のブロックの先頭アドレスが、保存されている前記
先頭アドレスより大きくないと判定されたとき、アドレ
スがより小さい方向に、メモリ解放位置の検索を行い、
解放される次のブロックのアドレスが、保存されている
前記先頭アドレスより大きいと判定されたとき、アドレ
スがより大きい方向に、メモリ解放位置の検索を行い、 前記各ブロックは、少なくとも、そのブロックに繋がれ
ている次のブロックの先頭アドレスと、そのブロックの
前のブロックの先頭アドレスと、そのブロックのユーザ
使用可能領域の先頭アドレスと、そのブロックのユーザ
使用可能領域の終了アドレスとからなるテーブルにより
管理され、 前記使用メモリは、前記使用メモリの先頭のブロックの
先頭アドレスと、前記使用メモリの最後のブロックの先
頭アドレスからなるテーブルにより管理され、 前記未使用メモリは、前記未使用メモリの先頭のブロッ
クの先頭アドレスと、前記未使用メモリの最後のブロッ
クの先頭アドレスからなるテーブルにより管理されるメ
モリ管理方法を前記コンピュータに実行させるためのプ
ログラムを記録したコンピュータ読み取り可能な記録媒
体。
3. The task according to a request from the task.
Management that allocates and frees memory for memory
Write a program that causes a computer to perform the method.
A recorded computer-readable recording medium, wherein the memory is used memory to which allocation is performed,
Divided into free unused memory and block units
And connect the used memories in the order in which the memories were acquired.
When the used memory is connected in the order of addresses and a predetermined block of the used memory is released, the release is performed.
The start address of the block to be stored is stored, and based on the start address of the stored block.
To detect the release position of the next block,
Before the next block is saved.
It is determined whether the address is greater than the
The start address of the next block is
If it is determined that the address is not larger than the start address,
Search for the memory release position in the direction where the
The address of the next block to be freed is saved
If it is determined that the address is larger than the start address,
A search for a memory release position is performed in the direction in which the
Address of the next block that is
Start address of previous block and user of that block
Start address of usable area and user of that block
According to the table consisting of the end address of the usable area
Managed, and the used memory is the first block of the used memory.
Start address and the end of the last block of the used memory
The unused memory is managed by a table including a head address, and the unused memory is a block at the head of the unused memory.
Block start address and the last block of the unused memory.
Messages managed by a table consisting of
A program for causing the computer to execute the memory management method.
Computer-readable recording medium on which the program was recorded
body.
JP34797098A 1998-11-24 1998-11-24 Memory management method, memory management device, and recording medium Expired - Fee Related JP3356090B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP34797098A JP3356090B2 (en) 1998-11-24 1998-11-24 Memory management method, memory management device, and recording medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP34797098A JP3356090B2 (en) 1998-11-24 1998-11-24 Memory management method, memory management device, and recording medium

Publications (2)

Publication Number Publication Date
JP2000163309A JP2000163309A (en) 2000-06-16
JP3356090B2 true JP3356090B2 (en) 2002-12-09

Family

ID=18393856

Family Applications (1)

Application Number Title Priority Date Filing Date
JP34797098A Expired - Fee Related JP3356090B2 (en) 1998-11-24 1998-11-24 Memory management method, memory management device, and recording medium

Country Status (1)

Country Link
JP (1) JP3356090B2 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3528525B2 (en) * 1997-07-28 2004-05-17 松下電工株式会社 Motor speed control circuit
JP4563707B2 (en) 2004-03-25 2010-10-13 ルネサスエレクトロニクス株式会社 Memory protector
JP6155867B2 (en) * 2013-06-10 2017-07-05 カシオ計算機株式会社 MEMORY CONTROL DEVICE, MEMORY CONTROL METHOD, AND PROGRAM

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
佐々政孝,動的記憶領域割付け法,情報処理,日本,社団法人情報処理学会,1983年4月,第24巻,第4号,p.408−412

Also Published As

Publication number Publication date
JP2000163309A (en) 2000-06-16

Similar Documents

Publication Publication Date Title
JP3308554B2 (en) Control device and control method of control device
JP3612339B2 (en) Data processing method and apparatus
JPH06100981B2 (en) Memory hierarchy control method
JPH02300949A (en) Memory control
JPS60147855A (en) Memory managing apparatus
JPH10254756A (en) Use of three-state reference for managing referred object
JPH0458051B2 (en)
JPH0743665B2 (en) Computer system resource management method
JPH08129457A (en) Method and apparatus for expansion,reduction and redistribution of external storage structure
EP1014264B1 (en) A system and method for facilitating safepoint synchronization in a multithreaded computer system
EP0493012A2 (en) Control system for cache storage unit
JP2002132582A (en) Reuse space reserve of compression memory system
JP3356090B2 (en) Memory management method, memory management device, and recording medium
JP2821345B2 (en) Asynchronous I / O control method
JPH05210584A (en) Digital data processor having improved paging
US5440712A (en) Database input/output control system having nonvolatile storing unit for maintaining the database
JP4506292B2 (en) Cache control method, data processing system, and processing program therefor
JPS6336538B2 (en)
JPS603229B2 (en) Information processing method
JP3325729B2 (en) Memory management device
JP3125634B2 (en) Electronic computer system
JPH0337748A (en) External storage accessing system utilizing main storage
JP4131579B2 (en) Data management system and data management method
JP3517884B2 (en) Data processing device
JP2735400B2 (en) Asynchronous I / O control method

Legal Events

Date Code Title Description
FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20071004

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20081004

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20091004

Year of fee payment: 7

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

Free format text: PAYMENT UNTIL: 20091004

Year of fee payment: 7

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

Free format text: PAYMENT UNTIL: 20101004

Year of fee payment: 8

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

Free format text: PAYMENT UNTIL: 20111004

Year of fee payment: 9

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

Free format text: PAYMENT UNTIL: 20121004

Year of fee payment: 10

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

Free format text: PAYMENT UNTIL: 20131004

Year of fee payment: 11

LAPS Cancellation because of no payment of annual fees