[go: up one dir, main page]

JP2001154860A - Memory managing method for operating system - Google Patents

Memory managing method for operating system

Info

Publication number
JP2001154860A
JP2001154860A JP33743099A JP33743099A JP2001154860A JP 2001154860 A JP2001154860 A JP 2001154860A JP 33743099 A JP33743099 A JP 33743099A JP 33743099 A JP33743099 A JP 33743099A JP 2001154860 A JP2001154860 A JP 2001154860A
Authority
JP
Japan
Prior art keywords
memory
size
block
operating system
memory block
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.)
Pending
Application number
JP33743099A
Other languages
Japanese (ja)
Inventor
Keiko Miyamoto
啓子 宮本
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 JP33743099A priority Critical patent/JP2001154860A/en
Publication of JP2001154860A publication Critical patent/JP2001154860A/en
Pending legal-status Critical Current

Links

Landscapes

  • Memory System Of A Hierarchy Structure (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide the memory managing method of an operating system for preventing the occurrence of any cache miss against any writing in an adjacent memory block even when performing access to a memory block boundary part by cache line access, and for preventing the occurrence of memory destruction due to write back in a simple constitution. SOLUTION: A request for capturing a memory of which size is designated from a task 11 is received, and a memory block having an available area of which size is not less than the size designated from the task and adjusted by using the cache line size of an operating CPU 1 as a unit size by an operation system 12 is assigned to the request for capturing a memory. Also, a request for releasing a memory of which size is designated form the task 11 is received, and a memory block having the available are of which size is not more than the size designated from the task 11 and adjusted by the cache line size unit of the operating CPU 1 by the operating system 12 is released to the request for releasing a memory.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明はオペレーティングシ
ステムのメモリ管理方法に関し、特に、キャッシュアク
セス方式が可能なメモリ空間にアクセスするオペレーテ
ィングシステムのメモリ管理方法に関する。
The present invention relates to a memory management method for an operating system, and more particularly, to a memory management method for an operating system that accesses a memory space that can be accessed by a cache.

【0002】[0002]

【従来の技術】従来のオペレーティングシステムのメモ
リ管理方法は、アプリケーションプログラムからワーク
エリアのメモリサイズが指定されて割り当て要求が発生
されると、管理しているメモリブロックから割り当て要
求されたサイズのメモリブロックの割り当てを行い、デ
ータの読み込み又は書き込みを行う。
2. Description of the Related Art In a conventional memory management method of an operating system, when a memory size of a work area is specified from an application program and an allocation request is issued, a memory block of the size requested to be allocated from the managed memory block is used. To read or write data.

【0003】一方、オペレーティングシステムが管理す
るメモリブロックの境界に忠実にメモリにアクセスする
のではなく、ハードウェア仕様による境界のブロックに
よってCPUがメモリにアクセスするケースがある。す
なわち、CPUからメモリへのキャッシュアクセスで
は、キャッシュラインサイズ単位でメモリからデータを
読み込み又は書き込む。すなわち、要求されたデータが
キャッシュラインサイズより小さい容量であっても、キ
ャッシュラインサイズの容量のデータを一括してメモリ
から読み込み又は書き込む。また、CPUは、キャッシ
ュに読み込まれているデータの実メモリのアドレス範囲
を保存しており、ライトバックという方式に基づいて、
キャッシュ内に読み込んだメモリ領域に対して書き込み
が発生すると、そのキャッシュラインに対するキャッシ
ュミスによって、データを実メモリに書き戻す。したが
って、2つのメモリブロックの境界部分にキャッシュラ
インサイズ分の未使用領域を設けない場合には以下に説
明するようにメモリの内容が破壊される可能性があっ
た。
On the other hand, there is a case where the CPU does not access the memory faithfully on the boundary of the memory block managed by the operating system, but accesses the memory by the boundary block according to the hardware specification. That is, in the cache access from the CPU to the memory, data is read or written from the memory in cache line size units. That is, even if the requested data has a smaller capacity than the cache line size, the data of the cache line size is read or written from the memory at once. Further, the CPU stores the address range of the real memory of the data read into the cache, and based on a method called write-back,
When writing occurs in the memory area read into the cache, data is written back to the real memory due to a cache miss for the cache line. Therefore, if an unused area corresponding to the cache line size is not provided at the boundary between two memory blocks, the contents of the memory may be destroyed as described below.

【0004】例えば、オペレーティングシステムが管理
するメモリブロックAとメモリブロックBが隣接し、こ
の境界がCPUからのキャッシュアクセスの単位となる
キャッシュラインサイズの領域の境界とは一致せず、1
領域の中間にあるものとする。例えば、ブロックAのブ
ロックBとの境界が含まれる部分をキャッシュアクセス
で読み込む場合、キャッシュラインサイズの容量のデー
タを一括してメモリから読み込むのでキャッシュメモリ
にブロックBの1部を含んで読み込まれる。次にブロッ
クBに非キャッシュで書き込みが行われるとすると、キ
ャッシュアクセスで読み込んだキャッシュラインの1部
についてキャッシュの内容と実メモリの内容が異なるも
のとなる。この時、そのキャッシュラインに対してキャ
ッシュミスが発生すると、ブロックBに対して、キャッ
シュに読み込まれていた古い値が書き戻されることにな
る。このことによって非キャッシュで書き込まれたメモ
リ内容の破壊が発生することになる。
For example, a memory block A and a memory block B managed by the operating system are adjacent to each other, and this boundary does not coincide with the boundary of a cache line size area serving as a unit of cache access from the CPU.
It is assumed to be in the middle of the area. For example, when a portion including the boundary between the block A and the block B is read by the cache access, data of a cache line size is read from the memory at once, so that the cache memory includes a part of the block B. Next, assuming that data is written to the block B in a non-cache state, the contents of the cache and the contents of the real memory of a part of the cache line read by the cache access are different. At this time, if a cache miss occurs for that cache line, the old value read into the cache is written back to block B. This results in the destruction of the memory contents written in non-cache.

【0005】また、特開平5−265864号公報に
は、RAMを境界アドレスAWによって2分されたアプ
リケーション利用領域とオペレーティングシステム利用
領域とから構成し、アプリケーションプログラムの書き
込み要求について出力されるメモリ書き込みアドレスと
境界アドレスとを比較し、オペレーティングシステム利
用領域に対する書き込みが発生したことが検出されると
これを禁止するものが示されている。
Japanese Patent Laid-Open Publication No. Hei 5-265864 discloses that a RAM is composed of an application use area and an operating system use area divided into two by a boundary address AW, and a memory write address output in response to a write request of an application program. And a boundary address are compared with each other, and when it is detected that writing to the operating system use area has occurred, this is prohibited.

【0006】[0006]

【発明が解決しようとする課題】しかしながら、この従
来の技術では、メモリアクセスの書き込みアドレスと境
界アドレスとを比較して禁止するか否か検出する処理を
行うので、利用領域を区別して管理すべきアクセス元が
多数存在すると、必要な処理が膨大となり、メモリ管理
処理の高速性の点で性能劣化を引き起こす可能性があ
る。
However, in this conventional technique, a process of comparing a write address of a memory access with a boundary address to detect whether or not to inhibit the memory access is performed. If there are a large number of access sources, the required processing becomes enormous, and there is a possibility that the performance may be deteriorated in terms of the speed of the memory management processing.

【0007】本発明の目的は、キャッシュラインアクセ
スでメモリブロック境界部分にアクセスしても、隣接す
るメモリブロックへの書き込みに対してキャッシュミス
が発生せず、ライトバックによるメモリ破壊の発生を防
止でき、簡単な構成でメモリ破壊を防止することにあ
る。
An object of the present invention is to prevent a cache miss from occurring in writing to an adjacent memory block even if a memory block boundary is accessed by a cache line access, thereby preventing the occurrence of memory corruption due to write-back. Another object of the present invention is to prevent memory destruction with a simple configuration.

【0008】また、本発明の他の目的は、メモリブロッ
クが解放されたときのメモリの断片化を防止し、メモリ
が虫食い状態になるのを防ぐことにある。
Another object of the present invention is to prevent fragmentation of the memory when the memory block is released, and to prevent the memory from becoming worm-like.

【0009】[0009]

【課題を解決するための手段】本発明のオペレーティン
グシステムのメモリ管理方法は、タスクからサイズを指
定したメモリ獲得要求を受け、前記メモリ獲得要求に対
し、タスクから指定されたサイズ以上でかつオペレーテ
ィングシステムが動作するCPUのキャッシュラインサ
イズを単位サイズとして調整した使用可能領域を持つメ
モリブロックを割り当てる。
A memory management method for an operating system according to the present invention receives a memory acquisition request whose size is specified from a task, and responds to the memory acquisition request with a size equal to or greater than the size specified by the task. Allocate a memory block having an available area adjusted with the cache line size of the CPU on which the CPU operates as a unit size.

【0010】また、タスクからサイズを指定したメモリ
解放要求を受け、前記メモリ解放要求に対し、タスクか
ら指定されたサイズを超えずかつオペレーティングシス
テムが動作するCPUのキャッシュラインサイズ単位で
調整したサイズの使用可能領域を持つメモリブロックを
解放する。
In addition, a memory release request specifying a size is received from a task, and the memory release request does not exceed the size specified by the task and has a size adjusted in cache line size units of a CPU on which an operating system operates. Release a memory block that has available space.

【0011】これ等の構成により、キャッシュラインア
クセスでメモリブロック境界部分にアクセスしても、隣
接するメモリブロックへの書き込みに対してキャッシュ
ミスが発生せず、ライトバックによるメモリ破壊の発生
を防止でき、簡単な構成でメモリ破壊を防止することが
できる。
With these configurations, even if a memory block boundary is accessed by a cache line access, a cache miss does not occur for writing to an adjacent memory block, and memory corruption due to write-back can be prevented. With a simple configuration, memory destruction can be prevented.

【0012】また、CPUのキャッシュラインサイズ単
位で調整したサイズが前記キャッシュラインサイズより
小さいサイズの場合には解放を行わないものとしてもよ
い。
If the size adjusted in cache line size units of the CPU is smaller than the cache line size, release may not be performed.

【0013】この構成によれば、メモリブロックが解放
されたときのメモリの断片化を防止し、メモリが虫食い
状態になるのを防ぐことができる。
According to this configuration, it is possible to prevent fragmentation of the memory when the memory block is released, and to prevent the memory from becoming wormy.

【0014】[0014]

【発明の実施の形態】次に、本発明の実施の形態につい
て図面を参照して詳細に説明する。以下、レーザプリン
タのコントローラのCPUで動作するオペレーティング
システムについて説明するが、本発明はキャッシュアク
セス方式が可能なメモリ空間にアクセスするもの全般に
適用できる。
Next, embodiments of the present invention will be described in detail with reference to the drawings. Hereinafter, an operating system that operates on the CPU of the controller of the laser printer will be described. However, the present invention can be applied to any system that accesses a memory space in which a cache access method can be used.

【0015】図1は本発明に係るオペレーティングシス
テムが動作するレーザプリンタのコントローラのハード
ウェア構成の一例を示す図である。レーザプリンタのコ
ントローラは、キャッシュメモリを有したCPU1と、
CPU1を動作させる命令コードを格納したROM2
と、CPU1の動作に必要なメインメモリ3と、フォン
ト等印刷に必要な情報を記憶する記憶装置4と、メイン
メモリを制御するメモリコントローラ5と、CPU1の
処理における一定時間での割り込みを制御するタイマコ
ントローラ6と、CPU1の処理における外部割り込み
要因とつながった割り込み処理を制御する割り込みコン
トローラ7と、これ等に接続されるバス8とを備えてい
る。
FIG. 1 is a diagram showing an example of a hardware configuration of a controller of a laser printer on which an operating system according to the present invention operates. A controller of the laser printer includes a CPU 1 having a cache memory;
ROM 2 storing instruction codes for operating CPU 1
And a main memory 3 necessary for the operation of the CPU 1, a storage device 4 for storing information necessary for printing such as fonts, a memory controller 5 for controlling the main memory, and controlling an interruption in a predetermined time in the processing of the CPU 1. It includes a timer controller 6, an interrupt controller 7 for controlling an interrupt process connected to an external interrupt factor in the processing of the CPU 1, and a bus 8 connected to these.

【0016】CPU1は、タイマコントローラ6による
一定時間での割り込み、外部割り込み要因とつながった
割り込みコントローラ7からの割り込みなどの様々な外
部要因に対し、適切な処理を行う。また、CPU1は、
キャッシュラインサイズが例えば32バイトのキャッシ
ュメモリを備えであり、従来の技術において説明したキ
ャッシュメモリのライトバック機能を有している。
The CPU 1 performs appropriate processing for various external factors such as an interrupt at a fixed time by the timer controller 6 and an interrupt from the interrupt controller 7 connected to the external interrupt factor. Also, the CPU 1
A cache memory having a cache line size of, for example, 32 bytes is provided, and has a cache memory write-back function described in the related art.

【0017】次に、本発明に係るオぺレーティングシス
テムの構成について説明する。
Next, the configuration of the operating system according to the present invention will be described.

【0018】図2は、本発明の一実施形態の構成を示す
ブロック図である。
FIG. 2 is a block diagram showing the configuration of one embodiment of the present invention.

【0019】オペレーティングシステム12は、オペレ
ーティングシステム内の処理時間を保証することを目的
としたリアルタイムオペレーティングシステムであり、
複数のタスク11と、それまでにタスクによって要求さ
れたサイズのメモリブロックに分割されているメインメ
モリ3と接続される。オペレーティングシステム12
は、メインメモリ3を管理し、タスク11はメインメモ
リ3中の必要なサイズの未使用領域を獲得する処理及び
それぞれに割り当てられたメインメモリ3中の使用領域
を解放する処理をオペレーティングシステム12を介し
て行う。また、オペレーティングシステム12は、複数
のタスク11の1つからメモリ獲得要求または解放要求
を受けると他のタスク11に対する処理を中断してメイ
ンメモリ3中の領域をメモリ獲得要求又は解放要求に対
し獲得する又は解放するメモリを割り当てるものとして
よい。
The operating system 12 is a real-time operating system for the purpose of guaranteeing processing time in the operating system.
A plurality of tasks 11 are connected to the main memory 3 divided into memory blocks of the size requested by the tasks. Operating system 12
Manages the main memory 3, and the task 11 executes the operation of acquiring the unused area of the required size in the main memory 3 and the processing of releasing the allocated area of the main memory 3 allocated to the operating system 12. Do through. When the operating system 12 receives a memory acquisition request or a release request from one of the tasks 11, the operating system 12 suspends the processing for the other tasks 11 and acquires an area in the main memory 3 in response to the memory acquisition request or the release request. The memory to be released or released may be allocated.

【0020】タスク11は、例えば、レーザプリンタの
コントローラにおいては、ホストI/Fモジュール、エ
ミュレータ、フォントマネージャモジュール及び印刷モ
ジュールである。ホストI/Fモジュールは、メモリに
受信したデータを格納する受信バッファ、送信するデー
タを格納する送信バッファをそれぞれ数メガバイト確保
することを要求し、エミュレータは、メモリに受け取っ
たデータを編集して格納するページデータを数百バイト
単位でデータ量に応じた個数のメモリブロックを確保す
ることを要求し、フォントマネージャモジュールは、印
刷するために必要な文字をCGROMから読み出して、
そのデータを一時的にメモリに保存するため文字キャッ
シュを文字のサイズに応じて数バイト〜文字のサイズに
応じた容量を確保することを要求し、印刷モジュール
は、メモリに印刷データを格納するフレームバッファを
数MB確保することを要求する。
The task 11 is, for example, a host I / F module, an emulator, a font manager module, and a printing module in a laser printer controller. The host I / F module requests that a reception buffer for storing received data in the memory and a transmission buffer for storing data to be transmitted be secured for each several megabytes, and the emulator edits and stores the received data in the memory. Requesting to secure a number of memory blocks corresponding to the amount of data in units of hundreds of bytes of page data to be printed, and the font manager module reads characters necessary for printing from the CGROM,
In order to temporarily store the data in the memory, a request is made for the character cache to have a capacity of several bytes to the size of the character according to the size of the character, and the printing module stores the print data in the memory. Request that a few MBs be reserved for the buffer.

【0021】オペレーティングシステム12は、タスク
によって獲得/解放されたメモリブロックを、キャッシ
ュラインサイズと同じサイズ、例えば32バイト単位で
調整するメモリアライメント制御部13を備える。ま
た、オペレーティングシステム12は、メモリアライメ
ント制御部13でCPU1のキャッシュラインサイズ単
位、例えば32バイト単位に調整されたメモリブロック
の獲得/解放処理を行うメモリ制御部14を備える。ま
た、メモリ制御部14は、空きメモリ及び使用メモリを
一括して管理するためのメモリ管理テーブル15を備え
ている。
The operating system 12 includes a memory alignment control unit 13 for adjusting a memory block acquired / released by a task in the same size as the cache line size, for example, in units of 32 bytes. The operating system 12 also includes a memory control unit 14 that performs acquisition / release processing of a memory block adjusted by the memory alignment control unit 13 in units of a cache line size of the CPU 1, for example, in units of 32 bytes. Further, the memory control unit 14 includes a memory management table 15 for collectively managing a free memory and a used memory.

【0022】具体的には、メモリ獲得の場合は、指定さ
れたサイズ以上で、例えば、32バイト単位で調整して
そのサイズでメモリを獲得する。調整後のサイズは、 調整後のサイズ = ((指定されたサイズ+(32−
1))/32)*32 となる。また、メモリを解放する場合は、メモリアライ
メント制御部13は、タスク14によって指定された解
放サイズを越えないサイズで32バイト単位で調整した
サイズのメモリを解放する。調整後のサイズは、 調整後のサイズ = (指定されたサイズ/32バイ
ト)*32バイト とする。
More specifically, in the case of acquiring a memory, the memory is acquired in a size larger than a specified size, for example, adjusted in units of 32 bytes. The size after adjustment is the size after adjustment = ((specified size + (32-
1)) / 32) * 32. When releasing the memory, the memory alignment control unit 13 releases a memory having a size not exceeding the release size specified by the task 14 and adjusted in 32-byte units. The size after adjustment is as follows: Size after adjustment = (specified size / 32 bytes) * 32 bytes.

【0023】また、獲得したメモリブロックを全て(部
分的にでない)解放する場合は、獲得されたときに32
バイト単位で調整されているので、特に調整する必要は
ないことになる。
When all (not partially) the acquired memory blocks are released, 32
Since it is adjusted on a byte-by-byte basis, no special adjustment is required.

【0024】メインメモリ3は、未使用メモリブロック
16及び使用メモリブロック17に分割されている。未
使用メモリブロック16は、それまでにタスクによって
要求されたサイズの現在使用されていないメモリブロッ
クかまたはこれまで全く使用されていないメモリブロッ
クであり、使用メモリブロック17は、現在、タスク1
1のいずれかの要求により獲得されているメモリブロッ
クである。なお、メインメモリ3が使用される前は、1
つの大きな未使用メモリブロック16である。
The main memory 3 is divided into unused memory blocks 16 and used memory blocks 17. The unused memory block 16 is a currently unused memory block of the size requested by the task or a memory block that has never been used, and the used memory block 17 is
1 is a memory block acquired by one of the requests. Before the main memory 3 is used, 1
Three large unused memory blocks 16.

【0025】図3は、図2の使用メモリブロック及び未
使用メモリブロックの具体的なメモリ構成を示す図であ
る。各メモリブロックはメモリブロックに関する情報を
記録しているメモリブロック管理テーブル21とタスク
使用可能領域22とからなっている。本発明に係るメモ
リブロックにおいては、メモリブロック管理テーブル2
1及びタスク使用可能領域22はそれぞれCPU1のキ
ャッシュラインサイズ単位、例えば32バイト単位に調
整されたサイズを持っている。
FIG. 3 is a diagram showing a specific memory configuration of the used memory block and the unused memory block of FIG. Each memory block includes a memory block management table 21 that records information on the memory block, and a task available area 22. In the memory block according to the present invention, the memory block management table 2
1 and the task usable area 22 each have a size adjusted to the cache line size unit of the CPU 1, for example, 32 bytes.

【0026】メモリブロック管理テーブル21には、次
ブロックアドレス23、前ブロックアドレス24、先頭
アドレス25、終了アドレス26、ブロック使用状況フ
ラグ27、メモリブロック情報28,29,30を備え
ている。次ブロックアドレス23は、次の同種類のメモ
リブロック、すなわち、未使用メモリブロックであれ
ば、そのメモリブロックの次にアドレスの数値が小さい
未使用ブロックの先頭アドレスを記録し、使用メモリブ
ロックであれば、そのメモリブロックの次にアドレスの
数値が小さい使用メモリブロックの先頭アドレスを記録
する。前ブロックアドレス24は、そのメモリブロック
の次にアドレスの数値が大きい同種類のメモリブロック
の先頭アドレスを記録する。先頭アドレス25は、その
メモリブロックのタスク使用可能領域の先頭アドレスを
記録し、終了アドレスはそのメモリブロックの終了アド
レスを記録する。ブロック使用状況フラグ27は、例え
ば、未使用メモリにおいては、空きメモリブロックであ
ることを示す情報、例えば“F”、使用中メモリにおい
ては、使用中のメモリブロックであることを示す“U”
のデータを記録する。また、メモリブロック情報27,
28,29は、そのメモリブロックに関する他の情報、
例えば、タスクから獲得しているメモリブロックの全解
放を示す要求があったときに、解放を行うか、または獲
得のままにするかを指定する情報などを記録する。例え
ば、メモリブロック管理テーブルを構成している次ブロ
ックアドレス23、前ブロックアドレス24、先頭アド
レス25、最終アドレス26、ブロック使用状況フラグ
27、及びメモリブロック情報28、29、30からな
る8個のデータのサイズをそれぞれ4バイトとしてもよ
い。
The memory block management table 21 has a next block address 23, a previous block address 24, a start address 25, an end address 26, a block use status flag 27, and memory block information 28, 29, 30. If the next block address 23 is the next memory block of the same type, that is, an unused memory block, the head address of an unused block having the next smaller address value after that memory block is recorded. For example, the head address of a used memory block having a smaller address value after the memory block is recorded. The previous block address 24 records the head address of the same type of memory block having the next largest numerical value of the address after that memory block. The start address 25 records the start address of the task usable area of the memory block, and the end address records the end address of the memory block. The block use status flag 27 is, for example, information indicating an empty memory block in an unused memory, for example, “F”, and “U” indicating an in-use memory block in an in-use memory.
Record the data. Also, the memory block information 27,
28, 29 are other information about the memory block,
For example, when there is a request from the task indicating that all of the acquired memory blocks have been released, information for specifying whether to release the memory blocks or to keep the acquisition is recorded. For example, eight data comprising the next block address 23, the previous block address 24, the start address 25, the last address 26, the block use status flag 27, and the memory block information 28, 29, 30 constituting the memory block management table May be 4 bytes each.

【0027】図4は、図2のメモリ管理テーブル15と
メインメモリ3との関係を示す図である。メインメモリ
3は図2に示すように順に並ぶメモリブロック31〜3
6を有している。メモリブロック31,34,35は未
使用メモリブロック16であり、それぞれ、ブロック使
用状況フラグ37,38,39には、未使用を示す情報
である“F”が記録されている。また、メモリブロック
32,33,36は使用メモリブロック17であり、そ
れぞれ、ブロック使用状況フラグ40,41,42に
は、使用中であることを示す情報である“U”が記録さ
れている。
FIG. 4 is a diagram showing the relationship between the memory management table 15 of FIG. The main memory 3 includes memory blocks 31 to 3 arranged in order as shown in FIG.
6. The memory blocks 31, 34, and 35 are unused memory blocks 16, and "F" that is information indicating unused is recorded in the block use status flags 37, 38, and 39, respectively. The memory blocks 32, 33, and 36 are used memory blocks 17, and the block use status flags 40, 41, and 42 record “U”, which is information indicating that they are in use.

【0028】各メモリブロックは、境界部分においてメ
モリとして使用されないバッファ領域を有しておらず、
隣接している。
Each memory block does not have a buffer area that is not used as a memory at a boundary portion,
Adjacent.

【0029】また、メモリブロック31の次ブロックア
ドレス43は、メモリブロック31のブロック使用状況
フラグ37と同じく、未使用を示す“F”が記録されて
いるメモリブロックのうち、メモリブロック31の次に
小さい先頭アドレスを持つメモリブロック34の先頭の
アドレスが記録されている。
The next block address 43 of the memory block 31 is, like the block use status flag 37 of the memory block 31, the next block address of the memory block 31 in which "F" indicating unused is recorded. The head address of the memory block 34 having a small head address is recorded.

【0030】また、メモリブロック33の前ブロックア
ドレス44は、メモリブロック33のブロック使用状況
フラグ41と同じく、使用中であることを示す“U”が
記録されているメモリブロックのうち、メモリブロック
33の次に大きい先頭アドレスを持つメモリブロック3
2の先頭のアドレスが記録されている。
The previous block address 44 of the memory block 33 is the same as the block use status flag 41 of the memory block 33, and among the memory blocks in which “U” indicating that the memory block 33 is being used is recorded, Block 3 having the next highest start address
2 is recorded at the beginning address.

【0031】未使用メモリブロック16、使用メモリブ
ロック17の各先頭のメモリブロック31、32の前ブ
ロックアドレス45、46及び各最終のメモリブロック
35、36の次ブロックアドレス47、48は、NUL
Lとなっている。
The previous block addresses 45 and 46 of the head memory blocks 31 and 32 of the unused memory block 16 and the used memory block 17 and the next block addresses 47 and 48 of the last memory blocks 35 and 36 are NULL.
L.

【0032】メモリ管理テーブル15には、図4に示す
ように、未使用メモリブロック16のうちの先頭の、す
なわちアドレスの小さいメモリブロック31の先頭アド
レスを指し示している空きメモリ先頭ブロック51と、
最終の、すなわちアドレスの大きいメモリブロック35
の先頭アドレスを指し示している空きメモリ最終ブロッ
ク52と、使用メモリブロック17のうちの先頭のメモ
リブロック32の先頭アドレスを指し示している使用メ
モリ先頭ブロック53と、最終のメモリブロック36の
先頭アドレスを指し示している使用メモリ最終ブロック
54とを記録している。また、メモリ管理テーブル15
は、キャッシュラインサイズに丸められたサイズになっ
ている。
As shown in FIG. 4, the memory management table 15 includes an empty memory head block 51 indicating the head of the unused memory block 16, that is, the head address of the memory block 31 having a smaller address.
The final, that is, the higher address memory block 35
, A free memory last block 52 indicating the start address of the first memory block 32 of the used memory blocks 17, and a start address of the last memory block 36. Used memory last block 54 is recorded. Also, the memory management table 15
Is the size rounded to the cache line size.

【0033】次に、図2のオペレーティングシステムの
メモリ管理の動作について説明する。
Next, the operation of the memory management of the operating system shown in FIG. 2 will be described.

【0034】図5は、図2のオペレーティングシステム
のメモリ管理の動作を示すフローチャートである。タス
クからのメモリ獲得または解放要求が発生すると(ステ
ップS1)、オペレーティングシステムはメモリ獲得要
求であるか判断し(ステップS2)、メモリ獲得要求で
あれば、メモリアライメント制御部13がCPU1のキ
ャッシュラインサイズに基づいて獲得するメモリサイズ
を調整する(ステップS3)。このとき、CPU1のキ
ャッシュラインサイズ単位、例えば、32バイト単位で
あって指定されたサイズ以上のサイズに調整する。すな
わち、調整後のサイズは、 調整後のサイズ = ((指定されたサイズ+(32−
1))/32)*32 となる。メモリ管理テーブル15の空きメモリ先頭ブロ
ック42からメモリブロックをたどって調整後のサイズ
を満たす使用領域サイズを持つ空きメモリブロックを検
出する(ステップS4)。このとき、メモリブロックの
サイズは、各メモリブロックのメモリブロック管理テー
ブルに記録されている最終アドレスと先頭アドレスの差
を求めて検出する。このサイズは常にキャッシュライン
サイズに丸められたサイズになっている。サイズの要件
が満たされていない場合は、次のブロック31を順次た
どり、メモリブロックのサイズを算出して、サイズの要
件を満たすメモリブロックが検出できるまで検索する。
メモリ制御部14は、検出された未使用メモリブロック
の全体、または、必要なサイズ分だけ分割したブロック
を、そのメモリブロックのアドレス範囲の先頭から、調
整後のサイズの使用領域サイズを持つ、使用メモリブロ
ックとしてメモリ管理テーブル15に登録する(ステッ
プS5)。また、このとき、検出された未使用メモリブ
ロックの領域情報を、それ以外の領域を示す領域情報に
変更する。
FIG. 5 is a flowchart showing the memory management operation of the operating system of FIG. When a memory acquisition or release request from a task occurs (step S1), the operating system determines whether the request is a memory acquisition request (step S2). The size of the memory to be obtained is adjusted based on (step S3). At this time, the size is adjusted to a cache line size unit of the CPU 1, for example, a unit of 32 bytes, which is equal to or larger than the specified size. That is, the size after adjustment is the size after adjustment = ((specified size + (32-
1)) / 32) * 32. The memory block is traced from the free memory head block 42 of the memory management table 15 to detect a free memory block having a used area size that satisfies the adjusted size (step S4). At this time, the size of the memory block is detected by calculating the difference between the last address and the start address recorded in the memory block management table of each memory block. This size is always rounded to the cache line size. If the size requirement is not satisfied, the next block 31 is sequentially traced, the size of the memory block is calculated, and the search is performed until a memory block satisfying the size requirement can be detected.
The memory control unit 14 divides the entire detected unused memory block or a block obtained by dividing it by a necessary size from the head of the address range of the memory block to the used area size of the adjusted size. It is registered in the memory management table 15 as a memory block (step S5). At this time, the area information of the detected unused memory block is changed to area information indicating the other area.

【0035】また、ステップS2において、メモリ獲得
でない場合、メモリ解放と判断し、次に指定のメモリブ
ロックにおいて部分的にメモリを解放するか判断する
(ステップS6)。獲得したメモリブロックを全て(部
分的にでない)解放する場合は、獲得されたときに32
バイト単位で調整されているので、特に調整する必要は
ないことになる。全体を解放する場合には、タスクが解
放を要求しているメモリブロックを未使用ブロックとし
てメモリ管理テーブル15に登録する(ステップS
7)。ステップS6において、部分的にメモリを解放す
る場合、解放するサイズを調整する(ステップS8)。
調整後のサイズは、 調整後のサイズ = (指定されたサイズ/32バイ
ト)*32バイト とする。次に、調整後のサイズが、キャッシュラインサ
イズより小さいか判断し(ステップS9)、小さい場合
には、メモリの解放は行わないで処理を終了する。調整
後のサイズが、キャッシュラインサイズより大きけれ
ば、メモリ制御部14はタスクが解放を要求しているメ
モリブロックを分割して、そのメモリブロックの領域の
うちタスク使用可能領域のサイズが調整後のサイズとな
るメモリブロックを未使用メモリブロックとしてメモリ
管理テーブル15に登録する(ステップS10)。な
お、このとき、メモリ管理テーブル15において、タス
クが解放を要求したメモリブロック使用のメモリブロッ
クの領域情報を変更する。
If it is determined in step S2 that the memory is not acquired, it is determined that the memory is to be released, and then it is determined whether to partially release the memory in the specified memory block (step S6). To release all (not partially) the acquired memory block, 32
Since it is adjusted on a byte-by-byte basis, no special adjustment is required. When releasing the whole, the memory block whose release is requested by the task is registered as an unused block in the memory management table 15 (step S).
7). If the memory is partially released in step S6, the size to be released is adjusted (step S8).
The size after adjustment is as follows: Size after adjustment = (specified size / 32 bytes) * 32 bytes. Next, it is determined whether the size after the adjustment is smaller than the cache line size (step S9). If the size is smaller, the process is terminated without releasing the memory. If the size after the adjustment is larger than the cache line size, the memory control unit 14 divides the memory block requested by the task to be released and sets the size of the task usable area in the memory block area after the adjustment. The memory block having the size is registered as an unused memory block in the memory management table 15 (step S10). At this time, in the memory management table 15, the area information of the memory block using the memory block requested to be released by the task is changed.

【0036】以上説明したように本発明のメモリ管理方
法によれば、CPUからのキャッシュアクセスと同じ単
位でメモリへのアクセスサイズを管理することが可能に
なり、オペレーティングシステムに複雑な対応を入れ込
む必要が無く、また、タスク側においてメモリに格納さ
れる内容の破壊防止のための特別な対応を全く行うこと
なく、メモリ破壊を防止することができる。
As described above, according to the memory management method of the present invention, it is possible to manage the access size to the memory in the same unit as the cache access from the CPU, and incorporate a complicated correspondence into the operating system. There is no necessity, and memory destruction can be prevented without any special measures for preventing destruction of the contents stored in the memory on the task side.

【0037】なお、メモリアライメント制御部13で調
整されるメモリサイズはCPUのキャッシュラインサイ
ズが32バイトの場合には、32の倍数のうちのどれか
を指定する。これによって隣接するメモリブロックが異
なったメモリアクセス方式によってもメモリ内容を破壊
しない、システムに最も最適なサイズを設定できる。十
分なメモリが備わっている場合、256バイト単位な
ど、調整単位を大きくすればするほどメモリが管理し安
くなり、高速化がはかれる。
When the cache line size of the CPU is 32 bytes, the memory size adjusted by the memory alignment control unit 13 is specified to be any multiple of 32. As a result, it is possible to set the most optimal size for the system so that adjacent memory blocks do not destroy the memory contents even by different memory access methods. If sufficient memory is provided, the larger the adjustment unit, such as the unit of 256 bytes, the lower the management and cost of the memory, and the higher the speed.

【0038】[0038]

【発明の効果】以上説明したように本発明のオペレーテ
ィングシステムのメモリ管理方法によれば、オペレーテ
ィングシステムによって動的に獲得/解放されるメモリ
ブロックが、オペレーティングシステムを動作させるC
PU1のキャッシュラインサイズ単位、例えば32バイ
ト単位で管理することにより、キャッシュラインアクセ
スでメモリブロック境界部分にアクセスしても、隣接す
るメモリブロックへの書き込みに対してキャッシュミス
が発生せず、ライトバックによるメモリ破壊の発生を防
止できる。また、メモリ破壊の防止のためにキャッシュ
アクセスを行う2つのメモリブロックの境界部分にメモ
リとして使用できないバッファ領域をもうける必要がな
く、2つのメモリブロックを隣接させることができメモ
リ効率が良い。また、キャッシュアクセスの際にメモリ
ブロックの境界をまたぐことによるメモリ破壊の防止の
ためのチェックを行う処理が不要であり、処理が簡単で
高速にメモリ管理を行うことができる。
As described above, according to the memory management method of the operating system of the present invention, the memory block dynamically acquired / released by the operating system is used for operating the operating system.
By managing the PU1 in units of cache line size, for example, in units of 32 bytes, even if a memory block boundary is accessed by cache line access, a cache miss does not occur for writing to an adjacent memory block, and write back is performed. Can prevent the occurrence of memory destruction. Also, in order to prevent memory destruction, it is not necessary to provide a buffer area that cannot be used as a memory at the boundary between two memory blocks for performing cache access, and the two memory blocks can be adjacent to each other, thus improving the memory efficiency. Further, at the time of cache access, there is no need to perform a process of performing a check for preventing memory destruction due to straddling a memory block boundary, so that the process is simple and memory management can be performed at high speed.

【0039】さらに、解放サイズがキャッシュラインサ
イズより小さいサイズの場合には解放を行わないことに
より、タスクによって数バイト単位の細かいサイズでメ
モリブロックが獲得/解放されることを防ぎ、メモリが
虫食い状態になることを防ぐことができる。
Furthermore, when the release size is smaller than the cache line size, the release is not performed, thereby preventing a task from acquiring / releasing a memory block in a small size of several bytes, thereby preventing the memory from being wormy. Can be prevented.

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

【図1】本発明に係るオペレーティングシステムが動作
するレーザプリンタのコントローラのハードウェア構成
の一例を示す図である。
FIG. 1 is a diagram illustrating an example of a hardware configuration of a controller of a laser printer on which an operating system according to the present invention operates.

【図2】本発明の一実施形態の構成を示すブロック図で
ある。
FIG. 2 is a block diagram showing a configuration of one embodiment of the present invention.

【図3】図2の使用メモリブロック及び未使用メモリブ
ロックの具体的なメモリ構成を示す図である。
FIG. 3 is a diagram showing a specific memory configuration of a used memory block and an unused memory block of FIG. 2;

【図4】図2のメモリ管理テーブル15とメインメモリ
3との関係を示す図である。
FIG. 4 is a diagram showing a relationship between a memory management table 15 of FIG.

【図5】図2のオペレーティングシステムのメモリ獲得
及び解放の動作を示すフローチャートである。
FIG. 5 is a flowchart showing an operation of acquiring and releasing memory of the operating system of FIG. 2;

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

1 CPU 2 ROM 3 メインメモリ 4 記憶装置 5 メモリコントローラ 6 タイマコントローラ 7 割り込みコントローラ 8 バス 11 タスク 12 オペレーティングシステム 13 メモリアライメント制御部 14 メモリ制御部 15 メモリ管理テーブル 16 未使用ブロックメモリ 17 使用ブロックメモリ 21 メモリブロック管理テーブル 22 タスク使用可能領域 23,43,47,48 次ブロックアドレス 24,44,45,46 前ブロックアドレス 25 先頭アドレス 26 終了アドレス 27,37,38,39,40,41,42 ブロック
使用状況フラグ 28,29,30 メモリブロック情報 31,32,33,34,35,36 メモリブロック 51 空きメモリ先頭ブロック 52 空きメモリ最終ブロック 53 使用メモリ先頭ブロック 54 使用メモリ最終ブロック
DESCRIPTION OF SYMBOLS 1 CPU 2 ROM 3 Main memory 4 Storage device 5 Memory controller 6 Timer controller 7 Interrupt controller 8 Bus 11 Task 12 Operating system 13 Memory alignment control unit 14 Memory control unit 15 Memory management table 16 Unused block memory 17 Used block memory 21 Memory Block management table 22 Task available area 23, 43, 47, 48 Next block address 24, 44, 45, 46 Previous block address 25 Start address 26 End address 27, 37, 38, 39, 40, 41, 42 Block usage status Flags 28, 29, 30 Memory block information 31, 32, 33, 34, 35, 36 Memory block 51 Free memory first block 52 Free memory last block 53 Usage memo Top block 54 use memory the last block

Claims (6)

【特許請求の範囲】[Claims] 【請求項1】 タスクからサイズを指定したメモリ獲得
要求を受け、前記メモリ獲得要求に対し、タスクから指
定されたサイズ以上でかつオペレーティングシステムが
動作するCPUのキャッシュラインサイズを単位サイズ
として調整した使用可能領域を持つメモリブロックを割
り当てることを特徴とするオペレーティングシステムの
メモリ管理方法。
1. A method in which a memory acquisition request whose size is designated by a task is received, and the memory acquisition request is used in which a cache line size of a CPU which is equal to or more than the size designated by the task and which runs an operating system is adjusted as a unit size. A memory management method for an operating system, wherein a memory block having a possible area is allocated.
【請求項2】 タスクからサイズを指定したメモリ解放
要求を受け、前記メモリ解放要求に対し、タスクから指
定されたサイズを超えずかつオペレーティングシステム
が動作するCPUのキャッシュラインサイズ単位で調整
したサイズの使用可能領域を持つメモリブロックを解放
することを特徴とするオペレーティングシステムのメモ
リ管理方法。
2. A memory release request having a size specified by a task is received. In response to the memory release request, a size smaller than the size specified by the task and adjusted by a cache line size unit of a CPU on which an operating system operates. A memory management method for an operating system, wherein a memory block having an available area is released.
【請求項3】 CPUのキャッシュラインサイズ単位で
調整したサイズが前記キャッシュラインサイズより小さ
いサイズの場合には解放を行わないことを特徴とする請
求項2に記載のオペレーティングシステムのメモリ管理
方法。
3. The memory management method for an operating system according to claim 2, wherein the release is not performed when the size adjusted in cache line size units of the CPU is smaller than the cache line size.
【請求項4】 前記タスクから指定されたサイズ以上で
かつオペレーティングシステムが動作するCPUのキャ
ッシュラインサイズを単位サイズとして調整した使用可
能領域を持つメモリブロックをメモリ中から検索するこ
とを特徴とする請求項1ないし3のいずれかに記載のオ
ペレーティングシステムのメモリ管理方法。
4. A memory block having a usable area which is equal to or larger than a size designated by the task and has an available area obtained by adjusting a cache line size of a CPU on which an operating system operates as a unit size is searched from the memory. Item 4. The memory management method for an operating system according to any one of Items 1 to 3.
【請求項5】 前記複数のメモリブロックにそれぞれ使
用状況を示すフラグと、次ブロックアドレスと、使用可
能領域のサイズを示す情報とを記録し、使用中メモリブ
ロックの先頭のメモリブロックのアドレス情報及び未使
用のメモリブロックの先頭のもののアドレス情報を保持
し、前記使用中メモリブロックの先頭または未使用のメ
モリブロックの先頭のものから、順次、使用中メモリブ
ロックまたは未使用のメモリブロックの使用状況を検出
し、前記タスクから指定されたサイズ以上でかつオペレ
ーティングシステムが動作するCPUのキャッシュライ
ンサイズを単位サイズとして調整した使用可能領域を持
つメモリブロックをメモリ中から検索するすることを特
徴とする請求項4に記載のオペレーティングシステムの
メモリ管理方法。
5. A flag indicating a use status, a next block address, and information indicating a size of an available area are recorded in each of the plurality of memory blocks, and address information of a head memory block of the used memory block is recorded. Holds the address information of the head of the unused memory block, and sequentially uses the usage status of the used memory block or the unused memory block from the head of the used memory block or the head of the unused memory block. Detecting a memory block having a usable area which is detected and adjusted as a unit size of a cache line size of a CPU on which an operating system operates and which is equal to or larger than a size specified by the task, from the memory; 5. The memory management method for an operating system according to claim 4.
【請求項6】 前記複数のメモリブロックの前記使用可
能領域以外のサイズがオペレーティングシステムが動作
するCPUのキャッシュラインサイズを単位サイズとし
たサイズであることを特徴とする請求項1ないし5のい
ずれかに記載のオペレーティングシステムのメモリ管理
方法。
6. The memory system according to claim 1, wherein the size of the plurality of memory blocks other than the usable area is a size in which a cache line size of a CPU on which an operating system operates is used as a unit size. The memory management method for an operating system according to claim 1.
JP33743099A 1999-11-29 1999-11-29 Memory managing method for operating system Pending JP2001154860A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP33743099A JP2001154860A (en) 1999-11-29 1999-11-29 Memory managing method for operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP33743099A JP2001154860A (en) 1999-11-29 1999-11-29 Memory managing method for operating system

Publications (1)

Publication Number Publication Date
JP2001154860A true JP2001154860A (en) 2001-06-08

Family

ID=18308566

Family Applications (1)

Application Number Title Priority Date Filing Date
JP33743099A Pending JP2001154860A (en) 1999-11-29 1999-11-29 Memory managing method for operating system

Country Status (1)

Country Link
JP (1) JP2001154860A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7472331B2 (en) 2004-07-16 2008-12-30 Samsung Electronics Co., Ltd. Memory systems including defective block management and related methods
JP2011243196A (en) * 2010-05-14 2011-12-01 Samsung Electronics Co Ltd Memory management device and method considering user response time

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7472331B2 (en) 2004-07-16 2008-12-30 Samsung Electronics Co., Ltd. Memory systems including defective block management and related methods
JP2011243196A (en) * 2010-05-14 2011-12-01 Samsung Electronics Co Ltd Memory management device and method considering user response time
US9223689B2 (en) 2010-05-14 2015-12-29 Samsung Electronics Co., Ltd. Apparatus and method for managing memory

Similar Documents

Publication Publication Date Title
US6401181B1 (en) Dynamic allocation of physical memory space
EP0777183B1 (en) Computer cache system
GB2265734A (en) Free memory cell management system
JPH07175698A (en) File system
JPS6219947A (en) Initialization time reducing apparatus for peripheral memorysubsystem
US5581726A (en) Control system for controlling cache storage unit by using a non-volatile memory
DE102020117350A1 (en) STORAGE SYSTEM INCLUDING HETEROGENIC STORAGE, COMPUTER SYSTEM WITH THE STORAGE SYSTEM AND DATA MANAGEMENT PROCESSES FOR IT
KR100419682B1 (en) Access control device and access method
JP2001154860A (en) Memory managing method for operating system
JP2003256269A (en) Method of controlling nonvolatile storage device and memory device
EP4033346B1 (en) Affinity-based cache operation for a persistent storage device
US20060143313A1 (en) Method for accessing a storage device
JP3745909B2 (en) File management method
JPH1091527A (en) Storage device and recording medium
JPH0329041A (en) Decentralized paging control system
JPH0363741A (en) disk cache device
JP3542894B2 (en) File system
JP2964504B2 (en) Document processing device
JP3660173B2 (en) Free buffer management method
JPS62108346A (en) Inter-process communication system
JP2583403B2 (en) Backing store management method
JPH08263426A (en) Logical direct memory access system
JPH1055308A (en) Cache memory
JPH0521256B2 (en)
JPH06131264A (en) Cache memory control method

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20040629

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20040830

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20050301