JPH0640311B2 - Register saving method - Google Patents

Register saving method

Info

Publication number
JPH0640311B2
JPH0640311B2 JP1104632A JP10463289A JPH0640311B2 JP H0640311 B2 JPH0640311 B2 JP H0640311B2 JP 1104632 A JP1104632 A JP 1104632A JP 10463289 A JP10463289 A JP 10463289A JP H0640311 B2 JPH0640311 B2 JP H0640311B2
Authority
JP
Japan
Prior art keywords
register
memory
program
contents
save
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 - Lifetime
Application number
JP1104632A
Other languages
Japanese (ja)
Other versions
JPH02284235A (en
Inventor
茂樹 柴山
Original Assignee
工業技術院長
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 工業技術院長 filed Critical 工業技術院長
Priority to JP1104632A priority Critical patent/JPH0640311B2/en
Publication of JPH02284235A publication Critical patent/JPH02284235A/en
Publication of JPH0640311B2 publication Critical patent/JPH0640311B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Description

【発明の詳細な説明】 [発明の目的] (産業上の利用分野) 本発明は電子計算機システムにおいて、プログラムによ
るコンテキストの切替え時に必要なレジスタの内容を効
率的に保存することのできるレジスタ保存方法に関す
る。
DETAILED DESCRIPTION OF THE INVENTION Object of the Invention (Industrial field of use) The present invention relates to a register saving method capable of efficiently saving the contents of registers required when a context is switched by a program in an electronic computer system. Regarding

(従来の技術) 電子計算機のCPUでは、通常、計算中のデータや、そ
のプログラムの実行に必要な情報、例えば計算機の動作
状態やスタックのポインタ等を汎用または専用のレジス
タを用いて保持している。レジスタに保持されるこれら
の情報は、その時点で実行されているプログラムの状態
を再現する上で必要なものである。特にマルチプログラ
ミングの環境下では、例えば割り込み等によって起動さ
れるコンテキストの切替えが行われることから、その切
替えが行われる直前のレジスタの内容をメモリ上の所定
の領域に格納することが行われる。そして、コンテキス
トが再開された場合には上記メモリに格納されている情
報を用いてレジスタの内容を復元することで、プログラ
ム実行の連続性を保つことが行われる。
(Prior Art) In a CPU of an electronic computer, data that is being calculated and information necessary for executing the program, such as an operating state of the computer and a pointer of a stack, are usually held by using a general-purpose or dedicated register. There is. These pieces of information held in the registers are necessary for reproducing the state of the program currently being executed. Particularly in a multi-programming environment, context switching activated by, for example, an interrupt is performed, so that the contents of the register immediately before the switching is stored in a predetermined area on the memory. When the context is restarted, the contents of the register are restored by using the information stored in the memory to maintain the continuity of the program execution.

このようなコンテキストの切替えに伴うレジスタ内容の
保存とその読出しは、一般的にはストア・マルチプル命
令やロード・マルチプル命令等を用いたソフトウェア手
続きにより、コンテキストの切替え指令が与えられた時
に実行される。これらの命令はプログラマに対する処理
負担を軽減する上で非常に有効なものであり、比較的簡
単に実行できる。しかし一般的にはデータバス上での制
約等からレジスタ内容の保存とその読出しには、レジス
タ数に比例した処理時間が掛かる。これ故、多数のレジ
スタを用いてプログラムを実行しているような場合、コ
ンテキストの切替え処理に時間が掛かり、その処理速度
が大幅に低下することが否めない。従って数多くの汎用
レジスタを備えたマイクロプロセッサにとっては、コン
テキストの切替えに伴うレジスタ内容の保存とその読出
しを如何にして効率的に行うかと云う点で深刻な問題と
なりつつある。
Saving and reading of register contents accompanying such context switching are generally executed when a context switching command is given by a software procedure using a store / multiple instruction or load / multiple instruction. . These instructions are very effective in reducing the processing load on the programmer and can be executed relatively easily. However, generally, due to restrictions on the data bus and the like, saving and reading the contents of a register takes a processing time proportional to the number of registers. Therefore, in the case where a program is executed using a large number of registers, it is undeniable that the context switching process takes time and the processing speed is significantly reduced. Therefore, for a microprocessor equipped with a large number of general-purpose registers, it is becoming a serious problem in terms of how to efficiently store and read the register contents accompanying context switching.

そこで従来では予めCPU内に多数のレジスタを準備し
ておき、コンテキストの切替え時には使用中のレジスタ
とは別のレジスタを新たなコンテキストの実行用に割り
当て、これによってレジスタ内容の保存処理時間を見掛
け上なくする方式が考えられている。然し乍ら、この方
式を採用するにしても、CPUに内蔵可能なレジスタ数
には実質的に限りがあるので、その数を越える複数のコ
ンテキストを取り扱う場合には同様な問題がある。しか
もレジスタの数を越えるコンテキストを取り扱う場合に
は、上述した例と同様にソフトウェアの助けが必要とな
り、かえってソフトウェアでの処理負担が重くなった
り、処理速度が低下する等の不具合が生じた。更には多
数のレジスタを備えているにも拘らず、プログラミング
・モデルとしては限られた少数のレジスタしか使用する
ことができないので、プログラムのメモリ・アクセス回
数が増え、この結果、その処理速度が低下する等の問題
も生じた。
Therefore, in the past, a large number of registers were prepared in the CPU in advance, and when switching contexts, a register different from the register being used was allocated for execution of a new context, and this made it possible to estimate the processing time to save the register contents. A method of eliminating it is being considered. However, even if this method is adopted, since the number of registers that can be incorporated in the CPU is substantially limited, there is a similar problem when handling a plurality of contexts exceeding that number. Moreover, when dealing with contexts that exceed the number of registers, software assistance is required as in the above-described example, which causes a problem that the processing load on the software becomes heavy and the processing speed decreases. Furthermore, despite the large number of registers, only a limited number of registers can be used as a programming model, so the number of memory accesses of the program increases, resulting in a decrease in the processing speed. There was also a problem such as doing.

一方、特開昭63-208128号公報にはCPUにレジスタ退
避エリアを設けておき、複数のレジスタ毎にその内容が
上記レジスタ退避エリアに退避されたか否かを示すフラ
グを持たせ、このフラグを参照することでレジスタの回
復時に上記レジスタ退避エリアから破壊前のレジスタ内
容を求める手法が開示されている。このような手法によ
れば、コンテキストの切替え時に先のコンテキストの実
行状態を示すレジスタ内容を非常に効果的に復元するこ
とができると云う利点がある。
On the other hand, in JP-A-63-208128, a CPU is provided with a register save area, and a flag indicating whether or not the contents are saved in the register save area is provided for each of a plurality of registers. By reference, a method for obtaining the register contents before destruction from the register save area when the register is restored is disclosed. According to such a method, there is an advantage that the register contents indicating the execution state of the previous context can be restored very effectively when the context is switched.

しかしレジスタ退避エリアに対してどのようにしてレジ
スタ内容を効率的に退避させておくかと云う点で、上述
した複数のレジスタを選択的に用いる場合と同様な問題
が残されている。
However, in terms of how to efficiently save the register contents in the register save area, the same problem as in the case of selectively using the plurality of registers described above remains.

(発明が解決しようとする課題) このように従来にあってはコンテキストの切替えを効率
的に行うべく、実行中のレジスタの内容を保存し、また
保存されているレジスタの内容を読出して先のコンテキ
ストの実行におけるレジスタ内容を復元再生する上で、
如何にして効率的にレジスタの内容を保存しておくかと
云う点で問題が残されている。
(Problems to be solved by the invention) As described above, in the related art, in order to efficiently perform context switching, the contents of the register being executed are saved, and the contents of the saved register are read out to In restoring and reproducing the register contents in context execution,
A problem remains in how to efficiently store the contents of registers.

本発明はこのような事情を考慮してなされたもので、そ
の目的とするところは、取り扱い得るレジスタの数に事
実上制限がなく、しかもこれらのレジスタの内容を効率
的に保存してコンテキストの切替え処理を高速に行うこ
とを可能とするレジスタ保存方法を提供することにあ
る。
The present invention has been made in consideration of such circumstances, and the purpose thereof is that the number of registers that can be handled is virtually unlimited, and the contents of these registers can be efficiently stored to save the context. It is to provide a register saving method that enables high-speed switching processing.

[発明の構成] (課題を解決するための手段) 本発明は、サブルーチンを含むプログラムの最初でバッ
クグラウンド保存命令及び保存領域アドレスが指定さ
れ、前記プログラム内での前記サブルーチンの直前でマ
ルチプル保存命令及び保存領域アドレスが指定されたプ
ログラム命令列を順次実行する計算機のレジスタ保存方
法であって、プログラムの実行に必要な情報を保持する
ための複数のレジスタに、プログラムの実行によって前
記レジスタの内容が更新されたときにリセットされるフ
ラグを夫々付属させて設け、前記バックグラウンド保存
命令を実行する際には、リセットされたフラグの有無を
順次調べ、リセットされたフラグが有る場合に当該レジ
スタの内容を前記保存領域アドレスに従ってメモリへ格
納し、この格納に成功したときに当該フラグをセットす
る各処理を、前記バックグラウンド保存命令の直後から
前記マルチプル保存命令の直前までのプログラムの実行
と並行して、該プログラムの実行を妨げることのない空
き時間を利用して行ない、前記マルチプル保存命令を実
行する際に、リセットされたフラグの有無を順次調べ、
リセットされたフラグが有る場合に当該レジスタの内容
を前記保存領域アドレスに従って前記メモリへ格納し、
この格納に成功したときに当該フラグをセットすること
を特徴とするものである。
[Structure of the Invention] (Means for Solving the Problem) According to the present invention, a background save instruction and a save area address are specified at the beginning of a program including a subroutine, and a multiple save instruction is executed immediately before the subroutine in the program. And a register storing method of a computer for sequentially executing a program instruction sequence in which a storage area address is designated, wherein the contents of the registers are stored in a plurality of registers for holding information necessary for executing the program. A flag that is reset when updated is provided separately, and when the background save instruction is executed, the presence or absence of a reset flag is sequentially checked, and if there is a reset flag, the contents of the register Was stored in the memory according to the storage area address, and this storage was successful. Each of the processes for setting the flag at the same time as the execution of the program from immediately after the background save instruction to immediately before the multiple save instruction, using a free time that does not prevent the execution of the program. When performing the multiple save instruction, the presence or absence of the reset flag is sequentially checked,
Stores the contents of the register in the memory according to the storage area address when there is a reset flag,
The feature is that the flag is set when the storage is successful.

(作用) このようなレジスタ内容の保存制御を行う本発明によれ
ば、サブルーチンを含むプログラムの最初でバックグラ
ウンド保存命令及び保存領域アドレスを指定すること
で、このバックグラウンド保存命令の直後から前記マル
チプル保存命令の直前までのプログラムの実行と並行し
て、例えばメモリバスの空きを検出してバックグラウン
ド処理にてレジスタの内容を逐次保存していくことがで
きるので、コンテキストの切替え時に改めてレジスタ内
容の保存処理を行う必要がなくなり、その処理負担を軽
減することができ、またその処理時間の短縮化を図るこ
とが可能となる。しかもプログラムの実行を妨げること
のない空き時間を利用して行なわれることから、本来の
プログラムの実行に悪影響を及ぼすことなくレジスタ内
容の保存を行わせることができるので、コンテキストの
切替え処理に必要な処理時間を大幅に軽減することがで
きる。
(Operation) According to the present invention for controlling the storage of the register contents as described above, by designating the background save instruction and the save area address at the beginning of the program including the subroutine, the multiple save is performed immediately after the background save instruction. In parallel with the execution of the program until immediately before the save instruction, for example, it is possible to detect the vacancy of the memory bus and save the register contents sequentially in the background processing. It is not necessary to perform the storage process, the processing load can be reduced, and the processing time can be shortened. Moreover, since the free time that does not hinder the execution of the program is used, the register contents can be saved without adversely affecting the original execution of the program, which is necessary for the context switching process. The processing time can be significantly reduced.

またレジスタに付属させたフラグを用いてそのレジスタ
内容の保存が完了しているか否かを表し、このフラグを
参照することで保存が行われていないレジスタの内容に
対してのみ保存処理を行うので、内容保存が完了してい
るレジスタに対する無駄な保存処理を実行することがな
くなり、その処理効率の向上を図ることが可能となる。
In addition, the flag attached to the register is used to indicate whether or not the contents of the register have been saved. By referring to this flag, only the contents of the register that have not been saved are saved. Thus, it is possible to improve the processing efficiency by avoiding the unnecessary storage process for the register whose contents have been stored.

(実施例) 以下、図面を参照して本発明の一実施例に係るレジスタ
保存方法について説明する。
(Embodiment) Hereinafter, a register saving method according to an embodiment of the present invention will be described with reference to the drawings.

第1図は実施例方式を適用して構成される中央演算処理
装置(CPU)の概略的な内部構成を示す図である。こ
のCPUは基本的には内部バス1,2に、例えば16個
のレジスタを備えたレジスタファイル(RF)3や算術
演算ユニット(ALU)4等を接続して構成される。A
LU4はコントローラ(CONT)5の制御を受け、与
えられたプログラムに従って上記レジスタファイル3を
用いながら所定の演算処理を実行する。
FIG. 1 is a diagram showing a schematic internal configuration of a central processing unit (CPU) configured by applying the embodiment system. This CPU is basically configured by connecting a register file (RF) 3 having, for example, 16 registers, an arithmetic operation unit (ALU) 4, etc. to the internal buses 1 and 2. A
The LU 4 receives the control of the controller (CONT) 5 and executes a predetermined arithmetic process according to a given program while using the register file 3.

しかしてメモリ(MRY)6に対するデータの書き込み
とその読出しは、前記コントローラ5の制御を受けて動
作するメモリコントローラ(MCONT)7の管理の下
で、メモリバス8の空きを検出して行われる。即ち、上
記メモリ6に対するデータの書き込みは、メモリアドレ
スレジスタ(MARN)9にセットされたメモリアドレ
スに従ってメモリ6に対する書き込みアドレスを指定
し、該当アドレスにメモリデータレジスタ(MDRN)
10に格納されているデータを上記メモリバス8を介して
転送し、前記メモリ6に書き込むことにより行われる。
またメモリ6からのデータの読出しは、前記メモリアド
レスレジスタ(MARN)9により指定されるアドレス
に書き込まれているデータを前記メモリバス8を介して
読出し、メモリレジスタ(MSR)11に格納することに
よって行われる。このメモリレジスタ(MSR)11に格
納されたデータを前記内部バス1,2を介してALU4
やレジスタバッファ3にデータを取り込むことにより、
前記メモリ6に書き込まれていたデータを用いた情報処
理が実行される。
Data writing to and reading from the memory (MRY) 6 are performed by detecting the vacancy of the memory bus 8 under the control of the memory controller (MCONT) 7 which operates under the control of the controller 5. That is, when writing data to the memory 6, the write address for the memory 6 is specified according to the memory address set in the memory address register (MARN) 9 and the memory data register (MDRN) is set to the corresponding address.
Data stored in 10 is transferred via the memory bus 8 and written in the memory 6.
Data can be read from the memory 6 by reading the data written at the address designated by the memory address register (MARN) 9 through the memory bus 8 and storing it in the memory register (MSR) 11. Done. The data stored in the memory register (MSR) 11 is transferred to the ALU 4 via the internal buses 1 and 2.
Or by loading data into the register buffer 3,
Information processing using the data written in the memory 6 is executed.

ここでこの実施例が特徴とするところは、前記レジスタ
ファイル3に準備される複数のレジスタのそれぞれに本
発明を特徴付けるフラグをそれぞれ設け、カウンタ(C
TR)12の制御の下で前記レジスタファイル3に格納さ
れているデータをバックグラウンド処理にて前述したA
LU4によるプログラムの実行と並行して次々に前記メ
モリ6に格納保存するようにした点にある。
Here, the feature of this embodiment is that each of a plurality of registers prepared in the register file 3 is provided with a flag characterizing the present invention, and a counter (C
The data stored in the register file 3 under the control of (TR) 12 is processed in the background process A described above.
The point is that the program is stored and saved in the memory 6 one after another in parallel with the execution of the program by the LU 4.

このバックグラウンド処理による前記レジスタファイル
3のデータ保存は、後述するようにバックグラウンド処
理が指定されたとき、上記カウンタ12によるレジスタの
選択指定によって当該レジスタに格納されているデータ
を前記内部バス2を介してメモリデータレジスタ(MD
RR)13に転送して格納し、同時にアドレスコントロー
ラ(ACONT)14の制御の下でメモリアドレスレジス
タ(MARR)15にセットすべきアドレスデータを設定
して行われる。そしてこのメモリアドレスレジスタ(M
ARR)15にセットされたアドレスデータに従って前記
メモリ6をアドレス指定し、指定されたメモリ6のアド
レスに前記メモリデータレジスタ(MDRR)13に格納
されているデータを書き込むことによって行われる。
The data storage of the register file 3 by the background processing is performed by storing the data stored in the register in the internal bus 2 when the background processing is designated as described later by the selection designation of the register by the counter 12. Memory data register (MD
The data is transferred to the RR) 13 and stored therein, and at the same time, under the control of the address controller (ACONT) 14, the address data to be set in the memory address register (MARR) 15 is set. And this memory address register (M
This is done by addressing the memory 6 according to the address data set in the ARR) 15 and writing the data stored in the memory data register (MDRR) 13 to the specified address of the memory 6.

このバックグラウンド処理は、例えば第2図に示すよう
なプログラム命令を用いてバックグラウンド保存の機能
を起動することによって行われる。このバックグラウン
ド保存は、ソフトウェア的な観点からはプログラムの実
行プロセスと同等なものであるが、この実施例における
バックグラウンドでのレジスタ内容の保存プロセスは前
述したプログラムの実行と並行してハードウェア的に制
御・実行されるものとなっている。
This background processing is performed by activating a background saving function using a program command as shown in FIG. 2, for example. This background saving is equivalent to the program execution process from a software point of view, but the background register content saving process in this embodiment is performed in hardware in parallel with the execution of the program described above. It is controlled and executed by.

即ち、この実施例ではユーザが自らのプログラム内でサ
ブルーチンをコールし、これによってコンテキストの切
り替えを行うようになっており、第2図に示すようにそ
のプログラムの最初でバックグラウンドでのレジスタ内
容の保存を指定するものとなっている。
That is, in this embodiment, the user calls a subroutine in his / her own program to switch the context, and as shown in FIG. 2, at the beginning of the program, the register contents in the background are changed. It is designated to save.

つまりここでは『save-background命令』によりレジス
タ内容を保存する為の前記メモリ6における保存領域ア
ドレス[SAVE-ADDRESS]を指定する。この第2図に示す
例では、汎用レジスタの全てをデータ保存対象とするレ
ジスタとして暗黙の内に指定するものとなっているが、
例えば商用のマイクロプロセッサのように保存対象とす
るレジスタをビットマップ等によって選択的に指定可能
な場合には、オペランドを用いてレジスタを指定するよ
うにすることも可能である。
That is, here, the save area address [SAVE-ADDRESS] in the memory 6 for saving the register contents is designated by the "save-background instruction". In the example shown in FIG. 2, all of the general-purpose registers are implicitly designated as the data storage target registers.
For example, when a register to be saved can be selectively designated by a bitmap or the like like a commercial microprocessor, it is possible to designate the register by using an operand.

また第2図に示すソフトウェアでは、コンテキストの切
り替えが行われる前に『save-multiple命令』が与えら
れ、前述した『save-background命令』でバックグラウ
ンド保存がなされたレジスタ以外のレジスタに残された
データを強制的に保存するものとなっている。
Further, in the software shown in FIG. 2, the "save-multiple instruction" is given before the context is switched, and the "save-background instruction" is left in the registers other than the background-saved registers. Data is forcibly saved.

尚、レジスタの全てに対してのバックグラウンド保存が
完了している場合には、上述した『save-multiple命
令』は『no-operation命令』として看做される。
When the background saving is completed for all the registers, the above-mentioned "save-multiple instruction" is regarded as a "no-operation instruction".

その後、コンテキストの切り替えによって再び制御が戻
ってきた場合には、『load-multiple命令』によって前
記メモリ6に退避格納されていたレジスタ内容の読出し
が行われ、前記レジスタファイル3の復元が行われる。
この場合にもメモリ6に対する保存領域アドレス[SAVE
-ADDRESS]の指定により、どのコンテキストのレジスタ
内容を復元するかが指定される。
After that, when the control returns again due to the context switching, the register contents saved and stored in the memory 6 are read by the "load-multiple instruction", and the register file 3 is restored.
Also in this case, the save area address [SAVE
-ADDRESS] specifies in which context the register contents are restored.

次に上記第2図に示すプログラムの実行に伴う前述した
第1図に示すCPU内部回路での動作について第3図を
参照して説明する。
Next, the operation of the CPU internal circuit shown in FIG. 1 described above in association with the execution of the program shown in FIG. 2 will be described with reference to FIG.

『save-background命令』によってバックグラウンド処
理が指定された場合、バックグラウンド処理の為のコン
トローラ5が起動され、バックグラウンド処理に関連す
る各部の動作がそれぞれ制御される。しかしてこのバッ
クグラウンド処理の起動により、先ず前記『save-backg
round命令』により指定される前記メモリ6における保
存領域アドレス[SAVE-ADDRESS]がALU4から内部バ
ス2を介してアドレスコントローラ(ACONT)14に
セットされる。同時にカウンタ12に対する初期化が行わ
れ(ステップa)、前記レジスタファイル3に準備され
た複数のレジスタを順次指定する為のカウンタ動作が開
始される。
When the background process is designated by the "save-background instruction", the controller 5 for the background process is activated, and the operation of each unit related to the background process is controlled. However, by starting this background processing, first, the above-mentioned "save-backg
The save area address [SAVE-ADDRESS] in the memory 6 designated by the "round instruction" is set in the address controller (ACONT) 14 from the ALU 4 via the internal bus 2. At the same time, the counter 12 is initialized (step a), and the counter operation for sequentially designating a plurality of registers prepared in the register file 3 is started.

このカウンタ12により生成されるデータによるレジスタ
ファイル3のアクセスは、ALU4にて実行中のプログ
ラムによってレジスタファイル3がアクセスされていな
い期間を利用して行われる。換言すればALU4による
レジスタファイル3のアクセスの方が、カウンタ12によ
るレジスタファイル3のアクセスに優先して定められて
おり、ALU4はレジスタファイル3を優先的に使用し
て所定のプログラムを実行するものとなっている。そし
てカウンタ12はレジスタファイル3の空き状態が検出さ
れている場合にのみレジスタファイル3をアクセスする
ことで、上述したプログラムの実行と並行してレジスタ
保存処理を起動するものとなっている。
The access of the register file 3 by the data generated by the counter 12 is performed while the register file 3 is not accessed by the program being executed by the ALU 4. In other words, the access of the register file 3 by the ALU 4 is determined prior to the access of the register file 3 by the counter 12, and the ALU 4 preferentially uses the register file 3 to execute a predetermined program. Has become. The counter 12 accesses the register file 3 only when the empty state of the register file 3 is detected, thereby activating the register saving process in parallel with the execution of the above-mentioned program.

しかしてカウンタ12によるレジスタファイル3のアクセ
スが行われると、先ずそのカウンタ値がアドレスコント
ローラ(ACONT)14に読み込まれる(ステップ
b)。同時に前記レジスタファイル3から前記カウンタ
値によって指定されるレジスタに付属して設けられてい
るフラグの情報を前記内部バス2を介して読み出す。前
記アドレスコントローラ14は当該レジスタに付属して設
けられているフラグを参照し、そのレジスタの内容のメ
モリ6への格納保存が完了しているか否かを調べる(ス
テップc)。即ち、レジスタに付属して設けられている
フラグは、当該レジスタの内容がバックグラウンド処理
によって後述するようにメモリ6に格納保存されたとき
にセットされ、プログラムの実行によってレジスタ内容
が更新されたとき、或いは上記バックグラウンド処理に
よるレジスタ内容のメモリ保存が成功する以前にレジス
タ内容が破壊(更新)されたときにリセットされるもの
で、フラグ“1”によりレジスタ内容の格納保存が完了
したことを示すものとなっている。
When the register file 3 is accessed by the counter 12, the counter value is first read into the address controller (ACONT) 14 (step b). At the same time, the information of the flag provided attached to the register designated by the counter value is read from the register file 3 via the internal bus 2. The address controller 14 refers to a flag attached to the register to check whether the storage of the contents of the register in the memory 6 is completed (step c). That is, the flag provided to the register is set when the content of the register is stored and saved in the memory 6 by the background processing as described later, and when the content of the register is updated by the execution of the program. Alternatively, it is reset when the register contents are destroyed (updated) before the memory saving of the register contents by the background processing is successful, and the flag "1" indicates that the storage and saving of the register contents are completed. It has become a thing.

アドレスコントローラ(ACONT)14は、このような
フラグを参照することで当該レジスタの内容をメモリ6
に保存するか否かを制御する。ちなみにフラグが既に
“1”にセットされている場合には、そのレジスタ内容
のメモリ6への保存処理を再度行うことは全くの無駄で
あることから、フラグ“1”の情報に従って当該レジス
タ内容の格納保存処理が禁止される。そして前記コント
ローラ5の制御の下でカウンタ12の値の更新が行われ
(ステップd)、次のレジスタに対する内容保存処理が
起動される。
The address controller (ACONT) 14 refers to such a flag to copy the contents of the register to the memory 6
Controls whether to save to. By the way, if the flag is already set to "1", it is completely useless to save the register content in the memory 6 again. Therefore, according to the information of the flag "1" Store and save processing is prohibited. Then, under the control of the controller 5, the value of the counter 12 is updated (step d), and the content saving process for the next register is started.

しかして前記カウンタ12によって指定されたレジスタの
フラグが“0”であった場合には、前記アドレスコント
ローラ(ACONT)14は前記ALU4によって指定さ
れた前記保存領域アドレス[SAVE-ADDRESS]に上記カウ
ンタ12によって指定される値を加算し、これによって求
められるメモリ6のアドレス値をメモリアドレスレジス
タ(MARR)15にセットする(ステップe)。つまり
保存領域アドレス[SAVE-ADDRESS]に前記カウンタ12に
よって指定されるレジスタに対する相対アドレスを加算
することでメモリ6に対するレジスタデータ格納の為の
絶対アドレスを求め、これをメモリアドレスレジスタ
(MARR)15にセットする。このメモリアドレスレジ
スタ15へのアドレスデータのセットに伴い、前記レジス
タファイル3から前記カウンタ12によって指定されるレ
ジスタの内容が前記内部バス2を介して読出され、メモ
リデータレジスタ(MDRR)13に格納する(ステップ
f)。
When the flag of the register designated by the counter 12 is “0”, the address controller (ACONT) 14 sets the counter 12 to the save area address [SAVE-ADDRESS] designated by the ALU 4. The value specified by is added, and the address value of the memory 6 obtained by this is set in the memory address register (MARR) 15 (step e). That is, the absolute address for storing the register data in the memory 6 is obtained by adding the relative address to the register designated by the counter 12 to the save area address [SAVE-ADDRESS], and this is stored in the memory address register (MARR) 15. set. With the setting of the address data in the memory address register 15, the contents of the register designated by the counter 12 are read from the register file 3 via the internal bus 2 and stored in the memory data register (MDRR) 13. (Step f).

しかしてメモリアドレスレジスタ(MARR)15にメモ
リ6に対するアドレスデータがセットされ、このアドレ
スに書き込むべきレジスタ内容がメモリデータレジスタ
(MDRR)13に格納されると、前記メモリコントロー
ラ(MCONT)7に対してメモリ6のアクセス要求が
発せられる。メモリコントローラ7はこのアクセス要求
に対してメモリバス8の空きを待ち、前記メモリ6への
前記レジスタ内容の書き込みを許可する。このメモリ6
への前記レジスタ内容の書き込みを行うためのアクセス
要求の順位は、プログラムの実行を妨げることのないよ
うに最低に設定される。従ってメモリバス8に空きがあ
る場合にのみ、前記メモリコントローラ(MCONT)
7の制御の下で前記メモリアドレスレジスタ(MAR
R)15にによって指定されるメモリ6のアドレスへの前
記メモリデータレジスタ(MDRR)13に格納されてい
るレジスタ内容の書き込みが行われる(ステップg)。
Then, when the address data for the memory 6 is set in the memory address register (MARR) 15 and the register content to be written at this address is stored in the memory data register (MDRR) 13, the memory controller (MCONT) 7 is sent. An access request for the memory 6 is issued. In response to this access request, the memory controller 7 waits for a free space on the memory bus 8 and permits writing of the register contents to the memory 6. This memory 6
The order of access requests for writing the contents of the register to is set to the lowest so as not to hinder the execution of the program. Therefore, only when the memory bus 8 has a space, the memory controller (MCONT)
Under the control of the memory address register (MAR
The register contents stored in the memory data register (MDRR) 13 are written to the address of the memory 6 designated by R) 15 (step g).

尚、このようなレジスタ内容のメモリ6への書き込みは
所定時間に亘って行われる。そしてその書き込みに成功
した場合には(ステップh)、前記コントローラ5の制
御の下でレジスタファイル3に対して保存成功の通知が
なされ、当該レジスタに付属して設けられているがフラ
グが“1”にセットされる(ステップi)。その後、前
述したようにしてカウンタ12のカウント値をアップし
(ステップd)、次のレジスタ内容の保存処理に移行す
る。
The writing of such register contents to the memory 6 is performed for a predetermined time. If the writing is successful (step h), the register file 3 is notified of the successful saving under the control of the controller 5, and the flag provided as "1" is attached to the register. Is set to "" (step i). After that, the count value of the counter 12 is increased as described above (step d), and the process proceeds to the storage process of the next register contents.

このようなレジスタ内容のメモリ6への格納保存処理を
前述したカウンタ12によるレジスタの選択指定と、指定
されたレジスタに付属するフラグの値に応じて順次繰り
返して実行する。しかもプログラムの実行と並行して、
該プログラムの実行を妨げることのない空き時間を利用
したバックグラウンド処理にてレジスタ内容の保存処理
が行われる。
The process of storing and saving the register contents in the memory 6 is sequentially and repeatedly executed according to the selection and designation of the register by the counter 12 and the value of the flag attached to the designated register. Moreover, in parallel with the execution of the program,
The register contents are saved in the background process using a free time that does not hinder the execution of the program.

一方、このようなバックグラウンド処理が実行されてい
るとき、このバックグラウンド処理とは無関係に、その
メインルーチンではプログラムの実行が行われる(ステ
ップA)。しかして前記コントローラ5ではプログラム
の実行に伴ってレジスタの内容が変更されたか否かを監
視しており(ステップB)、レジスタ内容に変更が生じ
た場合には当該レジスタに付属して設けられているフラ
グがセットされているか否かを調べている(ステップ
C)。そして当該レジスタのフラグが“1”である場
合、既にメモリ6に保存された内容と現にレジスタに格
納されている内容とに違いが生じることから、その新た
な内容をメモリ6に保存するべく前記フラグをリセット
する(ステップD)。
On the other hand, when such background processing is being executed, the program is executed in the main routine regardless of this background processing (step A). However, the controller 5 monitors whether or not the contents of the register are changed in accordance with the execution of the program (step B). When the contents of the register are changed, the controller 5 is attached to the register. It is checked whether the flag indicating that the flag is set is set (step C). When the flag of the register is "1", the contents already stored in the memory 6 differ from the contents actually stored in the register. Therefore, the new contents should be stored in the memory 6 as described above. Reset the flag (step D).

以上のような処理手続きによりレジスタにそれぞれ付属
されたフラグのセット・リセットが制御され、フラグが
セットされているレジスタを除いて、つまりメモリ6へ
の内容保存がなされていないレジスタについてだけ、フ
ラグ“0”の情報に従ってメモリ6への保存処理が行わ
れる。しかもコンテキストの切替え指示とは独立に、プ
ログラムの実行過程においてバックグラウンド的に、プ
ログラムの実行によりレジスタファイル3へのアクセス
が行われていない期間や、メモリバス8の空き時間等を
利用してレジスタ内容のメモリ6への保存が行われる。
更には内容保存がなされていないレジスタに対しての
み、或いは内容の更新があったレジスタに対してのみ、
その内容のメモリ6への保存が行われる。
By the processing procedure as described above, the setting / resetting of the flags respectively attached to the registers is controlled, and only the registers for which the contents are not stored in the memory 6 are excluded, except for the registers for which the flags are set. The storage process to the memory 6 is performed according to the information of "0". Moreover, independently of the context switching instruction, the register is used in the background during the execution of the program in the background while the register file 3 is not being accessed by the execution of the program, the free time of the memory bus 8 or the like. The contents are stored in the memory 6.
Furthermore, only for registers that have not been saved, or only for registers that have been updated,
The contents are stored in the memory 6.

この結果、コンテキストの切替え指示が与えられた場合
には、上述したバックグラウンド処理によってメモリ6
への内容保存が完了していないレジスタだけを前記フラ
グから調べ、このフラグによって示されるレジスタの内
容だけを前述した『save-multiple命令』に従って保存
するだけで、その全てのレジスタ内容を短時間に効率的
に保存してしまうことが可能となる。従ってコンテキス
トの切替えに伴うレジスタ内容の保存処理を非常に効率
良く実行し、その切り替え処理の高速化を図ることが可
能となる。
As a result, when the context switching instruction is given, the memory 6 is processed by the background processing described above.
Only the registers whose contents have not been saved to are checked from the flag, and only the contents of the register indicated by this flag are saved according to the above-mentioned "save-multiple instruction", and all the register contents are saved in a short time. It becomes possible to save efficiently. Therefore, it is possible to perform the register content saving process associated with the context switching very efficiently and speed up the switching process.

またこのようなレジスタ内容の保存処理によれば、プロ
グラムを実行しながらバックグラウンド処理にてレジス
タ内容を逐次メモリ6に保存していくので、CPUに準
備されたレジスタ数が多い場合であっても、コンテキス
トの切り替え時に保存すべきレジスタの内容がさほど増
大することがない。従ってレジスタの数に拘らず、コン
テキストの切り替え処理を効率的に行うことが可能とな
る。
Further, according to such a register content saving process, the register contents are sequentially saved in the memory 6 in the background process while executing the program, so that even when the number of registers prepared in the CPU is large. , The contents of registers to be saved do not increase so much when switching contexts. Therefore, the context switching process can be efficiently performed regardless of the number of registers.

また従来のように複数のレジスタを選択的に用いてコン
テキストを実行するものとは異なるので、取り扱い得る
コンテキストの数に事実上制限が加わることがなく、メ
モリ6を有効に利用してコンテキストのそれぞれに対応
したレジスタ内容の保存を行うことが可能となる等の利
点がある。
Further, since it is different from the conventional one in which a plurality of registers are selectively used to execute a context, the number of contexts that can be handled is not practically limited, and the memory 6 can be effectively used for each context. There is an advantage that the contents of the register corresponding to can be saved.

尚、本発明は上述した実施例に限定されるものではな
い。ここでは『save-background命令』を全ての汎用レ
ジスタを対象として実行するものとして説明したが、保
存対象とするレジスタを指定した上で『save-backgroun
d命令』を与えることで、その保存対象レジスタをセレ
クトするようにすることも可能である。また実施例では
レジスタ保存用のメモリアドレスレジスタ13と通常のデ
ータ保存用のメモリアドレスレジスタ10とを別々のもの
とし、またレジスタ保存用のデータレジスタ15と通常の
データ保存用のデータレジスタ9についても別々のもの
としたが、これらを或る制約条件の下で共用すること
で、そのハードウェア量を少なくするようにしても良
い。またレジスタファイル3からデータとフラグとを読
出し、当該フラグによってデータ保存を制御する処理
を、レジスタに対応する連想メモリを用いて行うように
することも勿論可能である。また汎用レジスタを対象と
してそのレジスタ内容の保存を行うことのみならず、コ
ンテキストを回復するための種々のレジスタ群を対象と
してその保存処理を行っても良いことは云うまでもな
い。その他、本発明はその要旨を逸脱しない範囲で種々
変形して実施することができる。
The present invention is not limited to the above embodiment. Here, the "save-background instruction" was explained as being executed for all general-purpose registers, but after specifying the registers to be saved, "save-backgroun"
It is also possible to select the register to be saved by giving "d instruction". Further, in the embodiment, the memory address register 13 for register saving and the memory address register 10 for normal data saving are separate, and the data register 15 for register saving and the data register 9 for normal data saving are also provided. Although they are separate, the hardware amount may be reduced by sharing them under a certain constraint condition. It is also possible to read the data and the flag from the register file 3 and control the data storage by the flag by using the associative memory corresponding to the register. Needless to say, not only the contents of the general-purpose registers are saved, but also the saving process may be performed for various register groups for restoring the context. In addition, the present invention can be variously modified and implemented without departing from the scope of the invention.

[発明の効果] 以上説明したように本発明によれば、プログラムの実行
に対してバックグラウンド処理にてレジスタの内容を逐
次保存していくので、コンテキストの切り替え時におけ
るレジスタ内容の保存処理を非常に簡単なものとし、ま
た実質的にその処理を不要とすることができる。これ
故、コンテキストの切り替えを非常に効率的に実行する
ことが可能となる。またフラグを用いてレジスタ内容の
保存を制御するので、処理の無駄を招くことなく効率的
にレジスタ内容の保存を行ない得ると云う実用上多大な
る効果が奏せられる。
[Effects of the Invention] According to the present invention as described above, the contents of the registers are sequentially saved in the background processing with respect to the execution of the program. In addition, the processing can be simplified and the processing can be substantially eliminated. Therefore, the context switching can be performed very efficiently. Further, since the storage of the register contents is controlled by using the flag, there is a practically great effect that the register contents can be efficiently saved without causing waste of processing.

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

図は本発明の一実施例に係るレジスタ保存方法につき示
すもので、第1図は実施例方法を適用して構成される中
央処理装置の内部構成を概略的に示す図、第2図は実施
例方法で用いられるレジスタ保存処理の為のプログラム
例を示す図、第3図は実施例方法におけるレジスタ保存
処理の手続きの流れを示す図である。 3……レジスタファイル(RF)、 4……算術演算ユニット(ALU)、 5……コントローラ(CONT)、 6……メモリ(MRY)、 7……メモリアドレスコントローラ(MCONT) 12……カウンタ(CTR)、 13……データレジスタ(MDRR)、 14……アドレスコントローラ(ACONT)、 15……アドレスレジスタ(MARR)。
FIG. 1 shows a register saving method according to an embodiment of the present invention. FIG. 1 is a diagram schematically showing an internal configuration of a central processing unit configured by applying the embodiment method, and FIG. FIG. 3 is a diagram showing a program example for register saving processing used in the example method, and FIG. 3 is a diagram showing a procedure flow of register saving processing in the example method. 3 ... Register file (RF), 4 ... Arithmetic operation unit (ALU), 5 ... Controller (CONT), 6 ... Memory (MRY), 7 ... Memory address controller (MCONT) 12 ... Counter (CTR) ), 13 ... Data register (MDRR), 14 ... Address controller (ACONT), 15 ... Address register (MARR).

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】サブルーチンを含むプログラムの最初でバ
ックグラウンド保存命令及び保存領域アドレスが指定さ
れ、前記プログラム内での前記サブルーチンの直前でマ
ルチプル保存命令及び保存領域アドレスが指定されたプ
ログラム命令列を順次実行する計算機のレジスタ保存方
法であって、 プログラムの実行に必要な情報を保持するための複数の
レジスタに、プログラムの実行によって前記レジスタの
内容が更新されたときにリセットされるフラグを夫々付
属させて設け、 前記バックグラウンド保存命令を実行する際には、リセ
ットされたフラグの有無を順次調べ、リセットされたフ
ラグが有る場合に当該レジスタの内容を前記保存領域ア
ドレスに従ってメモリへ格納し、この格納に成功したと
きに当該フラグをセットする各処理を、前記バックグラ
ウンド保存命令の直後から前記マルチプル保存命令の直
前までのプログラムの実行と並行して、該プログラムの
実行を妨げることのない空き時間を利用して行ない、 前記マルチプル保存命令を実行する際に、リセットされ
たフラグの有無を順次調べ、リセットされたフラグが有
る場合に当該レジスタの内容を前記保存領域アドレスに
従って前記メモリへ格納し、この格納に成功したときに
当該フラグをセットすることを特徴とするレジスタ保存
方法。
1. A program instruction sequence in which a background save instruction and a save area address are designated at the beginning of a program including a subroutine, and a program instruction sequence in which a multiple save instruction and a save area address are designated immediately before the subroutine in the program is sequentially performed. A method for saving registers of a computer to be executed, wherein a plurality of registers for holding information necessary for executing a program are each provided with a flag that is reset when the contents of the register are updated by executing the program. When executing the background save command, the presence or absence of a reset flag is sequentially checked, and if there is a reset flag, the contents of the register are stored in the memory according to the save area address, and this storage is performed. Each process that sets the flag when In parallel with the execution of the program from immediately after the background save instruction to immediately before the multiple save instruction, the free time that does not hinder the execution of the program is used, and when the multiple save instruction is executed, It is characterized in that the presence or absence of a reset flag is sequentially checked, the contents of the register are stored in the memory according to the storage area address when there is a reset flag, and the flag is set when the storage is successful. How to save registers.
JP1104632A 1989-04-26 1989-04-26 Register saving method Expired - Lifetime JPH0640311B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP1104632A JPH0640311B2 (en) 1989-04-26 1989-04-26 Register saving method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP1104632A JPH0640311B2 (en) 1989-04-26 1989-04-26 Register saving method

Publications (2)

Publication Number Publication Date
JPH02284235A JPH02284235A (en) 1990-11-21
JPH0640311B2 true JPH0640311B2 (en) 1994-05-25

Family

ID=14385823

Family Applications (1)

Application Number Title Priority Date Filing Date
JP1104632A Expired - Lifetime JPH0640311B2 (en) 1989-04-26 1989-04-26 Register saving method

Country Status (1)

Country Link
JP (1) JPH0640311B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7272703B2 (en) * 1997-08-01 2007-09-18 Micron Technology, Inc. Program controlled embedded-DRAM-DSP architecture and methods

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS57212551A (en) * 1981-06-25 1982-12-27 Toshiba Corp Operation controller
JPS63311537A (en) * 1987-06-15 1988-12-20 Pfu Ltd Arithmetic processor
JPH01217635A (en) * 1988-02-26 1989-08-31 Fujitsu Ltd Register saving system

Also Published As

Publication number Publication date
JPH02284235A (en) 1990-11-21

Similar Documents

Publication Publication Date Title
US5701493A (en) Exception handling method and apparatus in data processing systems
US5161226A (en) Microprocessor inverse processor state usage
JP2650675B2 (en) Method and operating system for executing a program in a multi-mode microprocessor
US5557766A (en) High-speed processor for handling multiple interrupts utilizing an exclusive-use bus and current and previous bank pointers to specify a return bank
US5125087A (en) Method of resetting sequence of access to extended memory disrupted by interrupt processing in 80286 compatible system using code segment register
US20060036824A1 (en) Managing the updating of storage keys
JP4024751B2 (en) Selective access to multiple registers with a common name
US20140122849A1 (en) Apparatus and method for handling exception events
JPH0450621B2 (en)
JP2539913B2 (en) Data processing system
US20050028159A1 (en) Memory managing system and task controller in multitask system
WO1985001136A1 (en) Processor with depictor-linked microcode and logic circuitry
JPH07120338B2 (en) Method for a data processor to coordinate the execution of instructions by a coprocessor and the data processor
JP3525070B2 (en) Access control device and access method
JPH0640311B2 (en) Register saving method
EP0206335B1 (en) Interruption method for a data processing system
JP3539984B2 (en) Processor
US20080072009A1 (en) Apparatus and method for handling interrupt disabled section and page pinning apparatus and method
US5201052A (en) System for transferring first and second ring information from program status word register and store buffer
JPH0668725B2 (en) Device for responding to interrupt condition in data processing system and method for responding to asynchronous interrupt condition
JPS61184643A (en) Starting control system for virtual computer
JPH0443301B2 (en)
JPH0756633B2 (en) Task switching method
JP2883488B2 (en) Instruction processing unit
EP1104899A2 (en) Data processing apparatus and method of controlling the same

Legal Events

Date Code Title Description
EXPY Cancellation because of completion of term