JPH076045A - Memory managing method of multi-processing system - Google Patents

Memory managing method of multi-processing system

Info

Publication number
JPH076045A
JPH076045A JP14334093A JP14334093A JPH076045A JP H076045 A JPH076045 A JP H076045A JP 14334093 A JP14334093 A JP 14334093A JP 14334093 A JP14334093 A JP 14334093A JP H076045 A JPH076045 A JP H076045A
Authority
JP
Japan
Prior art keywords
stack
task
memory
data
arrow
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
JP14334093A
Other languages
Japanese (ja)
Inventor
Minoru Kubota
稔 久保田
Katsumi Maruyama
勝己 丸山
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.)
Nippon Telegraph and Telephone Corp
Original Assignee
Nippon Telegraph and Telephone 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 Nippon Telegraph and Telephone Corp filed Critical Nippon Telegraph and Telephone Corp
Priority to JP14334093A priority Critical patent/JPH076045A/en
Publication of JPH076045A publication Critical patent/JPH076045A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To improve the memory use efficiency of the real-time multi-processing system which uses tasks. CONSTITUTION:When a task in a state (a) enters a stable state (long-period process interruption), effective data are saved (arrow 43) in an effective data area 42 assigned (arrow 41) separately from a stack, which is released (arrow 44), so that memory enters a state (b). When the task is restarted in the stable state (b), a stack is re-allocated (arrow 45) and then the effective data are reloaded (arrow 46) onto the stack from the effective data area 42. The effective data area which becomes unnecessary is released (arrow 47) or still allocated for next-time stand-by operation. In the latter case, the effective data area is released when the stack is deleted. Whether the effective data are saved or not and the address of the effective data area are recorded in areas 48 and 32 of a task control block.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明は、多重処理システム(マ
ルチタスクシステム)におけるメモリ管理方法に関し、
特に多重処理システム全体に必要なメモリ量を削減する
ことができるメモリ管理方法に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a memory management method in a multi-processing system (multi-task system),
In particular, the present invention relates to a memory management method that can reduce the amount of memory required for the entire multiprocessing system.

【0002】[0002]

【従来の技術】情報処理分野において、複数の処理を実
質的に同時並列的に行うことによって大容量のデータを
高速に処理するようにした多重処理システムは従来から
よく知られている。このような多重処理システムにおい
ては、全ての処理プログラムを1以上の処理単位に分割
して同時並列的処理の制御を行うのが普通である。その
場合の処理単位を“タスク”と呼んでいる。したがっ
て、多重処理システムにおいては複数のタスクは論理上
同時実行される。
2. Description of the Related Art In the field of information processing, a multi-processing system has been well known in the prior art, which is capable of processing a large amount of data at high speed by performing a plurality of processes substantially in parallel. In such a multi-processing system, it is usual to divide all processing programs into one or more processing units to control simultaneous parallel processing. The processing unit in that case is called a "task". Therefore, in a multiprocessing system, a plurality of tasks are logically executed simultaneously.

【0003】一般にタスクの処理は、図8に示すよう
な、状態遷移モデルに沿って進行する。タスクの状態
は、作動可能状態(ready state)、活動状態(active
state)および待ち状態(wait state)の3つの状態
をとり、ジョブを構成するタスクは、通常この3つの状
態を繰り返しながら実行される。図8において、その状
態遷移1〜6を簡単に説明する。1はジョブステップが
タスクとしてアタッチ(attach)され、タスク制御ブロ
ックTCBが作動可能待ち行列に入れられる遷移であ
る。2は該当作動タスクが他の作動可能タスクのどれよ
りも高い優先順位を持っているとCPUの制御権が渡さ
れ、そのタスクが実行され活動状態(active state)に
なる遷移である。3は何らかの事象(例えば、入出力)
が完了するのを待つために、タスクが待ち状態(wait s
tate)になる遷移である。4は待っている事象が完了し
た場合にそのタスクが作動可能状態(ready state)に
移る遷移である。5は活動中のタスクよりも優先順位の
高いタスクが作動可能になることによって、そのタスク
はCPU制御権を譲り渡し、再び作動可能状態に戻され
る遷移である。6はタスクの実行が完了した場合の遷移
で、この場合、TCBは作動可能待ち行列から削除さ
れ、そのタスクが使用していた各種資源は解放され、シ
ステムで利用することができるようになる。(江村潤著
「オペレーティングシステムへの構造的アプローチ
(下)」(昭和57年7月10日 日本コンピュータ協
会発行) P.653-654 参照)
Generally, task processing proceeds according to a state transition model as shown in FIG. The task states are ready state and active state.
A task that constitutes a job has three states, a state and a wait state, and is usually executed while repeating these three states. In FIG. 8, the state transitions 1 to 6 will be briefly described. 1 is a transition in which the job step is attached as a task and the task control block TCB is placed in the ready queue. 2 is a transition in which the control right of the CPU is passed when the corresponding active task has a higher priority than any of the other operable tasks, and the task is executed and becomes active. 3 is some event (for example, input / output)
Task is in a wait state (wait s
tate). 4 is a transition in which the task moves to the ready state when the waiting event is completed. Reference numeral 5 is a transition in which a task having a higher priority than an active task becomes operable, so that the task yields the CPU control right and is returned to the operable state again. 6 is a transition when the execution of the task is completed, in which case the TCB is deleted from the ready queue and the various resources used by the task are released and can be used by the system. (See Jun Emura, "Structural Approach to Operating Systems (2)" (published on July 10, 1982 by the Japan Computer Association) P.653-654)

【0004】次に、図9を用いてタスクについてさらに
詳細に説明する。図9において、11はタスク、12は
タスクに割り付けられたプログラムの実行状態を記憶す
るタスク制御ブロックTCB、13はプログラムが使用
するラストインファーストアウト(LIFO)で管理さ
れる作業用メモリ領域であるスタックである。同図に示
されているように、タスク11は、タスク制御ブロック
12とスタック13の2つから構成されている。スタッ
ク13は、アドレスの一定方向(低位アドレスから高位
アドレスへ、あるいは高位アドレスから低位アドレス
へ)に伸縮しながら使われる。プッシュ(push)操
作14はスタックに有効なデータを追加、ポップ(po
p)操作15はスタック13からデータを取り出す操作
であり、スタック上の有効なデータ16は連続メモリ領
域にある。スタックがどこまで使われているか、すなわ
ちどこまで有効データが格納されているかは、スタック
ポインタSPによって示される(矢印17)。タスク制
御ブロック12はスタック13の先頭アドレスを格納す
るための領域18とスタックポインタを格納するための
領域19を有している。タスク11はプログラム実行時
に生成され、プログラム終了時に削除される。タスク生
成時にタスク制御ブロックとスタックが割り付けられ、
タスク削除時にこれらが解放される。
Next, the task will be described in more detail with reference to FIG. In FIG. 9, 11 is a task, 12 is a task control block TCB that stores the execution state of the program assigned to the task, and 13 is a work memory area managed by the last-in first-out (LIFO) used by the program. It is a stack. As shown in the figure, the task 11 is composed of two tasks, a task control block 12 and a stack 13. The stack 13 is used while expanding or contracting in a certain direction of an address (from a low-order address to a high-order address or from a high-order address to a low-order address). A push operation 14 adds valid data to the stack and pops (po
p) Operation 15 is an operation for fetching data from the stack 13, and valid data 16 on the stack is in the continuous memory area. The stack pointer SP indicates how much the stack is used, that is, how much valid data is stored (arrow 17). The task control block 12 has an area 18 for storing the top address of the stack 13 and an area 19 for storing the stack pointer. The task 11 is created when the program is executed and deleted when the program ends. The task control block and stack are allocated when the task is created,
These are released when the task is deleted.

【0005】汎用情報処理システムにおいて、必要なメ
インメモリ容量を削減する方式として仮想記憶方式があ
るが、これはメインメモリ上のデータを一時的にディス
ク等の外部記憶装置に待避させる方式であり、メモリデ
ータの待避・回復の入出力処理を必要とするため処理に
遅延が生じ、高速処理を要する実時間処理システムには
適していない。また、仮想記憶方式は外部記憶装置を必
要とするため、実時間システムに多い組み込みシステム
には適用できない。さらにメインメモリ上のデータの待
避はメモリ容量が不足した時点で行われるが、一般にメ
モリ容量の不足は負荷の大きい場合におこる可能性が高
く、高負荷時にメモリの待避処理を行うと、実時間処理
要求を満たさなくなるおそれがある。
In a general-purpose information processing system, there is a virtual storage system as a system for reducing the required main memory capacity. This is a system for temporarily saving the data in the main memory to an external storage device such as a disk. Since input / output processing for saving / restoring memory data is required, the processing is delayed, which is not suitable for a real-time processing system that requires high-speed processing. Further, the virtual memory system requires an external memory device, and therefore cannot be applied to an embedded system that is often used in a real-time system. Furthermore, the saving of data in the main memory is performed when the memory capacity is insufficient, but in general, insufficient memory capacity is likely to occur when the load is high. There is a risk that processing requirements will not be met.

【0006】また、従来の交換プログラムにおいては、
多重処理の処理単位毎にデータ格納領域(これをトラン
ザクションメモリと呼ぶ)を設け、これを処理プログラ
ム間で持ち回ることにより多重処理を実現するととも
に、長期間処理が行われない場合に、次の処理に引き継
ぐ必要のあるデータのみを別メモリ領域に格納し、トラ
ンザクションメモリを解放することにより所要メモリ量
を削減していた。この方式は、処理の効率性を損なわず
にメモリ量を削減する効果があるが、多重処理を意識し
てアプリケーション側でトランザクションメモリのデー
タ構造を設計する必要があるため、プログラムが複雑化
し、プログラムの生産性、保守性を損ねるという弊害が
あった。
Further, in the conventional exchange program,
A data storage area (which is called a transaction memory) is provided for each processing unit of multiple processing, and this processing is carried between processing programs to realize multiple processing. Only the data that needs to be handed over to the process is stored in another memory area and the transaction memory is released to reduce the required memory amount. This method has the effect of reducing the amount of memory without sacrificing processing efficiency, but since the application side must design the data structure of the transaction memory in consideration of multiple processing, the program becomes complicated and However, there was an adverse effect that the productivity and maintainability of the machine were impaired.

【0007】実時間オペレーティングシステムを用い、
タスクを多重処理単位とすることにより、多重処理シス
テムのプログラムの構造を改良することができる。交換
プログラムにおけるトランザクションメモリはタスクに
おけるスタックに相当し、またスタック上のデータの割
り付けはプログラムの進行に応じて自動的に割り付けら
れるものであり、トランザクションメモリのデータ構造
の設計に相当している。
Using a real-time operating system,
By using a task as a multi-processing unit, the program structure of the multi-processing system can be improved. The transaction memory in the exchange program corresponds to the stack in the task, and the data allocation on the stack is automatically allocated according to the progress of the program, and corresponds to the design of the data structure of the transaction memory.

【0008】従来の実時間オペレーティングシステムを
用いた多重処理システムにおいて、タスクに割り付けら
れたスタックは、その実行が終了する(上記6の遷移で
タスクが削除される)までタスクに割り付けられたまま
である。従って、メモリを解放するためには次の処理に
引き継ぐデータを別のメモリ領域に待避したうえで、タ
スクを削除しなければならず、また次の処理を行うため
には、タスクを再度生成(アタッチ)する必要がある。
これは処理のオーバヘッドを増大させるとともに、プロ
グラム構造を複雑化させる。
In the conventional multi-processing system using the real-time operating system, the stack allocated to the task remains allocated to the task until its execution is completed (the task is deleted at the transition 6). . Therefore, in order to release the memory, the data to be carried over to the next process must be saved in another memory area and then the task must be deleted. In order to perform the next process, the task must be recreated ( Need to attach).
This increases the processing overhead and complicates the program structure.

【0009】[0009]

【発明が解決しようとする課題】従来の方式では、タス
ク数が多く、またタスクの存在時間に比べてタスクの処
理時間が短い場合に、スタックを割り付けるために必要
なメモリ量が膨大になり、またスタックが実際に必要と
なる延べ時間はシステムの運用時間に比べて非常に小さ
くなる。すなわちメモリの使用効率が悪い。本発明の目
的は、タスクを用いた実時間多重処理システムにおける
メモリ使用効率を改善する方法を提供することである。
In the conventional method, when the number of tasks is large and the processing time of the tasks is shorter than the existing time of the tasks, the amount of memory required for allocating the stack becomes enormous. Also, the total time required for the stack is much smaller than the system operation time. That is, the memory usage efficiency is poor. It is an object of the present invention to provide a method for improving memory usage efficiency in a task-based real-time multiprocessing system.

【0010】[0010]

【問題を解決する手段】本発明は、上記目的を達成する
ために、複数のプログラムを多重に動作させる多重処理
システムにおいて、実行プログラムとラストインファー
ストアウト(LIFO)で管理される作業領域(スタッ
ク)からなる処理単位(タスク)が予め指定された期間
実行されない場合に、上記タスクに割り付けられるスタ
ックのうち有効データを除く領域を一時的に解放し、該
プログラムが再開する際に所要メモリを再度割り付ける
ことを特徴としている。
In order to achieve the above object, the present invention provides a work area (stack) managed by an execution program and last-in first-out (LIFO) in a multi-processing system in which a plurality of programs are operated in a multiplexed manner. When a processing unit (task) consisting of () is not executed for a predetermined period, the area except the valid data in the stack allocated to the above task is temporarily released, and the required memory is re-established when the program restarts. It is characterized by allocation.

【0011】[0011]

【作用】本発明は、多重処理システムにおいて、タスク
が予め指定された期間実行されない場合に、タスクに割
り付けられるスタックのうち有効データを除く領域を一
時的に解放し、該プログラムが再開する際に所要メモリ
を再度割り付けるようにしたので、メモリの使用効率が
改善される。
According to the present invention, in a multi-processing system, when a task is not executed for a predetermined period, an area of the stack allocated to the task excluding valid data is temporarily released and the program is restarted. Since the required memory is reallocated, the memory usage efficiency is improved.

【0012】[0012]

【実施例】多重処理システムにおいては、各タスクは上
述したようにタスクの状態遷移モデルに沿って進行す
る。この場合、ある安定状態(待ち状態)になると長期
間タスクが実行されない場合が生じる。本発明は、この
場合にスタックを解放することによってメモリの使用効
率を高めたものである。そのための処理を図1を用いて
説明する。タスクは、タスク制御ブロックTCBとスタ
ックから構成され実行される。このときのタスクの状態
を(イ)に示す。その後、タスクが長期間実行されない
状態(待ち状態)になったことを後述の条件により検出
したときに、不要なスタックを解放する(矢印21)。
スタックが解放された時のタスクの状態を(ロ)に示
す。タスクの処理再開時にはスタックを再度割り付ける
(矢印22)。このときのタスクの状態を(ハ)に示
す。このように、タスクが長時間実行されないときには
スタックを解放するためメモリの使用効率は高まる。な
お、この際のスタック解放/再割り付け処理はオペレー
ティングシステムが行うものとする。また、スタックが
解放されたタスクについては、その情報をタスク制御ブ
ロック23に記録しておく。
BEST MODE FOR CARRYING OUT THE INVENTION In a multiprocessing system, each task progresses along the task state transition model as described above. In this case, the task may not be executed for a long period of time in a certain stable state (waiting state). The present invention improves the memory usage efficiency by releasing the stack in this case. A process therefor will be described with reference to FIG. A task consists of a task control block TCB and a stack and is executed. The state of the task at this time is shown in (a). After that, when it is detected that the task is not executed for a long time (waiting state) by a condition described later, an unnecessary stack is released (arrow 21).
The state of the task when the stack is released is shown in (b). When the task processing is resumed, the stack is reallocated (arrow 22). The state of the task at this time is shown in (c). In this way, when the task is not executed for a long time, the stack is released and the memory usage efficiency is improved. Note that the stack release / reallocation processing at this time is performed by the operating system. Further, regarding the task whose stack is released, the information is recorded in the task control block 23.

【0013】次に、スタックの解放と再割り付け、スタ
ック解放の契機、タスクの再開について具体的に説明す
る。 (1)スタックの解放と再割り付け タスクが安定状態になったときのタスクの状態を図2に
示す。図2には、有効データの状態によって取り得る各
種タスク状態を示す。(A)はスタック上に有効なデー
タを持たない場合であり、タスクが安定状態になるとた
だちにスタックを解放可能である。(B−1)はタスク
上に有効データを持ち、安定状態時のスタック上の有効
データは、プログラム開発時に分かっており、プログラ
ム上で陽に制御することが可能な場合である。(B−
2)はタスク上に有効データを持ち、安定状態時のスタ
ック上の有効データは実行状況に依存する場合である。
この場合、有効データにはコンパイラがスタックに割り
付ける作業用変数等が含まれるため、プログラム上で陽
に制御することができない。しかし、有効データの領域
は、タスクが安定状態になった時点のスタックポインタ
により知ることができる。
Next, the release and reallocation of the stack, the trigger for releasing the stack, and the restart of the task will be specifically described. (1) Release of stack and reallocation Figure 2 shows the task status when the task enters the stable state. FIG. 2 shows various task states that can be taken depending on the state of valid data. (A) is a case where there is no valid data on the stack, and the stack can be released immediately when the task enters the stable state. The case (B-1) has valid data on the task, and the valid data on the stack in the stable state is known at the time of program development and can be explicitly controlled on the program. (B-
2) is a case where the task has valid data and the valid data on the stack in the stable state depends on the execution status.
In this case, the valid data cannot be explicitly controlled on the program because the compiler includes work variables and the like allocated to the stack. However, the area of valid data can be known by the stack pointer when the task enters the stable state.

【0014】(B−1)の場合、有効データはスタック
とは別の有効データ領域31に割り付けておくことによ
り、(A)と同じ扱いが可能である。この有効データは
タスク生成時に割り付けておく。その場合、有効データ
領域31のアドレスはタスク制御ブロック32に記録し
ておく。(B−2)の場合は、図3に示すように、
(イ)の状態のタスクが安定状態(長期の処理中断)に
なると、有効データをスタックとは別に割り付けた(矢
印41)有効データ領域42に待避して(矢印43)、
スタックを解放(矢印44)して(ロ)の状態になる。
ただし、スタックの大きさに比べて有効データの領域が
十分小さくないと、プログラム実行のオーバヘッドが増
大する。タスクの安定状態(ロ)からタスク再開時に
は、スタックを再割り付け(矢印45)後、有効データ
領域(42)から有効データをスタック上に回復する
(矢印46)。不要となった有効データ領域は解放する
(矢印47)か、次回の待避操作に備えて割り付けたま
まにしておく。後者の場合、有効データ領域はタスク削
除時に解放される。有効データが待避されているか否か
と有効データ領域のアドレスはタスク制御ブロックの領
域(参照符号48および32)に記録しておく。
In the case of (B-1), the valid data can be treated in the same manner as (A) by allocating the valid data to a valid data area 31 different from the stack. This valid data is assigned when the task is created. In that case, the address of the valid data area 31 is recorded in the task control block 32. In the case of (B-2), as shown in FIG.
When the task in the state of (a) becomes a stable state (long-term processing suspension), the effective data is allocated to the stack (arrow 41) and saved in the effective data area 42 (arrow 43),
The stack is released (arrow 44) to enter the state of (b).
However, if the effective data area is not sufficiently small compared to the size of the stack, the overhead of program execution increases. When the task is restarted from the stable state (b) of the task, the stack is reallocated (arrow 45) and the valid data is restored from the valid data area (42) onto the stack (arrow 46). The unnecessary valid data area is released (arrow 47) or left allocated in preparation for the next save operation. In the latter case, the valid data area is released when the task is deleted. Whether or not the valid data is saved and the address of the valid data area are recorded in the task control block area (reference numerals 48 and 32).

【0015】(B−2)はさらに次の2つの方式に分け
られる。(B−2−1)実メモリシステムでは、有効デ
ータに元のスタックに割り当てられたメモリ領域に依存
するデータが含まれていないことが、有効データ退避、
スタックを解放、再割付けを可能にする条件となる。こ
れはタスク再開時に再割付けされるスタックのメモリ領
域のアドレスが、元のスタックのメモリ領域のアドレス
とは必ずしも同一とはならないためである。これを図4
を用いて説明する。あるタスクのスタック54につい
て、その上の有効データを退避した後に解放し、その
後、スタックを再割付け(55)し、有効データを回復
するものとする。スタック54とスタック55の領域
は、通常、アドレスの異なるメモリ領域に割り付けられ
る。元のスタック54上に、同じスタックのデータ52
のアドレスを持つデータ51があるものとする。有効デ
ータ回復後、51のデータは、56にコピーされる。ま
た、52のデータは53にコピーされる。したがって、
データ56は、53のデータのアドレスを持つべきであ
るが、元の有効データをコピーしただけなので、52の
データのアドレスのままである。スタック領域54は、
すでに他の用途に使われている可能性もあり、このまま
では正しい処理を続けることができないため、有効デー
タに元のスタックに割り付けられたメモリ領域に依存す
るデータが含まれていると、スタックを解放、再割付け
を行うことはできない。
(B-2) is further divided into the following two methods. (B-2-1) In the actual memory system, valid data is saved because valid data does not include data that depends on the memory area allocated to the original stack.
It is a condition that allows the stack to be released and reallocated. This is because the address of the memory area of the stack that is reallocated when the task is restarted is not always the same as the address of the memory area of the original stack. Figure 4
Will be explained. It is assumed that the stack 54 of a task is released after the valid data on it is saved, and then the stack is reallocated (55) to restore the valid data. The areas of the stack 54 and the stack 55 are normally allocated to memory areas having different addresses. Data 52 of the same stack on the original stack 54
It is assumed that there is data 51 having an address of. After valid data recovery, the data of 51 is copied to 56. Further, the data of 52 is copied to 53. Therefore,
The data 56 should have the address of the data of 53, but it remains the address of the data of 52 because it has just copied the original valid data. The stack area 54 is
Since it may have already been used for other purposes and the correct processing cannot be continued as it is, if the valid data contains data that depends on the memory area allocated to the original stack, the stack will be It cannot be released or reallocated.

【0016】(B−2−2)ページ単位の論理アドレス
変換機構を持つシステム(参考文献:日本モトローラ、
「MC68030ユーザーズマニュアル」では、図5に
示すように、スタック用の物理メモリ61をページ単位
に割り付け(矢印62)、スタック解放時には物理メモ
リのみを解放し(矢印63)、タスク再開時には元のス
タックと同じ論理アドレス(64)に物理メモリを割り
付ける(矢印65)。スタック上の有効データが待避さ
れたタスクに関しては、その情報と有効データ領域のア
ドレスをタスク制御ブロックに記録しておく。論理アド
レス変換機構を利用したシステムでは、スタックの論理
アドレスと物理メモリの割り付け状況をタスク制御ブロ
ックに記録しておく。(B−1)の場合、有効データ待
避領域に関しては、タスク生成時に割り付けておくか、
スタック解放時に割り付ける方式のいずれかをとること
ができる。
(B-2-2) A system having a logical address translation mechanism for each page (reference: Nippon Motorola,
In the "MC68030 User's Manual", as shown in FIG. 5, the physical memory 61 for stack is allocated in page units (arrow 62), only the physical memory is released when releasing the stack (arrow 63), and the original stack is resumed when resuming the task. The physical memory is allocated to the same logical address (64) as in (arrow 65). For a task for which valid data on the stack has been saved, its information and the address of the valid data area are recorded in the task control block. In the system using the logical address translation mechanism, the logical address of the stack and the allocation status of the physical memory are recorded in the task control block. In the case of (B-1), the valid data saving area is allocated at the time of task creation, or
One of the methods of allocating when releasing the stack can be used.

【0017】(2)スタックの解放契機 スタックが解放可能になった時点で直ちにスタックを解
放すると、タスクの安定状態が短い場合に、スタック解
放/再割り付けの頻度が高くなり、実行時間のオーバヘ
ッドを増大させる。このため、以下の方式によりスタッ
ク解放可能なタスクを求め、そのスタックを解放し、新
規生成タスク用のスタックエリアを確保する。(B−
2)の場合、スタック上の有効データの範囲は、スタッ
クポインタにより求めることができる。 ・スタック解放可能になったタスク(これを中断タスク
と呼ぶ)をオペレーティングシステムで記憶しておく。 ・スタックの解放は、実時間処理要求条件を満たすた
め、スタックエリアが不足する(使いきる)前に行う。 ・使用可能なスタックエリアが定められた値より少なく
なった時点で、中断タスクの中からシステムの運用条件
に応じたアルゴリズムにより、適当なタスクを選ぶ。こ
のアルゴリズムとしては周知のアルゴリズムのいずれの
ものでもよく、例えば、仮想記憶方式でよく用いられる
LRU方式、一定期間以上中断しているタスクの中で中
断時間が最小のタスクを選択する方式でもよい。ここで
一定時間以上中断しているという条件をつける理由は、
中断時間が極端に短いタスクを選択するのを防止するた
めである。実時間処理においては、タスクの中断は入出
力完了待ちのように短期のものと、外部イベント待ちの
ように比較的長期のものがある。なお、アプリケーショ
ンで長期間中断することをオペレーティングシステムに
通知しておくようにすれば、オペレーティングシステム
では、この長期間中断タスクのスタックを解放すればよ
くなるので、スタックを解放するタスクの選択が簡略化
される。
(2) Trigger of stack release If the stack is released immediately when the stack becomes free, stack release / reallocation becomes more frequent when the stable state of the task is short, resulting in an overhead of execution time. Increase. Therefore, the task that can release the stack is obtained by the following method, the stack is released, and the stack area for the newly created task is secured. (B-
In the case of 2), the range of valid data on the stack can be obtained by the stack pointer. -The operating system stores the task that can release the stack (called a suspended task). -The stack is released before the stack area runs out (is used up) because it meets the real-time processing requirements. -When the usable stack area becomes less than the specified value, an appropriate task is selected from among suspended tasks by an algorithm according to the operating conditions of the system. Any known algorithm may be used as this algorithm, for example, an LRU method often used in a virtual memory method, or a method of selecting a task with the shortest interruption time among tasks suspended for a certain period or longer. The reason for setting the condition that it is suspended for a certain period of time is as follows.
This is to prevent selecting a task whose interruption time is extremely short. In real-time processing, there are short-term tasks such as waiting for I / O completion and relatively long-term tasks such as waiting for external events. If the application notifies the operating system that it will be suspended for a long period of time, the operating system only needs to release the stack of this long-term suspended task, which simplifies the selection of the task that releases the stack. To be done.

【0018】(3)タスクの再開 タスク再開時のフローチャートを図6に示す。図6にお
いて、タスクの再開処理を開始する(ステップ71)
と、タスク制御ブロックのスタック割り当て情報をみ
て、スタック割り付け済みか否かを判定する(ステップ
72)。スタックが割り当てられたままであれば、通常
の手順にしたがってタスクを再開する(ステップ7
6)。ステップ72の判定の結果、スタックが割り付け
済みでないならば(スタックが解放されていれば)、ス
タックの再割り付けを行う(ステップ73)。そして、
有効データ退避領域がないかどうかを判定する(ステッ
プ74)。有効データ待避領域があれば、スタックにデ
ータを戻す(ステップ75)。また上記(B−2−2)
の場合、すなわちページ単位の論理アドレス変換機構を
もつ場合には、もとのスタックと同じ論理アドレスとな
るように、アドレス変換テーブルを設定する。
(3) Resumption of task FIG. 6 shows a flowchart for resuming a task. In FIG. 6, the task restart processing is started (step 71).
Then, the stack allocation information of the task control block is checked to determine whether or not stack allocation has been completed (step 72). If the stack remains allocated, the task is resumed according to the normal procedure (step 7).
6). If the result of determination in step 72 is that the stack has not been allocated (if the stack has been released), the reallocation of the stack is performed (step 73). And
It is determined whether or not there is a valid data save area (step 74). If there is a valid data saving area, the data is returned to the stack (step 75). The above (B-2-2)
In the case of, that is, in the case of having a logical address translation mechanism in page units, the address translation table is set so that the logical address becomes the same as the original stack.

【0019】本発明を並列オブジェクト指向システムに
適用した例を図7に示す(参考文献丸山、久保田“オブ
ジェクト指向による交換プログラムの構成法”、電子情
報通信学会論文誌、J74−B−I、No.10 19
91)。図7に示すようにオブジェクトは、オブジェク
トの状態を示すインスタンス変数と、オブジェクトに対
する操作を示すメソッド(図示せず)により定義され、
並列に動作する。オブジェクトのインスタンス81は、
タスク制御に相当する並列制御機構82、オブジェクト
メソッド実行用スタック83とインスタンス変数領域8
4からなる。インスタンス変数領域84はオブジェクト
固有のデータを含む領域で、オブジェクトが存在する間
は常に有効データを含んでいる。
An example in which the present invention is applied to a parallel object-oriented system is shown in FIG. 7 (reference document: Maruyama, Kubota "Method of constructing exchange program by object orientation", IEICE Transactions, J74-BI, No. 10 19
91). As shown in FIG. 7, an object is defined by an instance variable indicating the state of the object and a method (not shown) indicating an operation on the object.
Operates in parallel. The object instance 81 is
Parallel control mechanism 82 corresponding to task control, object method execution stack 83, and instance variable area 8
It consists of 4. The instance variable area 84 is an area containing data unique to the object, and always contains valid data while the object exists.

【0020】オブジェクトは他のオブジェクトから送ら
れるメッセージを受信して、それに対応するメソッドを
起動する。メソッド実行途中でメッセージ待ちになるこ
とはない。この時、メソッド実行中(メッセージ受信待
ち)でなければこのオブジェクトの有効データはインス
タンス変数のみである。したがって前述の方式(B−
1)により、スタックの動的解放を行うことができる。
オブジェクトのメッセージ受信待ちは、前述のタスクの
安定状態(長期中断)に相当する。
An object receives a message sent from another object and activates the corresponding method. There is no need to wait for a message during method execution. At this time, the valid data of this object is only instance variables unless the method is being executed (waiting for message reception). Therefore, the above method (B-
According to 1), the stack can be dynamically released.
Waiting for an object to receive a message corresponds to the stable state (long-term suspension) of the task described above.

【0021】以上述べたように、本発明の実施例では、
実時間処理要求を満たすために外部記憶装置を利用せず
に、所要メモリ量の削減を行い、またプログラムの構造
を複雑化させないため、実時間オペレーティングシステ
ムを用いたタスクにより多重処理を実現し、またプログ
ラム構造を複雑化させないため、タスクの頻繁な削除/
再生成は避けるようにしている。この場合、メモリ待避
回復処理はオペレーティングシステムが行い、アプリケ
ーションプログラムの変更は原則として行わない。
As described above, in the embodiment of the present invention,
To reduce the amount of memory required without using an external storage device to satisfy real-time processing requirements, and not to complicate the program structure, multiple processing is realized by a task using a real-time operating system. Frequent deletion of tasks / in order not to complicate the program structure
I try to avoid regeneration. In this case, the memory save recovery process is performed by the operating system, and the application program is not changed in principle.

【0022】[0022]

【発明の効果】本発明によると、多重処理(マルチタス
ク)システムにおいて、所定期間タスクの処理が中断し
た場合、有効データを除く領域を一時的に解放し、処理
再開時に所要メモリを再度割り付けるようにしたので、
メモリの使用効率が大幅に向上する。
According to the present invention, in a multi-processing system, when the processing of a task is interrupted for a predetermined period, the area excluding valid data is temporarily released and the required memory is reallocated when the processing is restarted. Because I chose
Memory usage efficiency is greatly improved.

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

【図1】スタックの解放と再割り付けを示す図である。FIG. 1 is a diagram showing stack release and reallocation.

【図2】スタック上有効データを示す図である。FIG. 2 is a diagram showing valid data on a stack.

【図3】スタック上有効データの待避と回復を示す図で
ある。
FIG. 3 is a diagram showing saving and recovery of valid data on a stack.

【図4】スタックの解放と再割り付けの条件を示す図で
ある。
FIG. 4 is a diagram showing conditions of stack release and reallocation.

【図5】論理アドレスを用いた場合のスタック解放と再
割り付けを示す図である。
FIG. 5 is a diagram showing stack release and reallocation when a logical address is used.

【図6】タスク再開の処理手順を示す図である。FIG. 6 is a diagram showing a processing procedure for task restart.

【図7】並列に動作するオブジェクトを示す図である。FIG. 7 is a diagram showing objects operating in parallel.

【図8】タスクの状態遷移図である。FIG. 8 is a state transition diagram of a task.

【図9】タスクの構造を示す図である。FIG. 9 is a diagram showing the structure of a task.

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

1 タスクをアタッチし、タスク制御ブロックを作動可
能待ち行列に入れる遷移 2 作動可能タスクが活動状態に移る遷移 3 活動状態のタスクが待ち状態に移る遷移 4 待ち状態のタスクが作動可能状態に移る遷移 5 活動状態のタスクが作動可能状態に移る遷移 6 活動状態のタスクが処理を終了し資源を解放する遷
移 11 タスク 12 タスク制御ブロック(TCB) 13 スタック 14 プッシュ(push)操作 15 ポップ(pop)操作 16 スタック上有効データ 17 スタックポインタ指示 18 スタックアドレスフィールド 19 スタックポインタフィールド 21 スタック解放 22 スタック再割り付け 23 スタック割り付け状況フィールド 31 有効データ(待避)領域(タスク生成時割り付
け) 32 有効データ領域アドレスフィールド 41 有効データ領域割り付け 42 有効データ(待避)領域(スタック解放時割り付
け) 43 有効データの待避(スタックから有効データ領域
へのコピー) 44 スタック解放 45 スタック再割り付け 46 有効データの回復(有効データ領域からスタック
へのコピー) 47 有効データ領域解放 48 退避データ状況フィールド 51 同一スタック上のデータのアドレスを持つデータ
(スタック解放前) 52 同一スタック上の他のデータからポイントされて
いるデータ(スタック解放前) 53 同一スタック上の他のデータからポイントされる
べきデータ(スタック再割付け後) 54 解放前のスタック 55 再割付けされたスタック 56 同一スタック上のデータのアドレスを持つデータ
(スタック再割付け後) 61 スタック用物理メモリ(ページ) 62 物理メモリ割り付け 63 物理メモリ解放 64 同一論理アドレスへのスタックの割り付け 65 スタック用物理メモリの再割り付け 81 オブジェクトインスタンス 82 オブジェクト並列動作機構 83 オブジェクトメソッド実行用スタック 84 インスタンス変数領域
1 Transition to attach task and put task control block in ready queue 2 Transition to move ready task to active state 3 Transition to move active task to wait state 4 Transition to move ready task to ready state 5 Transition in which active task moves to ready state 6 Transition in which active task finishes processing and releases resources 11 Task 12 Task control block (TCB) 13 Stack 14 Push operation 15 Pop operation 16 Effective data on stack 17 Stack pointer instruction 18 Stack address field 19 Stack pointer field 21 Stack release 22 Stack reallocation 23 Stack allocation status field 31 Effective data (save) area (allocation at task creation) 32 Effective data area address Field 41 Effective data area allocation 42 Effective data (save) area (allocation at stack release) 43 Effective data save (copy from stack to effective data area) 44 Stack release 45 Stack reallocation 46 Recovery of effective data (effective data area) To stack) 47 Release valid data area 48 Saved data status field 51 Data with address of data on same stack (before stack release) 52 Data pointed to by other data on same stack (before stack release) ) 53 data to be pointed to by other data on the same stack (after stack reallocation) 54 stack before release 55 reallocated stack 56 data having address of data on the same stack (after stack reallocation) 61 stack Physical memory (page) 62 physical memory allocation 63 physical memory release 64 same logical reallocation 81 object instance 82 object parallel operation mechanism 83 object method invocation stack 84 instance variable region of physical memory for allocation 65 stack stack to the address

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】 複数のタスクを多重に動作させる多重処
理システムにおけるメモリ管理方法において、上記各タ
スクは、実行プログラムと、必要に応じて該タスクに動
的に割り付けられラストインファーストアウトで管理さ
れるスタックから構成されており、該タスクが予め指定
された期間実行されないことが検出されたときに、該タ
スクに割り付けられた上記スタックのうち有効データを
除く領域を一時的に解放し、該タスクが再開する際に所
要メモリを再度割り付けるようにしたことを特徴とする
多重処理システムにおけるメモリ管理方法。
1. A memory management method in a multi-processing system for operating a plurality of tasks in a multiplexed manner, wherein each task is dynamically allocated to the execution program as needed and managed last in first out. When it is detected that the task is not executed for a predetermined period of time, the area except the valid data in the stack allocated to the task is temporarily released, and the task A memory management method in a multi-processing system, wherein required memory is reallocated when restarted.
JP14334093A 1993-06-15 1993-06-15 Memory managing method of multi-processing system Pending JPH076045A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP14334093A JPH076045A (en) 1993-06-15 1993-06-15 Memory managing method of multi-processing system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP14334093A JPH076045A (en) 1993-06-15 1993-06-15 Memory managing method of multi-processing system

Publications (1)

Publication Number Publication Date
JPH076045A true JPH076045A (en) 1995-01-10

Family

ID=15336518

Family Applications (1)

Application Number Title Priority Date Filing Date
JP14334093A Pending JPH076045A (en) 1993-06-15 1993-06-15 Memory managing method of multi-processing system

Country Status (1)

Country Link
JP (1) JPH076045A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010532053A (en) * 2007-06-27 2010-09-30 マイクロソフト コーポレーション Utilizing transactional memory hardware to facilitate virtualization and emulation
KR101458028B1 (en) * 2007-05-30 2014-11-04 삼성전자 주식회사 Apparatus and method for parallel processing

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101458028B1 (en) * 2007-05-30 2014-11-04 삼성전자 주식회사 Apparatus and method for parallel processing
JP2010532053A (en) * 2007-06-27 2010-09-30 マイクロソフト コーポレーション Utilizing transactional memory hardware to facilitate virtualization and emulation
US9043553B2 (en) 2007-06-27 2015-05-26 Microsoft Technology Licensing, Llc Leveraging transactional memory hardware to accelerate virtualization and emulation

Similar Documents

Publication Publication Date Title
US9798595B2 (en) Transparent user mode scheduling on traditional threading systems
US6006247A (en) Method and system for scheduling threads and handling exceptions within a multiprocessor data processing system
US5410700A (en) Computer system which supports asynchronous commitment of data
US5559978A (en) Method for increasing the efficiency of a virtual memory system by selective compression of RAM memory contents
JPH04137046A (en) Operating system for electronic computer
US8321874B2 (en) Intelligent context migration for user mode scheduling
JPH0353328A (en) Register saving recoverying method and processor
JP2003167737A (en) Stack use method
JP3034873B2 (en) Information processing device
US5678024A (en) Method and system for dynamic performance resource management within a computer based system
WO2003040948A1 (en) Computer and control method
JP2001256062A (en) Interruption processing method and operation processor using the same
JPWO2008114415A1 (en) Multi-processing system
JPH076045A (en) Memory managing method of multi-processing system
JP3991443B2 (en) Task switching method and data processing apparatus
JPS603229B2 (en) Information processing method
JP2003263366A (en) Swapping control method, its execution device and its processing program
KR100401560B1 (en) Kernel Stack Dynamic Allocation Method In Operating System
JP3163196B2 (en) Instruction interruption information storage control method in virtual storage control
JPH04213733A (en) Virtual processor system
JPH04218842A (en) Reexecution method for program
JPH06266619A (en) Page saving/restoring device
JPH04283849A (en) Multiprocessor system
JP2001282553A (en) Multithread control method, multithread controller, recording medium and program
JPH11161506A (en) Dispatch method for information processor, information processor and storage medium thereof