JPH04211837A - Register saving system - Google Patents
Register saving systemInfo
- Publication number
- JPH04211837A JPH04211837A JP7923790A JP7923790A JPH04211837A JP H04211837 A JPH04211837 A JP H04211837A JP 7923790 A JP7923790 A JP 7923790A JP 7923790 A JP7923790 A JP 7923790A JP H04211837 A JPH04211837 A JP H04211837A
- Authority
- JP
- Japan
- Prior art keywords
- register
- contents
- saving
- cpu
- task
- 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
Links
- 238000000034 method Methods 0.000 claims description 6
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 230000000694 effects Effects 0.000 description 2
- 239000013256 coordination polymer Substances 0.000 description 1
- 230000001934 delay Effects 0.000 description 1
- 230000003111 delayed effect Effects 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 239000011159 matrix material Substances 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 238000004904 shortening Methods 0.000 description 1
Abstract
Description
【発明の詳細な説明】
〔産業上の利用分野〕
本発明は、マルチタスク・オペレーティングシステムに
関し、特にタスク切替え時のレジスタ内容の退避方法に
関する。DETAILED DESCRIPTION OF THE INVENTION [Field of Industrial Application] The present invention relates to a multitasking operating system, and particularly to a method for saving register contents when switching tasks.
シングルプロセッサのシステムにおいて、マイクロプロ
セッサ(以下、CPUと略す)を効率良く使用する為に
、多重プログラミングの手法が用いられる。多重プログ
ラミングでは、プログラムを実行単位であるタスクに分
割し、オペレーティングシステム(以下、OSと略す)
が種々の状況に応じてタスクを選択し、CPU実行権を
割当てる。OSが、あるタスクにCPU実行権を割当て
る際には、現在CPUを使用しているタスクのコンテキ
ストをその格納領域に退避し、割当てるタスクのコンテ
キスト格納領域からコンテキストを復帰する。この時の
動作を第7図と第8図を参照しながら説明する。In a single-processor system, a multiple programming method is used to efficiently use a microprocessor (hereinafter abbreviated as CPU). In multiple programming, a program is divided into tasks, which are execution units, and the operating system (hereinafter abbreviated as OS)
selects tasks according to various situations and assigns CPU execution rights. When the OS allocates the CPU execution right to a certain task, it saves the context of the task currently using the CPU into its storage area, and restores the context from the context storage area of the assigned task. The operation at this time will be explained with reference to FIGS. 7 and 8.
第7図は、CPUのレジスタセットの例を示したもので
ある。このCPUは、32ビット長のレジスタ32本を
持つ。又、CPUは、これらのレジスタの退避及び復帰
は、それぞれ命令持っているものとする。第8図は、C
PU実行権を移す際の処理フローを示したものである。FIG. 7 shows an example of a CPU register set. This CPU has 32 registers with a length of 32 bits. It is also assumed that the CPU has instructions for saving and restoring these registers. Figure 8 shows C
This figure shows the processing flow when transferring the PU execution right.
今、タスクは簡単の為に、タスクAとタスクBの2つと
する。For simplicity, we will assume that there are two tasks: Task A and Task B.
タスクAにCPU実行権があり、タスクAからタスクB
にCPU実行権が移るものとする。また、タスクのコン
テキストを、第7図に示したレジスタセットとし、コン
テキスト格納領域は、タスクコントロールブロック(以
下、TCBと略す)内に確保されているものとする。Task A has CPU execution authority, and task A to task B
Assume that the CPU execution right is transferred to Further, it is assumed that the context of the task is the register set shown in FIG. 7, and that the context storage area is secured within the task control block (hereinafter abbreviated as TCB).
CPUの実行権を切替える為に、OSはタスクAのTC
Bアドレスを得る(第8図の■)。OSは、このTCB
内にタスクAのコンテキストを格納する為に、レジスタ
セットの退避命令を実行する。この命令によってCPU
は、32本のレジスタを、レジスタROから順にレジス
タR31まで全て格納する(第8図の■)。次に、実行
持ちの行列の先頭から、タスクBのTCBアドレスを得
る(第8図の■)。OSは、このTCB内のタスクBの
コンテキストをCPUのレジスタに格納する為に、レジ
スタセットの復帰命令を実行する。この命令によってC
PUは、TCB内に格納してあるデータをレジスタRO
からR31に格納する(第8図の■)。この様にすてO
Sは、タスクAからタスクBにCPUのコンテキストを
入替える。In order to switch the execution right of the CPU, the OS uses the TC of task A.
Obtain the B address (■ in Figure 8). The OS is this TCB
A register set save instruction is executed to store the context of task A within. This instruction causes the CPU to
stores all 32 registers in order from register RO to register R31 (■ in FIG. 8). Next, the TCB address of task B is obtained from the head of the execution matrix (■ in FIG. 8). The OS executes a register set return instruction to store the context of task B in this TCB in the register of the CPU. This command causes C
The PU transfers the data stored in the TCB to the register RO.
and stored in R31 (■ in FIG. 8). Throw it away like this
S switches the CPU context from task A to task B.
情報処理システムにおいて、アプリケーションプログラ
ムから見たOSの処理時間は、余分な処理時間(オーバ
ーヘッド)とみなされる。上述した、タスクコンテキス
トの切替え処理の時間もオーバーヘッドであり、極力短
いことが望ましい。In an information processing system, OS processing time seen from an application program is considered extra processing time (overhead). The time for the task context switching process described above is also an overhead, and is preferably as short as possible.
しかしながら、32ビットのレジスタを32本、計12
8バイトのデータをメモリに退避し、同量のデータをメ
モリからレジスタに格納する処理は、極めて長い時間が
かかる。従って、アプリケーションプログラムの切替わ
りが遅れ、処理の遅延を引起こすことになる。特に、こ
の様な遅延が発生すると、リアルタイム処理を中心とし
た組込み型のOSでは、割込みに対する応答時間が落ち
る事になる。例えばデータ転送を例にとると、OSのオ
ーバーヘッドによって到着したデータの処理に時間がか
かり、次に送られてきたデータを見落す事にもなりかね
ない。However, there are 32 32-bit registers, a total of 12
The process of saving 8 bytes of data to memory and storing the same amount of data from memory to a register takes an extremely long time. Therefore, switching of application programs is delayed, causing processing delays. In particular, when such a delay occurs, the response time to an interrupt will decrease in an embedded OS that mainly performs real-time processing. For example, in the case of data transfer, it takes time to process arriving data due to OS overhead, and the next data sent may be overlooked.
また、RISCの思想を取入れたCPUでは、レジスタ
数の増加は確実であり、この様なCPUを利用したシス
テムにおけるOSのオーバーヘッドは、ますます増加す
ることになる。Furthermore, in a CPU that incorporates the RISC concept, the number of registers is certain to increase, and the overhead of the OS in a system using such a CPU will further increase.
本発明は、複数本のレジスタセットを持つCPUにおい
て、前記レジスタセットに一対一に対応した情報を保持
する手段と、前記レジスタの内容が変更された時に前記
情報保持手段に対応するレジスタの内容が変更されたこ
とを示す情報を格納する手段を有している。The present invention provides, in a CPU having a plurality of register sets, a means for holding information in one-to-one correspondence with the register set, and a means for holding information that corresponds to the register set in a one-to-one manner; It has means for storing information indicating that it has been changed.
本発明の実施例を図を参照しながら説明する。 Embodiments of the present invention will be described with reference to the drawings.
第1図は、本発明の一つの実施例を示したものである。FIG. 1 shows one embodiment of the invention.
第1図において、一つのレジスタには、対応するモディ
ファイビットが設けられている。In FIG. 1, one register is provided with a corresponding modify bit.
第2図は、本実施例を用いたレジスタセットを示してい
る。第3図は、第2図のレジスタの内容を退避する際の
フローを示している。第1表は、第1図のモディファイ
ビットの意味を示している。FIG. 2 shows a register set using this embodiment. FIG. 3 shows the flow when saving the contents of the registers in FIG. 2. Table 1 shows the meanings of the modify bits in FIG.
次に、従来と同様の状況における動作を第2図、第3図
及び第8図を用いて説明する。第8図の■の動作は、従
来例と同じであるため、第8図の■から説明する。Next, the operation in a situation similar to the conventional one will be explained using FIGS. 2, 3, and 8. Since the operation indicated by ``■'' in FIG. 8 is the same as that of the conventional example, the operation will be explained from ``■'' in FIG. 8.
従来と同様に、OSはレジスタセットを退避する為の命
令を実行する。CPUはレジスタR0から順に格納する
が、この際各レジスタに対応したモディファイビットを
参照する。今、モディファイビットが第2図に示してい
るようになっているものとする。まずCPUは、レジス
タR0に対応したモディファイビットをチェックする。As in the past, the OS executes an instruction to save the register set. The CPU sequentially stores data starting from register R0, and at this time refers to the modify bits corresponding to each register. Assume that the modify bits are now as shown in FIG. First, the CPU checks the modify bit corresponding to register R0.
このモディファイビットは『1』である。よって、CP
Uは、レジスタR0の内容をコンテキスト格納領域に格
納し、格納アドレスを更新する。レジスタR1、R2、
R3のモディファイビットもレジスタR0と同様に『1
』である。よって、レジスタR1、R2、R3の内容も
コンテキスト格納領域に格納する。次に、レジスタR4
のモディファイビットをチェックする。レジスタ4のモ
ディファイビットは『0』である。よって、レジスタR
4の内容は格納せず、格納アドレスのみを更新する。This modification bit is "1". Therefore, C.P.
U stores the contents of register R0 in the context storage area and updates the storage address. Register R1, R2,
The modify bit of R3 is also “1” like register R0.
”. Therefore, the contents of registers R1, R2, and R3 are also stored in the context storage area. Next, register R4
Check the modification bits. The modify bit of register 4 is "0". Therefore, register R
The contents of 4 are not stored, and only the storage address is updated.
レジスタR5からレジスタR28までのモディファイビ
ットは『0』である。従ってこの間、レジスタの内容は
格納せず、格納アドレスのみを更新する。レジスタR2
9、30、31のモディファイビットは『1』である。The modify bits from register R5 to register R28 are "0". Therefore, during this time, the contents of the register are not stored, and only the storage address is updated. Register R2
Modification bits 9, 30, and 31 are "1".
従って、レジスタR0の時と同様、レジスタの内容をコ
ンテキスト格納領域に格納する。以上の様にしてCPU
は、レジスタセットの退避を行なう。Therefore, as with register R0, the contents of the register are stored in the context storage area. CPU as above
saves the register set.
次に、OSは、タスクBのTCBアドレスを得る(第8
図の■)。OSは、TCBに格納してあるタスクBのコ
ンテキストをCPUのレジスタに格納する為に、レジス
タセットの復帰命令を実行する。この命令によってCP
Uは、モディファイビットを全て『0』にし、コンテキ
スト格納領域に格納してあるデータをレジスタR0から
R31に格納する(第8図の■)。Next, the OS obtains the TCB address of task B (the eighth
■) in the figure. The OS executes a register set return instruction in order to store the context of task B stored in the TCB in the register of the CPU. With this command, CP
U sets all the modify bits to "0" and stores the data stored in the context storage area in registers R0 to R31 (■ in FIG. 8).
この様にしてOSは、タスクのコンテキストを入替える
。In this way, the OS replaces the task context.
本発明のもう一つの実施例を、前実施例と同様に、図を
参照しながら説明する。Another embodiment of the invention will be described in the same manner as the previous embodiment with reference to the figures.
第4図は、本発明の一つの実施例を示したものである。FIG. 4 shows one embodiment of the present invention.
第5図は、本実施例の動作例を示している。第6図は、
第4図で示した実施例を用いた時の、レジスタの内容を
退避する際のフローを示している。FIG. 5 shows an example of the operation of this embodiment. Figure 6 shows
4 shows a flow for saving the contents of a register when the embodiment shown in FIG. 4 is used.
次に、従来と同様の状況における動作を第5図、第6図
及び第8図を用いて説明する。第8図の■の動作は、実
施例1と同じであるため、第8図の■から説明する。Next, the operation in a situation similar to the conventional one will be explained using FIGS. 5, 6, and 8. Since the operation indicated by {circle around (2)} in FIG. 8 is the same as in the first embodiment, the operation will be explained starting from {circle around (2)} in FIG.
実施例1と同様に、OSはレジスタセットを退避する為
の命令を実行する。今、モディファイビットワードが第
5図の■に示すようになっている。CPUは、モディフ
ァイビットワードを1ビット右シフトする(第5図の■
)。モディファイビットワードのビット0は『1』であ
り、キャリーが発生する。よって、CPUは、レジスタ
R0の内容をコンテキスト格納領域に格納し、格納アド
レスを更新する。レジスタR1、R2、R3のモディフ
ァイビットもレジスタR0と同様に『1』である。従っ
て、右シフトの結果キャリーが発生する(第5図の■)
。よって、レジスタR1、R2、R3の内容もコンテキ
スト格納領域に格納する。As in the first embodiment, the OS executes an instruction to save the register set. The modify bit word is now as shown in (■) in FIG. The CPU shifts the modify bit word to the right by one bit (■ in Figure 5).
). Bit 0 of the modify bit word is "1" and a carry occurs. Therefore, the CPU stores the contents of register R0 in the context storage area and updates the storage address. The modify bits of registers R1, R2, and R3 are also "1" like register R0. Therefore, a carry occurs as a result of right shift (■ in Figure 5)
. Therefore, the contents of registers R1, R2, and R3 are also stored in the context storage area.
再び、モディファイビットワードを1ビット右シフトす
る。この時のビット0は『0』である。Again, shift the modify bit word to the right by one bit. Bit 0 at this time is "0".
よって、レジスタR4の内容は格納せず、格納アドレス
のみを更新する。レジスタR5からレジスタR28に対
応するビットは全て『0』である。Therefore, the contents of register R4 are not stored, and only the storage address is updated. All bits corresponding to registers R5 to R28 are "0".
従って、この間CPUは、レジスタの内容は格納せず、
モディファイビットワードのシフトの格納アドレスの更
新を行なう(第5図の■)。再びモディファイワードビ
ットを右シフトする。この時ビット0は『1』である。Therefore, during this time, the CPU does not store the contents of the register,
The storage address of the shift of the modify bit word is updated (■ in FIG. 5). Shift the modify word bits to the right again. At this time, bit 0 is "1".
よって、レジスタR29の内容をコンテキスト格納領域
に格納する。レジスタ30、31に対応するビットは『
1』である(第5図の■)。従って、レジスタ30、3
1の内容もコンテキスト格納領域に格納する。以上の様
にしてCPUは、レジスタセットの退避を行なう。Therefore, the contents of register R29 are stored in the context storage area. The bits corresponding to registers 30 and 31 are “
1'' (■ in Figure 5). Therefore, registers 30,3
The contents of 1 are also stored in the context storage area. As described above, the CPU saves the register set.
次に、OSは、タスクBのTCBアドレスを得る(第8
図の■)。OSは、この領域に格納してあるタスクBの
コンテキストをCPUのレジスタに格納する為に、レジ
スタセットの復帰命令を実行する。この命令によってC
PUは、コンテキスト格納領域に格納してあるデータを
レジスタR0からR31に格納する(第8図の■)。Next, the OS obtains the TCB address of task B (the eighth
■) in the figure. The OS executes a register set return instruction in order to store the context of task B stored in this area in the CPU register. This command causes C
The PU stores the data stored in the context storage area in registers R0 to R31 (■ in FIG. 8).
この様にしてOSは、タスクのコンテキストを入替える
。In this way, the OS replaces the task context.
以上述べたように、本発明はレジスタセット退避する時
に、そのタスクの実行によって使用されなかったレジス
タの退避を行わずに格納アドレスのみを更新する為に、
レジスタ退避の処理時間を短くすることができるという
効果がある。これによって、OS処理の中でも最も処理
速度を要求されるコンテキストの切替えを高速化するこ
とができる。従って、従来の問題点であった、OS処理
によるオーバーヘッドを縮小することができる。As described above, when saving a register set, the present invention updates only the storage address without saving registers that were not used by the execution of the task.
This has the effect of shortening the register saving processing time. This makes it possible to speed up context switching, which requires the highest processing speed among OS processing. Therefore, the overhead caused by OS processing, which has been a problem in the past, can be reduced.
第1図は、本発明の実施例1を示したものである。
第2図は、実施例1を用いたレジスタセットの例を示し
ている。
第3図は、実施例1を用いたレジスタセットの退避フロ
ーを示している。
第4図は、本発明の実施例2を示したものである。
第5図は、実施例2の動作例を示している。
第6図は、実施例2を用いたレジスタセットの退避フロ
ーを示している。
第7図は、従来のCPUのレジスタセットを示したもの
である。
第8図は、タスクコンテキストとしのレジスタセットを
入替える際のフローを示したものである。
第1表は、第1図、第4図におけるモディファイビット
の意味を示している。
代理人 弁理士 内原晋FIG. 1 shows a first embodiment of the present invention. FIG. 2 shows an example of a register set using the first embodiment. FIG. 3 shows a register set saving flow using the first embodiment. FIG. 4 shows a second embodiment of the present invention. FIG. 5 shows an example of the operation of the second embodiment. FIG. 6 shows a register set saving flow using the second embodiment. FIG. 7 shows a register set of a conventional CPU. FIG. 8 shows the flow when replacing the register set as a task context. Table 1 shows the meanings of the modify bits in FIGS. 1 and 4. Agent: Susumu Uchihara, patent attorney
Claims (1)
いて、前記レジスタセットに一対一に対応した情報を保
持する手段と、前記レジスタの内容が変更された時レジ
スタの内容が変更されたことを示す情報を前記レジスタ
に対応する前記情報保持手段に格納する手段を有し、前
記情報保持手段の情報を基に前記レジスタの内容を退避
することを特徴とするレジスタ退避方式。In a microprocessor having a plurality of register sets, means for retaining information in one-to-one correspondence with the register set, and means for retaining information indicating that the register contents have been changed when the contents of the registers are changed. 1. A register saving method, comprising means for storing in said information holding means corresponding to said information holding means, and saving the contents of said register based on information in said information holding means.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP7923790A JPH04211837A (en) | 1990-03-28 | 1990-03-28 | Register saving system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP7923790A JPH04211837A (en) | 1990-03-28 | 1990-03-28 | Register saving system |
Publications (1)
Publication Number | Publication Date |
---|---|
JPH04211837A true JPH04211837A (en) | 1992-08-03 |
Family
ID=13684258
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP7923790A Pending JPH04211837A (en) | 1990-03-28 | 1990-03-28 | Register saving system |
Country Status (1)
Country | Link |
---|---|
JP (1) | JPH04211837A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5935237A (en) * | 1996-05-30 | 1999-08-10 | Nec Corporation | Microprocessor capable of carrying out different data length instructions |
US5974512A (en) * | 1996-02-07 | 1999-10-26 | Nec Corporation | System for saving and restoring contents of a plurality of registers |
-
1990
- 1990-03-28 JP JP7923790A patent/JPH04211837A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5974512A (en) * | 1996-02-07 | 1999-10-26 | Nec Corporation | System for saving and restoring contents of a plurality of registers |
US5935237A (en) * | 1996-05-30 | 1999-08-10 | Nec Corporation | Microprocessor capable of carrying out different data length instructions |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6829697B1 (en) | Multiple logical interfaces to a shared coprocessor resource | |
JP3787167B2 (en) | Flash memory | |
KR100313261B1 (en) | Low Power Multi-task Controller (Name Correction) | |
EP0087978B1 (en) | Information processing unit | |
US6401155B1 (en) | Interrupt/software-controlled thread processing | |
US5212778A (en) | Message-driven processor in a concurrent computer | |
US8307053B1 (en) | Partitioned packet processing in a multiprocessor environment | |
FI78993C (en) | OEVERVAKARE AV DRIFTSYSTEM. | |
JPH09212371A (en) | Register saving and restoring system | |
EP1436724A1 (en) | Multi-threaded packet processing engine for stateful packet pro cessing | |
WO2001016715A9 (en) | Branch instructions in a multithreaded parallel processing system | |
JPH0353328A (en) | Register saving recoverying method and processor | |
KR100678930B1 (en) | Real-time Control System for Digital Signal Processor | |
EP0239078A2 (en) | Register saving/restoring system | |
JPH10207717A (en) | Microcomputer | |
JPH04211837A (en) | Register saving system | |
Quammen et al. | Register window management for a real-time multitasking RISC | |
JPH07210400A (en) | Processor for multi-task processing | |
US6711655B1 (en) | Finding available memory space by finding its associated memory transfer controller | |
JP2689914B2 (en) | Information processing device | |
JP2579008B2 (en) | Time-division multitasking execution device | |
JP2742245B2 (en) | Parallel computer | |
JPH02163834A (en) | Multi-task processing system | |
JP2004021610A (en) | Task managing device | |
JPH0477930A (en) | Microcomputer |